samifox Posted March 9, 2014 Share Posted March 9, 2014 hi how would you retrieve vertices list out of a polyline without using any of the vl-load-com functions? all approach that come to your mind is greatly welcome! Thanks Shay Quote Link to comment Share on other sites More sharing options...
vimcruz Posted March 9, 2014 Share Posted March 9, 2014 This? (defun VC:GetVertexList(edfx / vertex vertexList) (foreach vertex edfx (if (or (= (car vertex) 10) (= (car vertex) 11)) (setq vertexList (cons (cdr vertex) vertexList)) ) ) (reverse vertexList) ) Use it like this: (setq vertexList (VC:GetVertexList (entget (car (entsel))))) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 9, 2014 Share Posted March 9, 2014 Another, for both LWPolylines & Polylines: ;; Retrieve Polyline Vertices - Lee Mac ;; ent - [ent] Entity name of LWPolyline or Polyline (defun polyverts ( ent / _lwpolyverts _polyverts ) (defun _lwpolyverts ( enx / itm ) (if (setq itm (assoc 10 enx)) (cons (cdr itm) (_lwpolyverts (cdr (member itm enx)))) ) ) (defun _polyverts ( ent / enx ) (if (= "VERTEX" (cdr (assoc 0 (setq enx (entget ent))))) (cons (cdr (assoc 10 enx)) (_polyverts (entnext ent))) ) ) (if (= "LWPOLYLINE" (cdr (assoc 0 (entget ent)))) (_lwpolyverts (entget ent)) (_polyverts (entnext ent)) ) ) Call with polyline ename, e.g.: (if (setq s (ssget "_+.:E:S" '((0 . "*POLYLINE")))) (polyverts (ssname s 0)) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 10, 2014 Share Posted March 10, 2014 Why not use the vlisp method or is it to be used on a Mac ? You can tell the difference between a 2d and 3d pline. Quote Link to comment Share on other sites More sharing options...
samifox Posted March 12, 2014 Author Share Posted March 12, 2014 Why not use the vlisp method or is it to be used on a Mac ? You can tell the difference between a 2d and 3d pline. i think without using vlisp ill force myself to learn autolisp better, once ill feel comfortable with autolisp ill award myself with vlisp:) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 12, 2014 Share Posted March 12, 2014 i think without using vlisp ill force myself to learn autolisp better, once ill feel comfortable with autolisp ill award myself with vlisp:) You are on the right track . Quote Link to comment Share on other sites More sharing options...
samifox Posted March 12, 2014 Author Share Posted March 12, 2014 THANK YOU Tharwat Quote Link to comment Share on other sites More sharing options...
samifox Posted April 19, 2014 Author Share Posted April 19, 2014 This? (defun VC:GetVertexList(edfx / vertex vertexList) (foreach vertex edfx (if (or (= (car vertex) 10) (= (car vertex) 11)) (setq vertexList (cons (cdr vertex) vertexList)) ) ) (reverse vertexList) ) Use it like this: (setq vertexList (VC:GetVertexList (entget (car (entsel))))) why you test dxf 10 or dxf 11? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 19, 2014 Share Posted April 19, 2014 why you test dxf 10 or dxf 11? He may assumed that you may also select Line or LWpolyline Quote Link to comment Share on other sites More sharing options...
samifox Posted April 19, 2014 Author Share Posted April 19, 2014 thank you tharwat Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 19, 2014 Share Posted April 19, 2014 thank you tharwat No problem . Quote Link to comment Share on other sites More sharing options...
samifox Posted May 21, 2014 Author Share Posted May 21, 2014 hi why this one is not extracting points? (setq plst (mapcar '(lambda (x) (assoc 10 lst)) lst)) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 21, 2014 Share Posted May 21, 2014 hi why this one is not extracting points? (setq plst (mapcar '(lambda (x) (assoc 10 lst)) lst)) What is the value that assigned to variable " lst " ? Quote Link to comment Share on other sites More sharing options...
samifox Posted May 21, 2014 Author Share Posted May 21, 2014 Im not im front of acad but as i recall list of points Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 21, 2014 Share Posted May 21, 2014 Im not im front of acad but as i recall list of points Your answer is not clear enough , so what are you after with that previous codes ? Quote Link to comment Share on other sites More sharing options...
samifox Posted May 21, 2014 Author Share Posted May 21, 2014 Sorry when i get home ill posy the complete code Quote Link to comment Share on other sites More sharing options...
David Bethel Posted May 21, 2014 Share Posted May 21, 2014 I commend your learning of the basic autolisp first. The gotcha with heavy POLYLINES is the header group 70 and vertex group 70 codes: -> ARG -> POLYLINE ename [b][color=BLACK]([/color][/b]defun plpts [b][color=FUCHSIA]([/color][/b]en / ed mf vn vd vf[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq ed [b][color=NAVY]([/color][/b]entget en[b][color=NAVY])[/color][/b] mf [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 70 ed[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]= mf 0[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"I'm a open 2D Polyline\n"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]= [b][color=MAROON]([/color][/b]logand mf 1[b][color=MAROON])[/color][/b] 1[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"I'm a closed Polyline in theM direction\n"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]= [b][color=MAROON]([/color][/b]logand mf 2[b][color=MAROON])[/color][/b] 2[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"I'm a curved fit Polyline\n"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]= [b][color=MAROON]([/color][/b]logand mf 2[b][color=MAROON])[/color][/b] 4[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"I'm a spline-fit Polyline\n"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]= [b][color=MAROON]([/color][/b]logand mf 8[b][color=MAROON])[/color][/b] 8[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"I'm a 3D Polyline\n"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]= [b][color=MAROON]([/color][/b]logand mf 16[b][color=MAROON])[/color][/b] 16[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"I'm a 3D Polyline Mesh\n"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]= [b][color=MAROON]([/color][/b]logand mf 32[b][color=MAROON])[/color][/b] 32[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"I'm a closed Polyline Mesh in the N direction\n"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]= [b][color=MAROON]([/color][/b]logand mf 64[b][color=MAROON])[/color][/b] 64[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"I'm a PFACE Polyline Mesh\n"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]terpri[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq vn [b][color=NAVY]([/color][/b]entnext en[b][color=NAVY])[/color][/b] vd [b][color=NAVY]([/color][/b]entget vn[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]= [color=#2f4f4f]"VERTEX"[/color] [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc 0 vd[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq vp [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc 10 vd[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] vf [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc 70 vd[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [color=#8b4513];;;Here's where the fun begins![/color] [b][color=NAVY]([/color][/b]cond [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]and [b][color=BLUE]([/color][/b]= mf 0[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]= vf 0[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]= [b][color=RED]([/color][/b]cdr [b][color=PURPLE]([/color][/b]assoc 42 vd[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] 0[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]prin1 vp[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]princ [color=#2f4f4f]" - I'm a 2D Vertex point\n"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]and [b][color=BLUE]([/color][/b]= mf 0[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]= vf 0[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]/= [b][color=RED]([/color][/b]cdr [b][color=PURPLE]([/color][/b]assoc 42 vd[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] 0[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]prin1 vp[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]princ [color=#2f4f4f]" - I'm a 2D Bulge Ceneter point\n"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]and [b][color=BLUE]([/color][/b]= [b][color=RED]([/color][/b]logand mf 2[b][color=RED])[/color][/b] 2[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]= [b][color=RED]([/color][/b]logand vf 1[b][color=RED])[/color][/b] 1[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]prin1 vp[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]princ [color=#2f4f4f]" - I'm UCS curved fit tangent point\n"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]and [b][color=BLUE]([/color][/b]= [b][color=RED]([/color][/b]logand mf 8[b][color=RED])[/color][/b] 8[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]= [b][color=RED]([/color][/b]logand vf 1[b][color=RED])[/color][/b] 32[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]prin1 vp[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]princ [color=#2f4f4f]" - I'm a WCS Vertex point\n"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]and [b][color=BLUE]([/color][/b]= [b][color=RED]([/color][/b]logand mf 16[b][color=RED])[/color][/b] 16[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]= [b][color=RED]([/color][/b]logand vf 64[b][color=RED])[/color][/b] 64[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]prin1 vp[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]princ [color=#2f4f4f]" - I'm a WCS Mesh point\n"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]and [b][color=BLUE]([/color][/b]= [b][color=RED]([/color][/b]logand mf 64[b][color=RED])[/color][/b] 64[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]= [b][color=RED]([/color][/b]logand vf 128[b][color=RED])[/color][/b] 128[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]prin1 vp[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]princ [color=#2f4f4f]" - I'm a WCS PFACE point\n"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=NAVY])[/color][/b][color=#8b4513];cond[/color] [b][color=NAVY]([/color][/b]setq vn [b][color=MAROON]([/color][/b]entnext vn[b][color=MAROON])[/color][/b] vd [b][color=MAROON]([/color][/b]entget vn[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] There are numerous combinations of flags to test based on the entity construction. Have fun -David Quote Link to comment Share on other sites More sharing options...
samifox Posted July 23, 2014 Author Share Posted July 23, 2014 hi how would you retrive verts with mapcar? Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted July 23, 2014 Share Posted July 23, 2014 hi how would you retrive verts with mapcar? if retrieve verts coodinates, ([color="blue"]mapcar[/color] 'cdr (vl-remove-if '(lambda (x) (/= (car x) 10)) (entget(car(entsel))))) ;or ([color="blue"]mapcar[/color] 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget(car(entsel))))) *Note: but, ONLY LWPOLYLINE WITHOUT BULGE Quote Link to comment Share on other sites More sharing options...
samifox Posted July 23, 2014 Author Share Posted July 23, 2014 Is it ok to mix autolisp and vlisp at the same sentense? 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.