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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    450
    Login to Give a bone
    0

    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
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    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....
    R.K. McSwain | CAD Panacea |

  3. #3
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

    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,269
    Login to Give a bone
    0

    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'~

  5. #5
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    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!
    R.K. McSwain | CAD Panacea |

  6. #6
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    450
    Login to Give a bone
    0

    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
    Login to Give a bone
    0

    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
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    466
    Login to Give a bone
    0

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

    I suggest using the Flatten lisp program, then the pljoin lisp program.

  9. #9
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    466
    Login to Give a bone
    0

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

    Here's one I wrote a long time ago.

    Code:
    (DEFUN C:GPJ (/ PT1 PT2 SSET SSETN PLN LP ENT LA PLN2 TFC CV ENTL EVS SV EVT VE1 VE2 SI1 SI2 SII1 SII2 SI SII PF FB FE FLTR)
      (PROMPT "*GROUP POLYLINE JOIN*")
      (SETQ SSET (SSGET '((0 . "LWPOLYLINE"))))
      (SETQ SSETN (SSLENGTH SSET))
      (SETQ PLN SSETN)
      (PRINT SSETN)
      (PROMPT " POLYLINES SELECTED")
      (SETQ SSETN (- SSETN 1))
      (SETQ LOOP 1)
      (WHILE LOOP
        (SETQ ENT (SSNAME SSET SSETN))
        (SETQ LA (ASSOC 8 (ENTGET ENT)))
        (SETQ ENTL (ENTGET ENT))
        (SETQ VE1 (CDR (ASSOC 10 ENTL)))
        (SETQ EVS VE1)
        (SETQ SV 1)
        (WHILE SV
          (SETQ ENTL (CDR ENTL))
          (SETQ EVT (ASSOC 10 ENTL))
          (IF (/= EVT NIL)
    	(SETQ VE2 (CDR EVT))
    	(SETQ SV NIL)
          )
        ) ;END WHILE SV 
        (SETQ SI1 (MAPCAR '+ '(0.1 0.1 0.0) VE1))
        (SETQ SI2 (MAPCAR '+ '(-0.1 -0.1 0.0) VE1))
        (SETQ SII1 (MAPCAR '+ '(0.1 0.1 0.0) VE2))
        (SETQ SII2 (MAPCAR '+ '(-0.1 -0.1 0.0) VE2))
        (SETQ PF '(0 . "LWPOLYLINE"))
        (SETQ FB '(-4 . "<AND"))
        (SETQ FE '(-4 . "AND>"))
        (SETQ FLTR (LIST FB PF LA FE))
        (SETQ SI (SSGET "C" SI1 SI2 FLTR))
        (SETQ SII (SSGET "C" SII1 SII2 FLTR))
        (IF	(= SI NIL)
          (SETQ SI ENT)
        )
        (IF	(= SII NIL)
          (SETQ SII ENT)
        )
        (SETQ CV (CDR (ASSOC 70 (ENTGET ENT))))
        (IF	(> CV 0)
          (SETQ TFC 1)
          (SETQ TFC 0)
        )
        (IF	(= TFC 0)
          (COMMAND "PEDIT" ENT "J" SI SII "" "X")
        )
        (SETQ LP 1)
        (WHILE LP
          (SETQ SSETN (- SSETN 1))
          (PROMPT "\nJOIN ATEMPT # ")
          (PRINC SSETN)
          (IF (/= (SSNAME SSET SSETN) NIL)
    	(SETQ NT (ENTGET (SSNAME SSET SSETN)))
    	(SETQ NT 1)
          )
          (IF (= NT NIL)
    	(SETQ LP 1)
    	(SETQ LP NIL)
          )
          (IF (< SSETN 0)
    	(SETQ LOOP NIL)
          )
        ) ;END WHILE LP
      ) ;END WHILE LOOP
      (SETQ SSET NIL)
      (SETQ SSET NIL)
      (PRINC)
    ) ;END JPL
    [ Moderator Action = ON ] What are [ CODE ] tags... [ Moderator Action = OFF ]
    Last edited by Mike.Perry; 2007-01-02 at 06:45 AM. Reason: [CODE] tags added.

  10. #10
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    450
    Login to Give a bone
    0

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

    I tried the programs by Peter and CAB and both work very well but Peter's is about twice as fast, I guess its because of Active X commands.

    Thanks to all who helped, you saved me a ton of time!

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, 11:48 PM
  2. Replies: 7
    Last Post: 2008-02-22, 04: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, 01:31 PM
  4. Convert Splines to Polylines
    By juliefrancoeur109665 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
  •