Print Page | Close Window

convert 3d polyline to polyline

Printed From: CAD Forum
Category: EN
Forum Name: AutoCAD
Forum Description: Discussion about AutoCAD and AutoCAD LT, viewers, DWG and DXF formats, Design Review, AutoCAD web, Drive, add-ons
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=1875
Printed Date: 03.Sep.2026 at 12:04


Topic: convert 3d polyline to polyline
Posted By: seashell2day
Subject: convert 3d polyline to polyline
Date Posted: 03.Apr.2009 at 01:23
I have a 3Dpolyline & want to convert it to a normal polyline without exploding & getting a million lines. Can anyone help?

-------------
Cheers



Replies:
Posted By: msplcdykee69
Date Posted: 03.Apr.2009 at 04:08
if you have Civil 3D autoCAD you can go to Surface>Utilities>Convert 3D poly to 2D poly.  If you do not.. Here is a lisp program you can use to convert it.  Also if your 3D poly has "Z" elevations you need to get rid of I have a lisp to Flatten the "Z" value to 0. It is below as well
 
Convert 3D to 2D Poly
 
;;CADALYST 09/03 AutoLISP Solutions
;;; PLINE-3D-2D.LSP - a program to convert
;;; 3D polylines to 2D
;;; Program by Tony Hotchkiss
(defun pline-3d-2d ()
  (vl-load-com)
  (setq *thisdrawing* (vla-get-activedocument
   (vlax-get-acad-object)
        ) ;_ end of vla-get-activedocument
 *modelspace*  (vla-get-ModelSpace *thisdrawing*)
  ) ;_ end of setq
  (setq 3d-pl-list
  (get-3D-pline)
  ) ;_ end of setq
  (if 3d-pl-list
    (progn
      (setq vert-array-list (make-list 3d-pl-list))
      (setq n (- 1))
      (repeat (length vert-array-list)
 (setq vert-array (nth (setq n (1+ n)) vert-array-list))
 (setq lyr (vlax-get-property (nth n 3d-pl-list) 'Layer))
 (setq obj (vla-AddPolyline *modelspace* vert-array))
 (vlax-put-property obj 'Layer lyr)
      ) ;_ end of repeat
      (foreach obj 3d-pl-list (vla-delete obj))
    ) ;_ end of progn
  ) ;_ end of if
) ;_ end of pline-3d-2d
(defun get-3D-pline ()
  (setq pl3dobj-list nil
 obj      nil
 3d      "AcDb3dPolyline"
  ) ;_ end of setq
  (setq selsets (vla-get-selectionsets *thisdrawing*))
  (setq ss1 (vlax-make-variant "ss1"))
  (if (= (vla-get-count selsets) 0)
    (setq ssobj (vla-add selsets ss1))
  ) ;_ end of if
  (vla-clear ssobj)
  (setq Filterdata (vlax-make-variant "POLYLINE"))
  (setq no-ent 1)
  (while no-ent
    (vla-Selectonscreen ssobj)
    (if (> (vla-get-count ssobj) 0)
      (progn
 (setq no-ent nil)
 (setq i (- 1))
 (repeat (vla-get-count ssobj)
   (setq
     obj (vla-item ssobj
     (vlax-make-variant (setq i (1+ i)))
  ) ;_ end of vla-item
   ) ;_ end of setq
   (cond
     ((= (vlax-get-property obj "ObjectName") 3d)
      (setq pl3dobj-list
      (append pl3dobj-list (list obj))
      ) ;_ end of setq
     )
   ) ;_ end-of cond
 ) ;_ end of repeat
      ) ;_ end of progn
      (prompt "\nNo entities selected, try again.")
    ) ;_ end of if
    (if (and (= nil no-ent) (= nil pl3dobj-list))
      (progn
 (setq no-ent 1)
 (prompt "\nNo 3D-polylines selected.")
 (quit)
      ) ;_ end of progn
    ) ;_ end of if
  ) ;_ end of while 
  (vla-delete (vla-item selsets 0))
  pl3dobj-list
) ;_ end of get-3D-pline

(defun get-3D-pline-old ()
  (setq no-ent 1)
  (setq filter '((-4 . "<AND")
   (0 . "POLYLINE")
   (70 . 8)
   (-4 . "AND>")
  )
  ) ;_ end of setq
  (while no-ent
    (setq ss        (ssget filter)
   k        (- 1)
   pl3dobj-list nil
   obj        nil
   3d        "AcDb3dPolyline"
    ) ;_ end-of setq
    (if ss
      (progn
 (setq no-ent nil)
 (repeat (sslength ss)
   (setq ent (ssname ss (setq k (1+ k)))
  obj (vlax-ename->vla-object ent)
   ) ;_ end-of setq
   (cond
     ((= (vlax-get-property obj "ObjectName") 3d)
      (setq pl3dobj-list
      (append pl3dobj-list (list obj))
      ) ;_ end of setq
     )
   ) ;_ end-of cond
 ) ;_ end-of repeat
      ) ;_ end-of progn
      (prompt "\nNo 3D-polylines selected, try again.")
    ) ;_ end-of if
  ) ;_ end-of while
  pl3dobj-list
) ;_ end of get-3D-pline-old
(defun make-list (p-list)
  (setq i (- 1)
 vlist nil
 calist nil
  ) ;_ end of setq
  (repeat (length p-list)
    (setq obj  (nth (setq i (1+ i)) p-list)
   coords (vlax-get-property obj "coordinates")
   ca  (vlax-variant-value coords)
    ) ;_ end-of setq
    (setq calist (append calist (list ca)))
  ) ;_ end-of repeat
) ;_ end-of make-list
(defun c:pl32 ()
  (pline-3d-2d)
  (princ)
) ;_ end of pl32
(prompt "Enter PL32 to start: ")
 
Flatten "Z" Coordinates
 
;;
;;  Flatten.lsp - Converts 3d geometry to 2d geometry.
;;
;;  Copyright © 1999 by Autodesk, Inc.
;;
;;  Your use of this software is governed by the terms and conditions
;;  of the License Agreement you accepted prior to installation of this
;;  software.  Please note that pursuant to the License Agreement for this
;;  software, "[c]opying of this computer program or its documentation
;;  except as permitted by this License is copyright infringement under
;;  the laws of your country.  If you copy this computer program without
;;  permission of Autodesk, you are violating the law."
;;
;;  AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
;;  AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
;;  MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
;;  DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
;;  UNINTERRUPTED OR ERROR FREE.
;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:flatten ( / ss ans )
 (acet-error-init (list nil 1))
 
 (princ "\nSelect objects to convert to 2d...")
 (if (not acet:flatn-hide)
     (setq acet:flatn-hide "No")
 );if
 
 (if (and (setq ss (ssget "_:l" '((-4 . "<NOT") (0 . "VIEWPORT") (-4 . "NOT>"))));setq
          (setq ss (car (acet-ss-filter (list ss nil T))))
     );and
     (progn
      (initget "Yes No")
      (setq ans (getkword
                 (acet-str-format "\nRemove hidden lines? <%1>: "
                                  acet:flatn-hide
                 )
                );getkword
      );setq
      (if (not ans)
          (setq ans acet:flatn-hide)
          (setq acet:flatn-hide ans)
      );if
      (if (equal ans "No")
          (acet-flatn ss nil)
          (acet-flatn ss T)
      );if
     );progn then
 );if
 (acet-error-restore)
);defun c:flatten

(acet-autoload2 '("FLATTENSUP.LSP" (acet-flatn ss hide)))
(princ)
 
I hope these Help.....


-------------
Engineering Manufacturing Medical Cables/Adjunct Instructor Engineering Graphics/Engineering Computations and Careers

msplcdykee69@yahoo.com

Shawn


Posted By: seashell2day
Date Posted: 03.Apr.2009 at 04:58
http://cadtips.cadalyst.com -
Thanks, i got it from
 
http://cadtips.cadalyst.com


-------------
Cheers



Print Page | Close Window