MS13 Posted April 13, 2019 Posted April 13, 2019 Hi all I am using this routine to change 3dpoli to spline. Quote (defun C:Pline2Spline ;| credits to: Lee Mac |; ( / Get3DpolyVertices AddSpline e pLst spl ) (defun Get3DpolyVertices ( e / pLst ) (if (and (eq 'ENAME (type e)) (= "POLYLINE" (cdr (assoc 0 (entget e))))) (reverse (while (and (setq e (entnext e)) (/= "SEQEND" (cdr (assoc 0 (entget e))))) (setq pLst (cons (cdr (assoc 10 (entget e))) pLst)) ) ) ) ); defun Get3DpolyVertices (defun AddSpline ( 3DPtLst / Spline ) (if (and (vl-consp 3DPtLst) (vl-every (function (lambda (x) (and (vl-consp x) (= 3 (length x)) (apply 'and (mapcar 'numberp x))))) 3DPtLst) ); and (setq Spline (vla-AddSpline (vlax-get (vla-get-ActiveDocument (vlax-get-acad-object)) (if (equal (getvar "CVPORT") 1) 'PaperSpace 'ModelSpace) ) (vlax-safearray-fill (vlax-make-safearray vlax-vbDouble (cons 0 (1- (length (apply 'append 3DPtLst))))) (apply 'append 3DPtLst) ) (vlax-3d-point '(0. 0. 0.)) (vlax-3d-point '(0. 0. 0.)) ) ); setq Spline ); if ); defun AddSpline (setvar 'errno 0) (while (/= 52 (getvar 'errno)) (setq e (car (entsel "\nPick a pline <exit>: "))) (cond ((= 7 (getvar 'errno)) (princ "\nMissed, try again.") (setvar 'errno 0)) (e (cond ((wcmatch (cdr (assoc 0 (entget e))) "~*POLYLINE") (princ "\nInvalid object.")) ((= "POLYLINE" (cdr (assoc 0 (entget e)))) (and (setq spl (AddSpline (Get3DpolyVertices e))) (vla-put-Closed2 spl (vla-get-Closed (vlax-ename->vla-object e))) (setvar 'errno 52) ); and ) ((= "LWPOLYLINE" (cdr (assoc 0 (entget e)))) (and (setq pLst (mapcar 'cdr (vl-remove-if-not (function (lambda (x) (= 10 (car x)))) (entget e)))) (if (= 2 (length (car pLst))) ; convert to 3D point list (setq pLst (mapcar (function (lambda (x) (append x (list (cdr (assoc 38 (entget e))))))) pLst)) ; assoc 38, elevation pLst ) (setq spl (AddSpline pLst)) (vla-put-Closed2 spl (vla-get-Closed (vlax-ename->vla-object e))) (setvar 'errno 52) ); and ) ); cond ); e ); cond ); while );| defun Spline2Pline |; (vl-load-com) (princ) Is there way to amend it with few more elements: 1)Spline is drawn on the same layer as source 3d poly has 2) Spline is something what I do not need. I need this spline to be turn into another 3dpoly with precision<10> 3) Source 3dpoly is being deleted I know it can be done manually and I am doing like this, but this take long long time Thanks Quote
dlanorh Posted April 13, 2019 Posted April 13, 2019 Post a drawing (Autocad 2010) with a short 3DPolyline showing before and after, since I don't fully understand your requirement. It sounds like you want to convert a 3DPolyline rather than replace one polyline with another. Quote
eldon Posted April 13, 2019 Posted April 13, 2019 Perhaps PEDIT will do what you want with the original 3Dpolyline. Quote
MS13 Posted April 13, 2019 Author Posted April 13, 2019 File attached as requested Drawing2.dwg Quote
dlanorh Posted April 13, 2019 Posted April 13, 2019 OK, question, are they always 3DPolylines and always on layer "BANK" or is the lisp used for other polylines? Quote
dlanorh Posted April 13, 2019 Posted April 13, 2019 (edited) OK. Try the attached. I've added a local error routine, and substituted a selection set for the entsel, so you should be able to process multiple polylines with a single selection. As per the original, the spline is fitted to the polyline vertices. It now deletes the original polyline puts the spline onto the original polylines layer and converts the spline back into a polyline. I've minimally tested in the drawing you supplied. Pline2plinespline.lsp Edited April 13, 2019 by dlanorh Quote
MS13 Posted April 13, 2019 Author Posted April 13, 2019 Thanks Works almost perfect - spline is drawn on active layer not at the same layer as 3dpoly has Quote
dlanorh Posted April 13, 2019 Posted April 13, 2019 6 minutes ago, MS13 said: Thanks Works almost perfect - spline is drawn on active layer not at the same layer as 3dpoly has Ah! A missing line of code in the LWPolyline condition. Try the updated attached lisp Pline2plinespline.lsp Quote
MS13 Posted April 13, 2019 Author Posted April 13, 2019 Works perfect - thanks I can always count on you guys 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.