MastroLube Posted September 3, 2015 Share Posted September 3, 2015 Hello guys, I don't know why but i got stacked with my lisp! I've to create a polyline from a list of points and I really can't understand how to do that. I just searched everywhere but something is missed.. That's what I'm doing: 1. create a polyline -> extract coordinates (SETQ coordinate1 (VLAX-SAFEARRAY->LIST (VLAX-VARIANT-VALUE (VLAX-GET-PROPERTY obj1 'Coordinates)) ) ) 2. doing an offset from it and extract coordinates (SETQ coordinate3 (VLAX-SAFEARRAY->LIST (VLAX-VARIANT-VALUE (VLAX-GET-PROPERTY obj1 'Coordinates)) ) ) Now I want to merge these lines (merge list of points and entmake a polyline). The second one is oriented as the first one, I need to invert it! I have 2 problems: 1. can't append the list of points, because i got something like that: (1 2 3 4 5 6 ..) instead of ((1 2) (3 4) (5 6) (..) ..) (setq lista_punti (append lista_punti (list (nth n coordinate1) (nth (1+ n) coordinate1)))) 2. Really don't know exactly of to entmake that.. I saw something with lamda funcion. (entmakex (append (list '(0 . "LWPOLYLINE") ;nome '(100 . "AcDbEntity") '(100 . "AcDbPolyline") ;'(8 . "Muri") ;layer ;'(62 . 5) ;colore (cons 90 (length coordinate1)) ;numero vertici '(90 . 4) '(70 . 1) ;1 chiusa, 0 aperta ) ;istructions here? ) ) Can someone give me an advice please? Thanks Quote Link to comment Share on other sites More sharing options...
Commandobill Posted September 3, 2015 Share Posted September 3, 2015 A guy named freerefill put this together a while back. Not the cleanest code ever, but it's super reliable. (defun plverts (ent / retn listy retDum add1 add2) ; (vl-load-com) (if (= (cdr (assoc 0 (entget ent))) "LWPOLYLINE") (progn (setq retn nil listy (vlax-safearray->list (vlax-variant-value (vla-get-coordinates (vlax-ename->vla-object ent)) ) ) ) (while (and (setq var1 (car listy)) (setq var2 (cadr listy))) (setq retn (append retn (list (list var1 var2 0)))) (setq listy (cddr listy)) ) ) ) retn ) ; Returns a list of 3D coordinates defining the vertices of a polygon Quote Link to comment Share on other sites More sharing options...
Commandobill Posted September 3, 2015 Share Posted September 3, 2015 So you can do this: (SETQ coordinate1 (plverts ent1)) to get your points for both, then just append the two lists. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted September 3, 2015 Share Posted September 3, 2015 I guess that I don't understand. Do you want a continuous pline to incorporate the 2 exiting lines with vertices thru the mid points of the shape and add end caps as well ? The vertex order shown in attached jpg would not have any overlaying segment -David Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 3, 2015 Share Posted September 3, 2015 This should help (minus the hatch). Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 4, 2015 Share Posted September 4, 2015 This is another example create a pline form a list of points. ; co-ordsxy is a list of 2d points (setq x -1) ; so x starts at nth 0 at start and closing (command "PLINE" (while (= (getvar "cmdactive") 1) (COMMAND (repeat (length co-ordsxy) (nth (setq x (+ x 1)) co-ordsxy) ) ) ) ) (command "C") Quote Link to comment Share on other sites More sharing options...
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.