CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz] ARKANCE | CONTACT - CZ | SK | EN | DE
Over 1.096.000 registered users (EN+CZ). AutoCAD tips, Inventor tips, Revit tips. Try the new precise Engineering calculator and the updated Barcode generator. New AutoCAD 2026 commands and variables.
RSS channel - CAD tips RSS tips
RSS discussions

Discussion Discussion forum

?
CAD discussions, advices, exchange of experience

CAD Forum - Homepage CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.

Please abide by the rules of this forum.
This is a peer-to-peer forum. The forum doesn't replace the official direct technical support provided by ARKANCE for its customers.
How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic Closedconvert 3d polyline to polyline

 Post Reply Post Reply
Author
seashell2day View Drop Down
Newbie
Newbie


Joined: 31.Mar.2009
Status: Offline
Points: 9
Direct Link To This Post Topic: convert 3d polyline to polyline
    Posted: 03.Apr.2009 at 04:58
Cheers
Back to Top
msplcdykee69 View Drop Down
Senior Member
Senior Member


Joined: 15.Dec.2008
Location: United States
Using: Civil 3D, Map, Inventor, Mechanical, & Electrical
Status: Offline
Points: 163
Direct Link To This Post 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
Back to Top
seashell2day View Drop Down
Newbie
Newbie


Joined: 31.Mar.2009
Status: Offline
Points: 9
Direct Link To This Post 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
Back to Top

Related CAD tips:


 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0,250 seconds.