Author Topic: to place a circle in the vertex, regardless of the polyline , 2d polyline  (Read 1913 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 291
Hi
Sorry  for new ask
I need some help
That is same below
I want to place a circle in the all vertex, regardless of the polyline
, lwpolyline  , 2d polyline  , 3d polyline
Pls help me again

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
I had something so just added circle.

Code: [Select]
; pline co-ords example 2d or 3d
; By Alan H June 2018

(defun plinecords (/ xyz obj i co-ords)

; program starts here
  (setq co-ordsxy '())

  (setq obj (vlax-ename->vla-object (car (entsel "\nPlease pick pline"))))

  (cond
    ((= (vla-get-ObjectName obj) "AcDbPolyline") (setq xyz 2))
    ((= (vla-get-ObjectName obj) "AcDbLine") (setq xyz 1))
    ((= (vla-get-ObjectName obj) "AcDb3dPolyline") (setq xyz 3))
    ((alert "Object not supported\n\nPlease pick again"))
  )

  (if (> xyz 1)
    (progn
      (setq co-ords
            (vlax-safearray->list
              (vlax-variant-value
                (vlax-get-property
                  obj
                  "Coordinates"
                )
              )
            )
      )
    )
  )

  (if (= xyz 1)
    (progn
      (setq xyz (vlax-safearray->list (vlax-variant-value (vla-get-startpoint obj))))
      (setq co-ordsxy (cons xyz co-ordsxy))
      (setq xyz (vlax-safearray->list (vlax-variant-value (vla-get-endpoint obj))))
      (setq co-ordsxy (cons xyz co-ordsxy))
    )
  )

  (if (= xyz 2)
    (progn
      (setq I 0)
      (repeat (/ (length co-ords) 2)
        (setq xyz (list (nth i co-ords) (nth (+ I 1) co-ords)))
        (setq co-ordsxy (cons xyz co-ordsxy))
        (setq I (+ I 2))
      )
    )
  )

  (if (= xyz 3)
    (progn
      (setq I 0)
      (repeat (/ (length co-ords) 3)
        (setq xyz (list (nth i co-ords) (nth (+ I 1) co-ords) (nth (+ I 2) co-ords)))
        (setq co-ordsxy (cons xyz co-ordsxy))
        (setq I (+ I 3))
      )
    )
  )
  (alert "co-ords are in variable co-ordsxy")
  (princ)
)

(plinecords)

(repeat (setq x (length co-ordsxy))
(command "circle" (nth (setq x (- x 1)) co-ordsxy) 5)
)
A man who never made a mistake never made anything

Dlanor

  • Bull Frog
  • Posts: 263
Try this

Code - Auto/Visual Lisp: [Select]
  1. (defun rh:sammlung_n (o_lst grp / tmp n_lst)
  2.   (setq n_lst nil)
  3.   (cond ( (and o_lst (= (rem (length o_lst) grp) 0))
  4.           (while o_lst
  5.             (repeat grp (setq tmp (cons (car o_lst) tmp) o_lst (cdr o_lst)))
  6.             (setq n_lst (cons (reverse tmp) n_lst) tmp nil)
  7.           );end_while
  8.         )  
  9.   );end_cond
  10.   (if n_lst (reverse n_lst))
  11. );end_defun rh:sammlung_n
  12.  
  13. (defun rh:223 (lst z / a) (setq a (mapcar '(lambda (x) (reverse (cons z (reverse x)))) lst)))
  14.  
  15. (defun c:ATV ( / c_doc ms c_rad ent obj grp elev p_lst)
  16.  
  17.         ms (vla-get-modelspace c_doc)
  18.   );end_setq
  19.  
  20.   (initget 6)
  21.   (setq c_rad (getreal "\nEnter Circle Radius : "))
  22.  
  23.   (while (setq ent (car (entsel "\nSelect Polyline : ")))
  24.     (setq obj (vlax-ename->vla-object ent))
  25.    
  26.     (cond ( (wcmatch (vlax-get-property obj 'objectname) "*3d*") (setq grp 3 elev nil))
  27.           ( (/= (vlax-get-property obj 'elevation) 0.0) (setq grp 2 elev (vlax-get-property obj 'elevation)))
  28.           (t (setq grp 2 elev 0.0))
  29.     );end_cond
  30.     (setq p_lst (rh:sammlung_n (vlax-get obj 'coordinates) grp))
  31.     (if (= grp 2) (setq p_lst (rh:223 p_lst elev)))
  32.     (foreach pt p_lst
  33.       (vla-addcircle ms (vlax-3d-point pt) c_rad)
  34.     );end_foreach
  35.   );end_while
  36. );end_defun
  37.