thomasdonny86 Posted June 14, 2010 Posted June 14, 2010 Hi everyone!!!! I am reallly in need of knowing how to convert splines to lines??? Quote
rvpas Posted June 14, 2010 Posted June 14, 2010 Hi Thomas, If you just need to convert spline to line in keeping approxymatively curve saving a copy as a R12 dxf, all the splines will be convert to pline. open this drawing and explode the pline Bye Pascal Quote
rvpas Posted June 14, 2010 Posted June 14, 2010 Yes, after you save your drawing in dxf 12 format Menu file/save as/ Choose in file of type AUTOCAD R12 DXF only. see image Quote
eldon Posted June 14, 2010 Posted June 14, 2010 Have you looked at the bottom of the page at 'Similar Threads'. Flatten seems to be a bit quicker and simpler. Quote
Lee Mac Posted June 14, 2010 Posted June 14, 2010 An old one of mine - will convert anything to an LWPolyline... [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:Segs [b][color=RED]([/color][/b] [b][color=BLUE]/[/color][/b] *error* doc ss undo [b][color=RED])[/color][/b] [i][color=#990099]; Lee Mac ~ 29.01.10[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] *error* [b][color=RED]([/color][/b] msg [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] undo [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndomark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]wcmatch[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcase[/color][/b] msg[b][color=RED])[/color][/b] [b][color=#a52a2a]"*BREAK,*CANCEL*,*EXIT*"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"\n** Error: "[/color][/b] msg [b][color=#a52a2a]" **"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] *segs [b][color=RED]([/color][/b][b][color=BLUE]cond[/color][/b] [b][color=RED]([/color][/b]*segs[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=#009900]10[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]ssget[/color][/b] [b][color=#a52a2a]"_:L"[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#a52a2a]"ARC,CIRCLE,*POLYLINE,SPLINE,LINE,ELLIPSE"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]initget[/color][/b] [b][color=#009900]6[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] *segs [b][color=RED]([/color][/b][b][color=BLUE]cond[/color][/b] [b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=BLUE]getint[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"\nSpecify Number of Segments <"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]itoa[/color][/b] *segs[b][color=RED])[/color][/b] [b][color=#a52a2a]"> : "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]*segs[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b] j [b][color=BLUE]/[/color][/b] ent inc i pts [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] undo [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-StartUndoMark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ent [b][color=RED]([/color][/b][b][color=BLUE]ssname[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] j [b][color=RED]([/color][/b][b][color=BLUE]1+[/color][/b] j[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] inc [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getDistatParam[/color][/b] ent [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getEndParam[/color][/b] ent[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]float[/color][/b] *segs[b][color=RED])[/color][/b][b][color=RED])[/color][/b] i [b][color=#009900]-1[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]repeat[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]1+[/color][/b] *segs[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pts [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getPointatDist[/color][/b] ent [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] i [b][color=RED]([/color][/b][b][color=BLUE]1+[/color][/b] i[b][color=RED])[/color][/b][b][color=RED])[/color][/b] inc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] pts[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entmake[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]append[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]0[/color][/b] [b][color=#a52a2a]"LWPOLYLINE"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]100[/color][/b] [b][color=#a52a2a]"AcDbEntity"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]100[/color][/b] [b][color=#a52a2a]"AcDbPolyline"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]90[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]length[/color][/b] pts[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]70[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-remove[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]nil[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b] d [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] d [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] ent[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]6[/color][/b] [b][color=#009900]8[/color][/b] [b][color=#009900]39[/color][/b] [b][color=#009900]48 62[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]function[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b] a [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]10[/color][/b] a[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] pts[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entdel[/color][/b] ent[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pts [b][color=BLUE]nil[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] undo [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndoMark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=#009900]-1[/color][/b] [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] Quote
Skybeorn Posted June 21, 2010 Posted June 21, 2010 Lee Thanks for your contribution this is a nice utility to use. Very Helpful LISP. Quote
Lee Mac Posted June 21, 2010 Posted June 21, 2010 You're very welcome Slightly edited to account for Colour not ByLayer Quote
Cad64 Posted June 21, 2010 Posted June 21, 2010 Hi Lee, I need to convert a bunch of 3D Polyline contours to LWPolylines, and I remembered that you had posted this routine, so I decided to try it out. The problem is, when it converts the polylines, it changes the shape of the contour. Is there any way to force it to keep the original shape? As you can see below, the shape of the contour is altered after I run the routine. BTW, both contours have the same number of segments, (23), but the routine distributes the segments evenly, instead of leaving them in place at their original length and position. Quote
Lee Mac Posted June 21, 2010 Posted June 21, 2010 Hi Rod, Yes, this was a quick routine I wrote, - it will merely divide the curve up into the number of segments specified and get the point at each division, then use this to create the new curve. Quote
Lee Mac Posted June 21, 2010 Posted June 21, 2010 This may be more appropriate, another routine I wrote recently - more experimental and probably needs a bit of a rewrite... Should convert 3D Poly's to LW Poly's: [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] LM:3D->LW [b][color=RED]([/color][/b] [color=Black]3[/color]dpl [b][color=BLUE]/[/color][/b] Verts [b][color=RED])[/color][/b] [i][color=#990099];; © Lee Mac ~ 04.06.10[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] Verts [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b] x [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]=[/color][/b] [b][color=#009900]10[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] x[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=#009900]10[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] x[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]caddr[/color][/b] x[b][color=RED])[/color][/b][b][color=RED])[/color][/b] x[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]apply[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]append[/color][/b] [b][color=RED]([/color][/b]LM:Get3DPolyData [color=Black]3[/color]dpl[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entmake[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]append[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b] [b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#a52a2a]"LWPOLYLINE"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=#009900]100[/color][/b] . [b][color=#a52a2a]"AcDbEntity"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=#009900]100[/color][/b] . [b][color=#a52a2a]"AcDbPolyline"[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]90[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]length[/color][/b] Verts[b][color=RED])[/color][/b] [b][color=#009900]4[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]70[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]logand[/color][/b] [b][color=#009900]129[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]70[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] [color=Black]3[/color]dpl[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b]LM:RemovePairs [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] [b][color=#009900]10[/color][/b] [b][color=#009900]40[/color][/b] [b][color=#009900]41[/color][/b] [b][color=#009900]66[/color][/b] [b][color=#009900]70[/color][/b] [b][color=#009900]71[/color][/b] [b][color=#009900]72[/color][/b] [b][color=#009900]73[/color][/b] [b][color=#009900]74[/color][/b] [b][color=#009900]75[/color][/b] [b][color=#009900]100[/color][/b] [b][color=#009900]102[/color][/b] [b][color=#009900]360[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] [color=Black]3[/color]dpl[b][color=RED])[/color][/b][b][color=RED])[/color][/b] Verts [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entdel[/color][/b] [color=Black]3[/color]dpl[b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] LM:Get3DPolyData [b][color=RED]([/color][/b] e [b][color=BLUE]/[/color][/b] p el [b][color=RED])[/color][/b] [i][color=#990099];; © Lee Mac ~ 04.06.10[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] e [b][color=RED]([/color][/b][b][color=BLUE]entnext[/color][/b] e[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] p [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]10[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] el [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] e[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]=[/color][/b] [b][color=#009900]16[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]logand[/color][/b] [b][color=#009900]16[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]70[/color][/b] el[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]LM:Get3DPolyData e[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]reverse[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]member[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]42[/color][/b] el[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]reverse[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]member[/color][/b] p el[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]LM:Get3DPolyData e[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] LM:RemovePairs [b][color=RED]([/color][/b] pairs lst [b][color=RED])[/color][/b] [i][color=#990099];; © Lee Mac ~ 04.06.10[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]vl-remove-if[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b] pair [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-position[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] pair[b][color=RED])[/color][/b] pairs[b][color=RED])[/color][/b][b][color=RED])[/color][/b] lst [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [i][color=#990099];; Test Function[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:test [b][color=RED]([/color][/b] [b][color=BLUE]/[/color][/b] ss e [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]ssget[/color][/b] [b][color=#a52a2a]"_:L"[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#a52a2a]"POLYLINE"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b] i [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] e [b][color=RED]([/color][/b][b][color=BLUE]ssname[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] i [b][color=RED]([/color][/b][b][color=BLUE]1+[/color][/b] i[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]LM:3D->LW e[b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=#009900]-1[/color][/b] [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] Quote
Lee Mac Posted June 21, 2010 Posted June 21, 2010 Updated the above... it should also work on 3D Spline Polys Quote
Cad64 Posted June 22, 2010 Posted June 22, 2010 Ok, I'm feeling a bit dumb here, but I can't get it to run? I've saved it as test.lsp, loaded it and typed test at the command prompt, but I just get "Unknown Command". What am I missing? Quote
The Buzzard Posted June 22, 2010 Posted June 22, 2010 Ok, I'm feeling a bit dumb here, but I can't get it to run?I've saved it as test.lsp, loaded it and typed test at the command prompt, but I just get "Unknown Command". What am I missing? I just tried the code on two different versions and it works great. I am sure if you did not copy it completely you would have a different error message. Keep trying. Quote
Cad64 Posted June 22, 2010 Posted June 22, 2010 Wow! I think I've been sitting in front of this computer for too long today. I copied and pasted the code into Notepad but I guess I forgot to Save. What a rookie mistake. It works fine now. Thanks Lee, for the code. And thanks Buzzard for helping me get my head screwed on straight. Quote
santhorathi Posted August 14, 2010 Posted August 14, 2010 Dear All I have clearly explained in the image attached to this post. kindly go through it, And help me to fix this problem. Thanks & Regards Radish.G Quote
JoshKing Posted August 7, 2013 Posted August 7, 2013 An old one of mine - will convert anything to an LWPolyline... [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:Segs [b][color=RED]([/color][/b] [b][color=BLUE]/[/color][/b] *error* doc ss undo [b][color=RED])[/color][/b] [i][color=#990099]; Lee Mac ~ 29.01.10[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] *error* [b][color=RED]([/color][/b] msg [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] undo [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndomark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]wcmatch[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcase[/color][/b] msg[b][color=RED])[/color][/b] [b][color=#a52a2a]"*BREAK,*CANCEL*,*EXIT*"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"\n** Error: "[/color][/b] msg [b][color=#a52a2a]" **"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] *segs [b][color=RED]([/color][/b][b][color=BLUE]cond[/color][/b] [b][color=RED]([/color][/b]*segs[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=#009900]10[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]ssget[/color][/b] [b][color=#a52a2a]"_:L"[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#a52a2a]"ARC,CIRCLE,*POLYLINE,SPLINE,LINE,ELLIPSE"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]initget[/color][/b] [b][color=#009900]6[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] *segs [b][color=RED]([/color][/b][b][color=BLUE]cond[/color][/b] [b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=BLUE]getint[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"\nSpecify Number of Segments <"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]itoa[/color][/b] *segs[b][color=RED])[/color][/b] [b][color=#a52a2a]"> : "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]*segs[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b] j [b][color=BLUE]/[/color][/b] ent inc i pts [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] undo [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-StartUndoMark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ent [b][color=RED]([/color][/b][b][color=BLUE]ssname[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] j [b][color=RED]([/color][/b][b][color=BLUE]1+[/color][/b] j[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] inc [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getDistatParam[/color][/b] ent [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getEndParam[/color][/b] ent[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]float[/color][/b] *segs[b][color=RED])[/color][/b][b][color=RED])[/color][/b] i [b][color=#009900]-1[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]repeat[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]1+[/color][/b] *segs[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pts [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getPointatDist[/color][/b] ent [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] i [b][color=RED]([/color][/b][b][color=BLUE]1+[/color][/b] i[b][color=RED])[/color][/b][b][color=RED])[/color][/b] inc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] pts[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entmake[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]append[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]0[/color][/b] [b][color=#a52a2a]"LWPOLYLINE"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]100[/color][/b] [b][color=#a52a2a]"AcDbEntity"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]100[/color][/b] [b][color=#a52a2a]"AcDbPolyline"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]90[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]length[/color][/b] pts[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]70[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-remove[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]nil[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b] d [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] d [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] ent[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]6[/color][/b] [b][color=#009900]8[/color][/b] [b][color=#009900]39[/color][/b] [b][color=#009900]48 62[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]function[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b] a [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]10[/color][/b] a[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] pts[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entdel[/color][/b] ent[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pts [b][color=BLUE]nil[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] undo [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndoMark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=#009900]-1[/color][/b] [b][color=RED])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b] [b][color=RED])[/color][/b] This is exactly what I am looking for, but trying to do so in VBA. Does anyone know how to code this? Thanks, Josh Quote
Edwin Mendoza Posted July 9, 2014 Posted July 9, 2014 Hi Lee, you're an an ACE mate! Thanks a lot. It just did the magic for me today. An old one of mine - will convert anything to an LWPolyline... [b][color=red]([/color][/b][b][color=blue]defun[/color][/b] c:Segs [b][color=red]([/color][/b] [b][color=blue]/[/color][/b] *error* doc ss undo [b][color=red])[/color][/b] [i][color=#990099]; Lee Mac ~ 29.01.10[/color][/i] [b][color=red]([/color][/b][b][color=blue]vl-load-com[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]defun[/color][/b] *error* [b][color=red]([/color][/b] msg [b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]and[/color][/b] undo [b][color=red]([/color][/b][b][color=blue]vla-EndUndomark[/color][/b] doc[b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]or[/color][/b] [b][color=red]([/color][/b][b][color=blue]wcmatch[/color][/b] [b][color=red]([/color][/b][b][color=blue]strcase[/color][/b] msg[b][color=red])[/color][/b] [b][color=#a52a2a]"*BREAK,*CANCEL*,*EXIT*"[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]princ[/color][/b] [b][color=red]([/color][/b][b][color=blue]strcat[/color][/b] [b][color=#a52a2a]"\n** Error: "[/color][/b] msg [b][color=#a52a2a]" **"[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]princ[/color][/b][b][color=red])[/color][/b] [b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] doc [b][color=red]([/color][/b][b][color=blue]vla-get-ActiveDocument[/color][/b] [b][color=red]([/color][/b][b][color=blue]vlax-get-acad-object[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] *segs [b][color=red]([/color][/b][b][color=blue]cond[/color][/b] [b][color=red]([/color][/b]*segs[b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=#009900]10[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]if[/color][/b] [b][color=red]([/color][/b][b][color=blue]and[/color][/b] [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] ss [b][color=red]([/color][/b][b][color=blue]ssget[/color][/b] [b][color=#a52a2a]"_:L"[/color][/b] [b][color=darkred]'[/color][/b][b][color=red]([/color][/b][b][color=red]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#a52a2a]"ARC,CIRCLE,*POLYLINE,SPLINE,LINE,ELLIPSE"[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]not[/color][/b] [b][color=red]([/color][/b][b][color=blue]initget[/color][/b] [b][color=#009900]6[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] *segs [b][color=red]([/color][/b][b][color=blue]cond[/color][/b] [b][color=red]([/color][/b][b][color=red]([/color][/b][b][color=blue]getint[/color][/b] [b][color=red]([/color][/b][b][color=blue]strcat[/color][/b] [b][color=#a52a2a]"\nSpecify Number of Segments <"[/color][/b] [b][color=red]([/color][/b][b][color=blue]itoa[/color][/b] *segs[b][color=red])[/color][/b] [b][color=#a52a2a]"> : "[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b]*segs[b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b] [b][color=red]([/color][/b][b][color=blue]lambda[/color][/b] [b][color=red]([/color][/b] j [b][color=blue]/[/color][/b] ent inc i pts [b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] undo [b][color=red]([/color][/b][b][color=blue]not[/color][/b] [b][color=red]([/color][/b][b][color=blue]vla-StartUndoMark[/color][/b] doc[b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]while[/color][/b] [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] ent [b][color=red]([/color][/b][b][color=blue]ssname[/color][/b] ss [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] j [b][color=red]([/color][/b][b][color=blue]1+[/color][/b] j[b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] inc [b][color=red]([/color][/b][b][color=blue]/[/color][/b] [b][color=red]([/color][/b][b][color=blue]vlax-curve-getDistatParam[/color][/b] ent [b][color=red]([/color][/b][b][color=blue]vlax-curve-getEndParam[/color][/b] ent[b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]float[/color][/b] *segs[b][color=red])[/color][/b][b][color=red])[/color][/b] i [b][color=#009900]-1[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]repeat[/color][/b] [b][color=red]([/color][/b][b][color=blue]1+[/color][/b] *segs[b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] pts [b][color=red]([/color][/b][b][color=blue]cons[/color][/b] [b][color=red]([/color][/b][b][color=blue]vlax-curve-getPointatDist[/color][/b] ent [b][color=red]([/color][/b][b][color=blue]*[/color][/b] [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] i [b][color=red]([/color][/b][b][color=blue]1+[/color][/b] i[b][color=red])[/color][/b][b][color=red])[/color][/b] inc[b][color=red])[/color][/b][b][color=red])[/color][/b] pts[b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]entmake[/color][/b] [b][color=red]([/color][/b][b][color=blue]append[/color][/b] [b][color=red]([/color][/b][b][color=blue]list[/color][/b] [b][color=red]([/color][/b][b][color=blue]cons[/color][/b] [b][color=#009900]0[/color][/b] [b][color=#a52a2a]"LWPOLYLINE"[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]cons[/color][/b] [b][color=#009900]100[/color][/b] [b][color=#a52a2a]"AcDbEntity"[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]cons[/color][/b] [b][color=#009900]100[/color][/b] [b][color=#a52a2a]"AcDbPolyline"[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]cons[/color][/b] [b][color=#009900]90[/color][/b] [b][color=red]([/color][/b][b][color=blue]length[/color][/b] pts[b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]cons[/color][/b] [b][color=#009900]70[/color][/b] [b][color=#009900]0[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]vl-remove[/color][/b] [b][color=darkred]'[/color][/b][b][color=blue]nil[/color][/b] [b][color=red]([/color][/b][b][color=blue]mapcar[/color][/b] [b][color=darkred]'[/color][/b][b][color=red]([/color][/b][b][color=blue]lambda[/color][/b] [b][color=red]([/color][/b] d [b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]assoc[/color][/b] d [b][color=red]([/color][/b][b][color=blue]entget[/color][/b] ent[b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=darkred]'[/color][/b][b][color=red]([/color][/b][b][color=#009900]6[/color][/b] [b][color=#009900]8[/color][/b] [b][color=#009900]39[/color][/b] [b][color=#009900]48 62[/color][/b][b][color=red])[/color][/b] [b][color=red])[/color][/b] [b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]mapcar[/color][/b] [b][color=red]([/color][/b][b][color=blue]function[/color][/b] [b][color=red]([/color][/b][b][color=blue]lambda[/color][/b] [b][color=red]([/color][/b] a [b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]cons[/color][/b] [b][color=#009900]10[/color][/b] a[b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] pts[b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]entdel[/color][/b] ent[b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] pts [b][color=blue]nil[/color][/b][b][color=red])[/color][/b] [b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] undo [b][color=red]([/color][/b][b][color=blue]vla-EndUndoMark[/color][/b] doc[b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red])[/color][/b] [b][color=#009900]-1[/color][/b] [b][color=red])[/color][/b] [b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]princ[/color][/b][b][color=red])[/color][/b] [b][color=red])[/color][/b] 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.