Jump to content

Drawing circles to all vertices of polyline


Recommended Posts

Posted
(defun c:POV (/ foo ss)
 ;; Points On Vertices (create points on vertices of selected Arcs, Lines, *Polylines, Splines)
 ;; Alan J. Thompson, 09.09.10 / 09.22.10
 ;; Modified by Tharwat - Date: 18.May.16

 (defun foo (p)
   (if (vl-consp p)
     (or (vl-member-if
           (function (lambda (a) (equal (list (car a) (cadr a)) (list (car p) (cadr p)))))
           plst
         )
         (setq plst (cons (cdr
                            (assoc 10
                                   (entmake (list '(0 . "POINT") (cons 10 p)))
                            )
                          )
                          pLst
                    )
         )
     )
   )
 )
 (if (setq ss (ssget '((0 . "ARC,LINE,*POLYLINE,SPLINE"))))
   ((lambda (i / e eLst p pLst)
      (while (setq e (ssname ss (setq i (1+ i))))
        (cond
          ((vl-position (cdr (assoc 0 (setq eLst (entget e)))) '("ARC" "LINE" "SPLINE"))
           (mapcar (function foo) (list (vlax-curve-getStartPoint e) (vlax-curve-getEndPoint e)))
          )
          ((vl-position (cdr (assoc 0 eLst)) '("LWPOLYLINE" "POLYLINE"))
           (repeat (setq p (1+ (fix (vlax-curve-getEndParam e))))
             (foo (vlax-curve-getPointAtParam e (setq p (1- p))))
           )
          )
        )
      )
    )
     -1
   )
 )
 (princ)
)

 

in that can u add circle object also,

good program, i need as well as point at circle center.

 

thanks

Posted

plz add circle object also in pov.lsp program, need point at circle center also.

 

Posted
1 hour ago, Ish said:

plz add circle object also in pov.lsp program, need point at circle center also.

 

Like this?

(defun c:POV (/ foo ss)
 ;; Points On Vertices (create points on vertices of selected Arcs, Lines, *Polylines, Splines)
 ;; Alan J. Thompson, 09.09.10 / 09.22.10
 ;; Modified by Tharwat - Date: 04.Jul.19
 (defun foo (p)
   (if (vl-consp p)
     (or (vl-member-if (function (lambda (a) (equal (list (car a) (cadr a)) (list (car p) (cadr p))))) plst)
         (setq plst (cons (cdr (assoc 10 (entmake (list '(0 . "POINT") (cons 10 p))))) pLst))))
   )
 (if (setq ss (ssget '((0 . "ARC,LINE,*POLYLINE,SPLINE,CIRCLE"))))
   ((lambda (i / e eLst p pLst)
      (while (setq e (ssname ss (setq i (1+ i))))
        (cond
          ((vl-position (cdr (assoc 0 (setq eLst (entget e)))) '("ARC" "LINE" "SPLINE"))
           (mapcar (function foo) (list (vlax-curve-getStartPoint e) (vlax-curve-getEndPoint e)))
          )
          ((vl-position (cdr (assoc 0 eLst)) '("LWPOLYLINE" "POLYLINE"))
           (repeat (setq p (1+ (fix (vlax-curve-getEndParam e))))
             (foo (vlax-curve-getPointAtParam e (setq p (1- p))))
           )
          )
          (t
           (mapcar (function foo) (list (cdr (assoc 10 (entget e)))))
          )
        )
      )
    )
     -1
   )
 )
 (princ)
)

 

  • Like 1
Posted

👍Yes sir Perfectly working , 

just add a small code for to create layer, all points must be come in layer.

 

Thanks

 

Posted
53 minutes ago, Tharwat said:

(setq plst (cons (cdr (assoc 10 (entmake (list '(0 . "POINT") (cons 8 "YourLayerNameHere") (cons 10 p))))) pLst))))

 

3 minutes ago, Ish said:

👍Yes sir Perfectly working , 

just add a small code for to create layer, all points must be come in layer.

 

Thanks

 

Add Your layer name as indicated above.

  • Like 1
Posted

where i must copy paste that code ?

from above which line?

Posted

for points must be  points.

My Desire Layer Name is Points.

Posted
3 minutes ago, Ish said:

for points must be  points.

My Desire Layer Name is Points.

(defun c:POV (/ foo ss)
 ;; Points On Vertices (create points on vertices of selected Arcs, Lines, *Polylines, Splines)
 ;; Alan J. Thompson, 09.09.10 / 09.22.10
 ;; Modified by Tharwat - Date: 04.Jul.19
 (defun foo (p)
   (if (vl-consp p)
     (or (vl-member-if (function (lambda (a) (equal (list (car a) (cadr a)) (list (car p) (cadr p))))) plst)
         (setq plst (cons (cdr (assoc 10 (entmake (list '(0 . "POINT") '(8 . "Points") (cons 10 p))))) pLst))))
   )
 (if (setq ss (ssget '((0 . "ARC,LINE,*POLYLINE,SPLINE,CIRCLE"))))
   ((lambda (i / e eLst p pLst)
      (while (setq e (ssname ss (setq i (1+ i))))
        (cond
          ((vl-position (cdr (assoc 0 (setq eLst (entget e)))) '("ARC" "LINE" "SPLINE"))
           (mapcar (function foo) (list (vlax-curve-getStartPoint e) (vlax-curve-getEndPoint e)))
          )
          ((vl-position (cdr (assoc 0 eLst)) '("LWPOLYLINE" "POLYLINE"))
           (repeat (setq p (1+ (fix (vlax-curve-getEndParam e))))
             (foo (vlax-curve-getPointAtParam e (setq p (1- p))))
           )
          )
          (t (mapcar (function foo) (list (cdr (assoc 10 eLst))))
          )
        )
      )
    )
     -1
   )
 )
 (princ)
)

 

  • Like 1
Posted
On 7/4/2019 at 6:02 PM, Tharwat said:

You're welcome anytime. :) 

👍👍

  • 5 months later...
Posted

 

Please. Could someone add the vertex number (1,2,3 ... n) and the prefix V- to the circle? V-1, V-2, V-3, V-N ...

  • 1 month later...
Posted
On 20/09/2010 at 08:38, fixo said:

See if that helps

 


(defun C:PCIRC (/  coords ent rad)
 (setq rad (getreal"\nEnter radius: "))
           (while (setq ent (entsel "\nSelect polyline (or press Enter to Exit) >> "))
           (setq ent (car ent))
      (setq coords (vl-remove-if 'not
      (mapcar
        (function (lambda(p)
      (if (= 10 (car p))(cdr p))))
        (entget ent))))
      
      (foreach pt coords
 (command "_circle" "_non" pt rad)   
   )
         )
           (princ)
 )
 

Can anyone tell me how to see the circles on every vertix?

I have uploaded the LISP successfully but I cant see any changes on the polylines that I have drawn..

 

  • 11 months later...
Posted (edited)
On 9/20/2010 at 9:38 AM, fixo said:

See if that helps

 


(defun C:PCIRC (/  coords ent rad)
 (setq rad (getreal"\nEnter radius: "))
           (while (setq ent (entsel "\nSelect polyline (or press Enter to Exit) >> "))
           (setq ent (car ent))
      (setq coords (vl-remove-if 'not
      (mapcar
        (function (lambda(p)
      (if (= 10 (car p))(cdr p))))
        (entget ent))))
      
      (foreach pt coords
 (command "_circle" "_non" pt rad)   
   )
         )
           (princ)
 )
I'm learning autolisp and I don't understand some fragments.
Can someone explain why there is used loop while (after entering radius) and the fragment with "vl-remove-if 'not" and "lambda"? Why in loop if there is "=10"?
 
 
I will be very grateful for help.

 

Edited by k88
Posted (edited)

The (while) loop just allows you to continue selecting polylines until you hit enter and entsel returns NIL.

 

(while (setq en (entsel "\nSelect an Entity: "))

;; Do soemthing for each selected entity...

) ;; End while when en variable is NIL (user pressed enter instead of selecting another entity).

 

The (vl-remove-if 'not) function is used to filter out the NIL values after (mapcar) is used to get the DXF code 10 (the vertices) from all the other entity codes returned by the (entget) function. The (mapcar) statement returns nils for anything that is not DXF code 10 and stacks them into the list.

 

Here is an example to show you how this works:

Command: (setq el (entget (car (entsel))))

Select object:

((-1 . <Entity name: 2015a32b6d0>) (0 . "LWPOLYLINE") (330 . <Entity name: 2014eac42d0>) (5 . "1D15") (100 . "AcDbEntity") (67 . 1)
(410 . "Sheet1") (8 . "0") (100 . "AcDbPolyline") (90 . 4) (70 . 0) (43 . 0.0) (38 . 0.0) (39 . 0.0) (10 3.91426 4.38087) (40 . 0.0)
(41 . 0.0) (42 . 0.0) (91 . 0) (10 5.66079 6.03297) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 8.18059 4.83386) (40 . 0.0) (41 . 0.0)
(42 . 0.0) (91 . 0) (10 10.5804 6.29943) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0))

Command: (setq elx (mapcar '(lambda (x) (if (= 10 (car x))(cdr x))) el))
(nil nil nil nil nil nil nil nil nil nil nil nil nil nil (3.91426 4.38087) nil nil nil nil (5.66079 6.03297) nil nil nil nil
(8.18059 4.83386) nil nil nil nil (10.5804 6.29943) nil nil nil nil nil)

Command: (vl-remove-if 'not elx)
((3.91426 4.38087) (5.66079 6.03297) (8.18059 4.83386) (10.5804 6.29943))

 EDITED: To better explain

Edited by pkenewell
  • Thanks 1
Posted

@k88 Updated my above post to explain a little better.

  • Like 1
Posted

Here is another example of using DXF code 10 for a pline. I use this a lot.

(setq plent (entsel "\nPick pline"))
(if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))

The vertice points are in the list co-ord.

 

You can use the VL function also

 

(setq co-ord (vlax-safearray->list (vlax-variant-value (vla-get-coordinates (car plent)))))

 

  • Like 1
  • Thanks 1
Posted
On 1/6/2021 at 4:46 PM, BIGAL said:

Here is another example of using DXF code 10 for a pline. I use this a lot.


(setq plent (entsel "\nPick pline"))
(if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))

The vertice points are in the list co-ord.

 

You can use the VL function also

 


(setq co-ord (vlax-safearray->list (vlax-variant-value (vla-get-coordinates (car plent)))))

 

@BIGAL It's worthwhile to note that these two options don't return the same results. Also you need to convert '(car plent) to a vla-object when using vla-get-coordinates.

image.thumb.png.9a24433f854a538960d8908113e6bc0f.png

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...