Lucas Lim Posted September 20, 2010 Posted September 20, 2010 Does anyone knows whether there are any codes where i can add circles to the all the vertices of polylines automatically? Quote
fixo Posted September 20, 2010 Posted September 20, 2010 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) ) Quote
Lucas Lim Posted September 20, 2010 Author Posted September 20, 2010 thx for the reply fixo. FYI i just started to learn and use lisp.do u know where i can download the complete lisp for this problem? Quote
Tharwat Posted September 20, 2010 Posted September 20, 2010 thx for the reply fixo. FYI i just started to learn and use lisp.do u know where i can download the complete lisp for this problem? Could you please tell where the problem is ? Tharwat Quote
Lucas Lim Posted September 20, 2010 Author Posted September 20, 2010 sorry i am just being a bit blur.the codes does work well. just another question.is there a way to select multiple polylines? Quote
Tharwat Posted September 20, 2010 Posted September 20, 2010 YES of course . (setq ss (ssget '((0 . "LWPOLYLINE,POLYLINE")))) But you have to add more functions to the above, if you have intents to replace it with fixo routine. Quote
Lucas Lim Posted September 20, 2010 Author Posted September 20, 2010 may i know wat function should i add as i hv hundreds of polylines to be selected.it would be faster if i could select all the polylines at a time Quote
irneb Posted September 20, 2010 Posted September 20, 2010 Well, fixo's routine uses entsel (Entity Select - which only asks for one single entity). What tharwat's suggesting is using the ssget (Selection Set Get). However, this gives something other than an entity reference. What I'd suggest is replacing the entsel with a ssget, but also move it outside the while loop (you only want to select the PLs once in one go don't you?). Then you need to obtain the number of selected entities, use sslength for this. Then you need to loop through the selection set (incrementing an index variable from 0 up to -1 sslength, or do it the other way round if you don't mind the order of the circles). From there you use ssname to obtain the entity reference of the nth item in the selection set. From there on it should be nearly the same. Quote
Tharwat Posted September 20, 2010 Posted September 20, 2010 irneb Absolutely right. And here is a start for your routine Lucas Lim . (if (setq ss1 (ssget ":L" '((0 . "POLYLINE,LWPOLYLINE")))) (progn (setq i -1 ss1 (sslength ss1) ) (while (setq e (ssname ss1 (setq i (1+ i)))) (................... (princ) ) Tharwat Quote
Lt Dan's legs Posted September 20, 2010 Posted September 20, 2010 http://www.cadtutor.net/forum/showthread.php?51700-Vertices-of-a-Polyline&highlight=dxf+polylines Quote
fixo Posted September 20, 2010 Posted September 20, 2010 thx for the reply fixo. FYI i just started to learn and use lisp.do u know where i can download the complete lisp for this problem? this is a great net resource: http://www.afralisp.net/ FYI, I had started to learn lisp from there Thanks to Kenny Ramage The Great ~'J'~ Quote
alanjt Posted September 20, 2010 Posted September 20, 2010 (edited) I did this the other day... (defun c:COV (/ foo ss) ;; Circles On Vertices (create circle on vertices of selected Arcs, Lines, *Polylines, Splines) ;; Alan J. Thompson, 09.09.10 / 09.22.10 (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 . "CIRCLE") (cons 10 p) (cons 40 *COV:RAD*))) ) ) pLst ) ) ) ) ) (if (and (setq ss (ssget '((0 . "ARC,LINE,*POLYLINE,SPLINE")))) (not (initget 6)) (setq *COV:RAD* (cond ((getdist (strcat "\nSpecify circle radius" (if *COV:RAD* (strcat " <" (rtos *COV:RAD*) ">: ") ": " ) ) ) ) (*COV:RAD*) ) ) ) ((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) ) Edited September 24, 2010 by alanjt Quote
irneb Posted September 21, 2010 Posted September 21, 2010 I did this the other day...This was actually a query on AUGI a short while ago. :wink:http://forums.augi.com/showthread.php?t=123189 Quote
afrazawan Posted September 22, 2010 Posted September 22, 2010 please help me how i ll use this code in auto cad pls how can i insert this code in cad Quote
fixo Posted September 22, 2010 Posted September 22, 2010 please help me how i ll use this code in auto cad pls how can i insert this code in cad Take a look at this thread http://www.cadtutor.net/forum/showthread.php?1390-How-to-use-the-LISP-routines-in-this-archive Quote
Tharwat Posted September 22, 2010 Posted September 22, 2010 please help me how i ll use this code in auto cad pls how can i insert this code in cad Read this . http://www.cadtutor.net/forum/showthread.php?1390-How-to-use-the-LISP-routines-in-this-archive Tharwat Quote
irneb Posted September 22, 2010 Posted September 22, 2010 "Simple" way copy-n-paste the code to ACad's command line. "Better" way, save code into a LSP file - then drag-n-drop onto ACad. More "official" way, use AppLoad, browse to LSP file & click Load. "Quicker" and more customizable way, save file to one of the folders in Options --> Files --> Support Paths, type (load "Filename") at the AC command line (including the parentheses and change filename to that which you gave the LSP file). This you need to do for each DWG you've got open, since it will only load it for the current drawing. You could use the (vl-load-all "Filename") to load it for the entire ACad session. Or otherwise there are numerous ways of getting it to load "automatically". Quote
alanjt Posted September 22, 2010 Posted September 22, 2010 Above code updated; thought of an easier way to retrieve vertices for LWPolylines and Polylines. Quote
udomsak Posted May 18, 2016 Posted May 18, 2016 I did this the other day... (defun c:COV (/ foo ss) ;; Circles On Vertices (create circle on vertices of selected Arcs, Lines, *Polylines, Splines) ;; Alan J. Thompson, 09.09.10 / 09.22.10 (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 . "CIRCLE") (cons 10 p) (cons 40 *COV:RAD*))) ) ) pLst ) ) ) ) ) (if (and (setq ss (ssget '((0 . "ARC,LINE,*POLYLINE,SPLINE")))) (not (initget 6)) (setq *COV:RAD* (cond ((getdist (strcat "\nSpecify circle radius" (if *COV:RAD* (strcat " <" (rtos *COV:RAD*) ">: ") ": " ) ) ) ) (*COV:RAD*) ) ) ) ((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) ) Hi brp If I want to change the circle to point How to? Quote
Tharwat Posted May 18, 2016 Posted May 18, 2016 Hi brpIf I want to change the circle to point How to? Hi, Alan has not posted in CADTutor for a quite long time and personally I hope he would resume participating in this forum again as before. Anyway try the following modification and let me know: (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) ) 1 Quote
Recommended Posts
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.