See the top rated post in this thread. Click here

Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

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

  1. #11
    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 first tried Lion's but it seamed like autocad locked up on me, then I tried Cab's suggestion and it worked perfectly.

    Thanks, you saved me a bunch of time!!!

  2. #12
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

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

    Here is a 3dto2d function using activeX

    After flattening the 3dpoly's you could try using the express tools "overkill" to join them together.

    You can also use a pjoin.lsp routine to join them.

    Code:
    
    (defun C:3DTo2D (/ intCount
                       lstCoordiantes
                       objDocument
                       obj2dPolyline
                       obj3dPolyline
                       ssSelections
                       strProperty
                    )
     (if (setq ssSelections (ssget (list (cons 0 "polyline"))))
      (vlax-for obj3dPolyline (vla-get-activeselectionset 
                             (setq objDocument (vla-get-activedocument
                                                (vlax-get-acad-object))))
       (if (= (vla-get-objectname obj3dPolyline) "AcDb3dPolyline")
        (progn
         (setq intCount       0
               lstCoordinates (mapcar 
                              '(lambda (sngCoordinate)
                                (if (= (/ (setq intCount (1+ intCount)) 3.0)
                                       (/ intCount 3)
                                    )                             
                                 nil
                                 sngCoordinate
                                ) 
                               )
                               (vlax-get obj3dPolyline "coordinates")
                              )
              lstCoordinates (vl-remove nil lstCoordinates)
              obj2dPolyline  (vla-addlightweightpolyline 
                              (vla-get-block 
                               (vla-get-activelayout objDocument))
                              (listtosafearray 5 lstCoordinates))
         )
         (foreach strProperty (list "truecolor" "layer" "linetype" "closed")
          (vlax-put obj2dPolyline strProperty (vlax-get obj3dPolyline strProperty))
         )
         (vla-delete obj3dPolyline)
        )
       )
      )
     )
     (princ)
    )
    
    
    ; This function creates a safearray from a list and the safearray type symbol
    ; for example: (listtosafearray vlax-vbinteger (list 0) )
    
    (defun ListToSafeArray (symSafeArrayType lstItems / safArray)
     (setq safArray (vlax-make-safearray symSafeArrayType (cons 0 (1- (length lstItems)))))
     (vlax-safearray-fill safArray lstItems)
    )
    
    ;vlax-vbInteger  (2)  Integer 
    ;vlax-vbLong     (3)  Long integer 
    ;vlax-vbSingle   (4)  Single-precision floating-point number 
    ;vlax-vbDouble   (5)  Double-precision floating-point number 
    ;vlax-vbString   (8)  String 
    ;vlax-vbObject   (9)  Object 
    ;vlax-vbBoolean (11)  Boolean 
    ;vlax-vbVariant (12)  Variant 
    (princ "C:3dTo2d")
    (prin1)
    Attached Files Attached Files

  3. #13
    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 will try your routine once I get back in the office on Tuesday to see which way is faster. Happy New Year.

  4. #14
    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.

  5. #15
    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.

  6. #16
    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!

  7. #17
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

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

    Oh, that's not my lisp. I just posted the link.
    Glad you got what you needed.

Page 2 of 2 FirstFirst 12

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
  •