Hello all,
I have LWPOLYLINEs that represent a cross section of a train tunnel. Each LWPOLYLINE lists its 2D points in an Object Coordinate System.
My task is to create 3D Polylines in WorldCoordinateSystem using those LWPOLYLINEs.
Can anyone point me in the right direction? I have posted a drawing with sample objects.
I have attached a sample drawing. Drawing was created with Civil 3D 2013, but I exporttoautocadr12dxf'd it and then save to 2004 dwg so most should be able to open it.
Thanks in advance,
Tim
Solved! Go to Solution.
Solved by kefer_kb. Go to Solution.
Hello Tim,
there is a suitable Lisp command for translating a point (or a displacement) from one coordinate system to another: TRANS
Please take a look into Autolisp Reference Guide. It will be explained well.
kind regards,
Franz
Try this..
It is working on your sample dwg.
(defun C:TEST (/ ss i e en h lst poly) (if (setq ss (ssget '((0 . "LWPOLYLINE")))) (repeat (setq i (sslength ss)) (setq en (entget (setq e (ssname ss (setq i (1- i))))) h (cdr (assoc 38 en)) lst (mapcar (function (lambda (x) (trans (list (cadr x) (caddr x) h) e 0) ) ) (vl-remove-if '(lambda (x) (/= (car x) 10)) en) ) poly (vla-Add3DPoly (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object) ) ) (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbDouble (cons 0 (1- (* 3 (length lst)))) ) (apply 'append lst) ) ) ) ) (vla-put-layer poly (cdr (assoc 8 en))) (entdel e) ) ) (princ) )
You may want to add more code lines to match color and linetype.
Thank you phanaem. It works beautifully.