Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Convert 2d pline with OCS into 3D Pline in WCS

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
tcorey
1753 Views, 3 Replies

Convert 2d pline with OCS into 3D Pline in WCS

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

 



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
3 REPLIES 3
Message 2 of 4
kefer_kb
in reply to: tcorey

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

www.gfm.at
Message 3 of 4
phanaem
in reply to: tcorey

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.

 

 

Message 4 of 4
tcorey
in reply to: phanaem

Thank you phanaem. It works beautifully.



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost