See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: How to convert 3D Polylines to 2D Polylines

  1. #1
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    429
    0 Did you find this post helpful? Yes

    Default How to convert 3D Polylines to 2D Polylines

    I converted an Arcview Shapefile to DXF and the resulting drawing has a bunch of 3D Polylines. I need to convert these to 2D Polylines. I was exploding and then joining them together but it is taking to much time. Is there a faster or easier way to do this? There are over 100,000 3D polylines I have to do this to.

  2. #2
    Certified AUGI Addict rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Houston
    Posts
    7,855
    0 Did you find this post helpful? Yes

    Default Re: How to convert 3D Polylines to 2D Polylines

    Quote Originally Posted by boesiii
    I converted an Arcview Shapefile to DXF and the resulting drawing has a bunch of 3D Polylines. I need to convert these to 2D Polylines. I was exploding and then joining them together but it is taking to much time. Is there a faster or easier way to do this? There are over 100,000 3D polylines I have to do this to.
    If you just want to flatten the 3D polylines to a certain elevation and you don't care if they are still technically 3D polylines, then just use the ET "flatten" command. It will leave the entities as 3D polylines, but each vertex will be set to 0.00

    If you really want to convert the 3D polyline to a 2D polyline, then ToolPac has a function to do this. The resulting entities are POLYLINE entities, but can easily be converted to LWPOLYLINE entities if desired by using the ._CONVERTPOLY command.

    If you don't have ToolPac, then you can use WMFOUT and WMFIN. After you bring the entities back with WMFIN, you can use ._PEDIT to join them all back up in one swoop....

  3. #3
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    7,405
    0 Did you find this post helpful? Yes

    Default Re: How to convert 3D Polylines to 2D Polylines

    Quote Originally Posted by rkmcswain
    If you just want to flatten the 3D polylines to a certain elevation and you don't care if they are still technically 3D polylines, then just use the ET "flatten" command. It will leave the entities as 3D polylines, but each vertex will be set to 0.00

    If you really want to convert the 3D polyline to a 2D polyline, then ToolPac has a function to do this. The resulting entities are POLYLINE entities, but can easily be converted to LWPOLYLINE entities if desired by using the ._CONVERTPOLY command.

    If you don't have ToolPac, then you can use WMFOUT and WMFIN. After you bring the entities back with WMFIN, you can use ._PEDIT to join them all back up in one swoop....
    Why not just explode the polyline; flatten the "Previous" selection set; Pedit one of the entities; then use the Join option of the Pedit command to join the Previous selection set? Why use WMFOUT / WMFIN?
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  4. #4
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,267
    0 Did you find this post helpful? Yes

    Default Re: How to convert 3D Polylines to 2D Polylines

    Try this but very quick and dirty
    Tested 1 time only on A2005
    Works too slowly, approx. 2000 polylines in 8 minutes

    Code:
    (defun C:X3P (/ *error* adoc obj_lst ss tmp_ss)
      (alert "Works slowly, converted \n
      2000 polylines in 8 minutes")
    (or (vl-load-com))
    (defun *error* (msg)
        (princ msg)
        (vla-endundomark
          (vla-get-activedocument
    	(vlax-get-acad-object)))   
        (princ)
        )
      (defun delobject (obj)
        (vl-catch-all-apply
          (function (lambda()
    		  (vla-delete obj)))))
    (or adoc
          (setq adoc (vla-get-activedocument
    		   (vlax-get-acad-object))))
      (vla-endundomark
          adoc)
      (vla-startundomark
          adoc)  
    (setvar "peditaccept" 1)
    (setvar "delobj" 1)  
    (setq ss (ssget "_X" (list (cons 0 "POLYLINE")
    			   (cons 100 "AcDb3dPolyline"))))
    (vlax-for a (vla-get-activeselectionset adoc)
      (setq obj_lst (vlax-invoke a 'Explode))
      (setq tmp_ss (ssadd))
      (foreach itm obj_lst  
        (ssadd (vlax-vla-object->ename itm) tmp_ss))
      (command "._pedit" "_m" tmp_ss ""  "_j" 0.000 "")
      (delobject a)
      (setq tmp_ss nil)
      )
      (*error* nil)
      (princ)
      )
    ~'J'~
    "The whole problem with the world is that fools and fanatics are always
    so certain of themselves, and wiser people so full of doubts."
    Bertrand Russell

  5. #5
    Certified AUGI Addict rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Houston
    Posts
    7,855
    0 Did you find this post helpful? Yes

    Smile Re: How to convert 3D Polylines to 2D Polylines

    Quote Originally Posted by Opie
    Why not just explode the polyline; flatten the "Previous" selection set; Pedit one of the entities; then use the Join option of the Pedit command to join the Previous selection set? Why use WMFOUT / WMFIN?
    You are right. No need to export/import.

    You can even save one more step. No need to ._PEDIT "one" of the entities first. You can just use ._PEDIT, window the entire selection, then use the _Join option.

    In the case of other complex entities (MLINE, SPLINE, TEXT, etc.) that you may want to "explode" or "flatten", then the WMFIN/OUT trick will work.

    Thanks for the catch!

  6. #6
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    429
    0 Did you find this post helpful? Yes

    Default Re: How to convert 3D Polylines to 2D Polylines

    The main problem is when I explode 20,000 3D polylines, Autocad converts them to over 200,000 smaller lines and then that creates a huge drawing file and takes forever to join them to polylines. I just don't want to watch and wait for it to finish, but that maybe my only option.

    I guess I will a little over each lunch break.

  7. #7
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    0 Did you find this post helpful? Yes

    Default Re: How to convert 3D Polylines to 2D Polylines

    Here is just a real simple code to change all your 3d polylines into 2d Polylines. If your prefer you can get rid of the alert. It is just there to let you know what the program is doing.

    Code:
    (defun 3dp ()
      (alert "Converting 3dPolyLines to 2DPolyLines")
      (setq ss (ssget "X" '((0 . "POLYLINE"))))
      (command "explode" ss)
      (setq ss (ssget "X" '((0 . "LINE"))))
      (command "pedit" ss "y" "j"ss"""")
    )

  8. #8
    Certified AUGI Addict rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Houston
    Posts
    7,855
    0 Did you find this post helpful? Yes

    Default Re: How to convert 3D Polylines to 2D Polylines

    Quote Originally Posted by Lions60
    Here is just a real simple code to change all your 3d polylines into 2d Polylines. If your prefer you can get rid of the alert. It is just there to let you know what the program is doing.
    Lions60, this will not work. See comments below.

    Code:
    (defun 3dp () ;Missing the "C:".
    Yes, it will still run as (3dp), but many people won't know this.
      (alert "Converting 3dPolyLines to 2DPolyLines")
      (setq ss (ssget "X" '((0 . "POLYLINE")))) ;This selects all POLYLINE entities, not just 3D.
      (command "explode" ss) ;This will not work. You would have to walk the selection set
    and explode each one.
      (setq ss (ssget "X" '((0 . "LINE"))))
      (command "pedit" ss "y" "j"ss"""") ;This will fail also, because the
    resulting LINE entities are still 3D.
    You also fail to account for the setting of PEDITACCEPT.
    Lastly, you would need the "_M" (multiple option) in there.
    )
    A better lisp solution would be to walk each 3D Polyline entity, scoop up the coordinates, erase it, then remake a 2D polyline in its place at the desired elevation.

  9. #9
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    1 Did you find this post helpful? Yes

    Default Re: How to convert 3D Polylines to 2D Polylines

    Ok, this redraws all 3d polylines as 2d polylines, but this does not join the polylines together.

    Code:
    (defun c:3DP>2DP (/ OLDVAR1 COUNT LINENO NO SS1 SS2 ENT EDATA PT1 PT2)
       (command ".undo" "Mark")
         (setq old_plinetype (getvar "PLINETYPE"))
       (setvar "PLINETYPE" 0)
       (setq OLDVAR1 (getvar "CMDECHO")) (setvar "CMDECHO" 0)
      
     (if
      (setq SS2 (ssget "X" ' ((100 . "AcDb3dPolyline"))))
       (progn
         (setq no (sslength ss2))
         (setq count 0)
        (repeat no
          (progn
           (setq ent (ssname ss2 count))
           (setq edata (entget ent))
           (command "explode" ent)
           (setq count (1+ count))
          )
        )
       )
    )
      
    (if 
       (setq SS1 (ssget "X" ' ((0 . "Line"))))   
    (progn  ; added
       (setq LINENO (sslength SS1))  
       (setq COUNT 0)
       (setq PLINFO (ssadd))         
       (repeat LINENO 
          (progn
             (setq ENT (ssname SS1 COUNT))   
             (setq EDATA (entget ENT))    
             (setq PT1 ( cdr (assoc 10 EDATA))) 
             (setq PT2 ( cdr (assoc 11 EDATA))) 
             (command "Pline" PT1 PT2 "")       
             (ssadd (entlast) PLINFO)
             (prompt (strcat "Processing line no. " (itoa COUNT) "\r")) 
             (setq COUNT (1+ COUNT))        
          )      
       )    
    ) ; added end (progn     
    ) ; added end (if
      
       (COMMAND "ERASE" SS1 "")
       (setvar "CMDECHO" OLDVAR1)
       (prompt (strcat "\n" "Erasing original lines..." "\n"))
       (setvar "PLINETYPE" old_plinetype)
       (princ) ; end program
    ); end 3dp.lsp

  10. #10
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2002-12
    Location
    Brandon, Florida
    Posts
    687
    0 Did you find this post helpful? Yes

    Default Re: How to convert 3D Polylines to 2D Polylines

    Another lisp by TT.
    http://tinyurl.com/y3639e
    Last edited by CAB2k; 2006-12-28 at 05:19 PM.

Page 1 of 2 12 LastLast

Similar Threads

  1. Convert Polylines to AEC Polygons
    By medwards.119413 in forum ACA Wish List
    Replies: 2
    Last Post: 2008-12-14, 10:48 PM
  2. Replies: 7
    Last Post: 2008-02-22, 03:13 PM
  3. Map 3D 2006 - Convert Solids to Polylines
    By nokiya2000 in forum AutoCAD Map 3D - General
    Replies: 1
    Last Post: 2007-01-11, 12:31 PM
  4. Convert Splines to Polylines
    By juliefrancoeur in forum AutoCAD General
    Replies: 7
    Last Post: 2006-04-03, 09:14 AM
  5. Replies: 9
    Last Post: 2005-06-29, 09:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •