TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: CosmicTruth on March 05, 2009, 08:17:38 AM
-
I'm trying to write a routine to draw circles along a polyline at each vertice
I don't understand the foreach conditionals or for that matter I dont understand LISP at all
the code i made so far seems to be putting the right things into the variables but i'm stuck at the meat of the routine to actually draw the circles at each angle point along the polyline...
;;;Circle along polyline routine to make a circle at each polyline vertice sized to (* .04 drawing scale)
(defun c:capl ()
(setq scmde (getvar "cmdecho")) ;set scmde to current cmdecho setting
(setvar "cmdecho" 0) ;turn off command echo
(setq str "What is the drawing scale: ") ;set up the string for scale prompt
(setq s (getint str)) ;set s to drawing scale
(setq ds (* s 0.04)) ;make ds=circle radius
(setq l (entsel
"Select a Polyline"
)
) ;ask for pl select
;;;=====HELP=====
;;; I need some code to draw a circle at each polyline vertice
;;; the circle radius should be ds
(setvar "cmdecho" scmde) ;reset commandecho var
(princ)
)
can someone please help me code this?
-
Maybe this will help
http://forums.augi.com/showthread.php?t=39710&highlight=polyline
-
Not much that hasn't been done here. :evil:
http://www.theswamp.org/index.php?topic=10187.0
-
This is a commented version of one of the routines in my link.
(defun c:circlepline (/ ent vlst pt)
(and ; and will stop at any nill
(setq ent (car (entsel "\nSelect pline to add circles.")))
(or (= (cdr (assoc 0 (entget ent))) "LWPOLYLINE") ; verify entity type
(prompt "\nNot a LWpolyline."))
;; get the pline vertex in a list
(setq vlst (mapcar 'cdr (vl-remove-if-not
'(lambda (x) (= 10 (car x))) (entget ent))))
(foreach pt vlst ; make the circles
(entmake (list '(0 . "CIRCLE")
(cons 8 "0") ; layer, comment out to use current layer
(cons 10 pt) ; center pt
(cons 40 (getvar "Dimscale")) ; radius of circle
))
)
)
(princ) ; this leaves no message when the routine ends
)
-
Welcome to theswamp Cosmic! :pissed:
-
Welcome to theswamp Cosmic! :pissed:
Does not seem like much of a welcome :?
-
Here's a variant of CAB's code to place circles on vertex when cursor is near them:
(defun c:circlepline (/ vtx done ent p pt vlst vs)
(if (and (setq ent (entsel "\nSelect pline to add circles."))
(setq vlst (mapcar 'cdr
(vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget (car ent)))
)
)
)
(while (and (setq p (grread 5)) (= (car p) 5))
(princ (strcat "\rPut cursor near vertex to add circle: "))
(setq pt (cadr p)
vs (* (getvar 'viewsize) 0.005)
vtx (vl-remove-if-not '(lambda (x)
(and (equal (car x) (car pt) vs) (equal (cadr x) (cadr pt) vs))
)
vlst
)
)
(if (and vtx (not (vl-position vtx done)))
(progn (setq done (cons vtx done))
(entmake (list '(0 . "CIRCLE")
(cons 8 "0")
(cons 10 (car vtx)) ; center pt
'(40 . 18.0) ; 18 units radius
)
)
)
)
)
)
(princ)
)
(c:circlepline)
-
Thanks Ron.
Where were my manors. 8-)
Welcome CosmicTruth to The Swamp.
-
Thanks for the warm welcomes
and the great codes : )
its working great, now I need a fun way to trim the circles.
hey i'm going to buy a book, anyone know a good one?
Thanks
: )
-
I am not a big fan of trimming the lines.
Consider placing a block with your circle at an elvation of 2 and a wipeout with an elevation of 1 relative to the polyline vertex.
This still gives a visual appearance of the line being broken, but an inquiry on the line will still give the correct distance between verticies.
Just my 2 cents worth.
Welcome to the swamp :lol:
Cheers
Scott
-
Thanks for the warm welcomes
and the great codes : )
its working great, now I need a fun way to trim the circles.
hey i'm going to buy a book, anyone know a good one?
Thanks
: )
Take a look here for trimming circles: http://www.theswamp.org/index.php?topic=20164.msg245188#msg245188
-
Thanks for the help, I learned alot.
I know its not much but here is a prize for helping me...
(http://www.theswamp.org/screens/Swamp.jpg)
: )
Cosmic
-
I like it. (http://www.theswamp.org/screens/index.php?dir=cab/&file=av-BigGrin.gif)