Convert Line to 3d Polyline

Convert Line to 3d Polyline

mhughesUYP4M
Participant Participant
3,796 Views
10 Replies
Message 1 of 11

Convert Line to 3d Polyline

mhughesUYP4M
Participant
Participant

Hi,

 

Is there a way to convert line to 3d polyline and keep z values and object data?

 

Our current workflow is to import .shp files using MAPIMPORT, any lines with 2 vertices automatically become lines and whereas those with more become 3d polylines. For simplicity i want them all to be 3d polylines. 

 

I've tried MAPCLEAN but the new polyline only takes the start z value and flattens the line.

 

Any ideas?

 

0 Likes
Accepted solutions (1)
3,797 Views
10 Replies
Replies (10)
Message 2 of 11

ChicagoLooper
Mentor
Mentor

Hi @mhughesUYP4M 

Shapefiles vary, in particular, the database file (dbf) varies from fine-to-file. There's no way to answer your question without your specific, real-deal shapefile.

 

Chicagolooper

EESignature

0 Likes
Message 3 of 11

mhughesUYP4M
Participant
Participant

@ChicagoLooper

 

The attached .zip contains an example SHP file with one entity as line and the other as 3d polyline.

Little background on the data, this is captured with a Leica GNSS or TS, then imported into Leica Infinity as the proprietary file format (DBX) before being exported to SHP.

0 Likes
Message 4 of 11

O_Eckmann
Mentor
Mentor

Hi,

 

Its a little brutal, but this code should do the job.

 

(defun C:LineTo3DPoly ( / oFileCopy ssLine iLine oLine PT1 PT2)
  ; find COPY_OD.LSP
  (if (not (setq oFileCopy (findfile "COPY_OD.lsp")))
    (setq oFileCopy (strcat (vl-registry-read (strcat "HKEY_LOCAL_MACHINE\\" (vlax-machine-product-key)) "Location") "MAP\\SAMPLE\\COPY_OD.LSP"))
  )
  (load oFileCopy)
  (if (setq ssLine (ssget (list (cons 0 "LINE"))))
    (progn
      (setq iLine 0)
      (repeat (sslength ssLine)
	(setq oLine (ssname ssLine iLine))
	(setq iLine (1+ iLine))
	(setq PT1 (cdr (assoc 10 (entget oLine))))
	(setq PT2 (cdr (assoc 11 (entget oLine))))
	(setvar "CLAYER" (cdr (assoc 8 (entget oLine))))
	(command "_3DPOLY" "_none" (trans PT1 0 1) "_none" (trans PT2 0 1) "")
	(copy_data oLine (entlast) T)
      )
      (command "_ERASE" ssLine "")
    )
  )
)

 

Olivier Eckmann

EESignature

0 Likes
Message 5 of 11

ChicagoLooper
Mentor
Mentor

Hi @mhughesUYP4M 

 

  1. In addition to Map3, do you run Civil 3D too?
  2. Is it possible to change your Workspace from Planning and Analysis to Civil 3D?

If you run C3D, it's easier than you think.

 

Chicagolooper

EESignature

0 Likes
Message 6 of 11

braudpat
Mentor
Mentor
Accepted solution

Hello  @mhughesUYP4M  @O_Eckmann   @ChicagoLooper 

 

The Routine "LineTo3DPoly" has a Bug for me : it can't load correctly the "COPY_OD" routine !

 

But the Routine is OK if the "COPY_OD" has been loaded before running  "LineTo3DPoly"  ...

 

So please find attached the 2 Lisp Routines : "COPY_OD" and "LineTo3DPoly" (without the LOAD Lines)

 

Bye, Patrice (The Old French EE Froggy)

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 7 of 11

O_Eckmann
Mentor
Mentor

Hi @braudpat ,

 

I've made error between AutoCAD Sample Folder and Map Sample Folder.

I've modified my code to search COPY_OD.LSP in 

C:\Program Files\Autodesk\AutoCAD 20XX\Map\Sample

 

Olivier

Olivier Eckmann

EESignature

0 Likes
Message 8 of 11

mhughesUYP4M
Participant
Participant

@braudpat @O_Eckmann 

Thanks guys, the LSP did the trick.

 

@ChicagoLooper  

I am indeed running C3D and have access to Planning and Analysis. Happy to hear of another route to solve.

0 Likes
Message 9 of 11

ChicagoLooper
Mentor
Mentor

@mhughesUYP4M wrote

<<I am indeed running C3D and have access to Planning and Analysis. Happy to hear of another route to solve.>>

 

Using the shapefile you uploaded in Post #3 you can E-A-S-I-L-Y convert your linework to 3D Polylines.  

 

First, use MAPIMPORT command to import the shapefile as plain vanilla AutoCAD objects. When importing your uploaded shapefile named SLN.shp, the command will create two objects: (A) a Line and (B) a 3D Polyline. After using MapImport, do this:

 

  1. Use the command PEDIT=>Multiple=>Select ALL Lines using a crossing window=>Enter=>Yes=>Enter <<This will CONVERT the line object to a Polyline, the 3D polyline will REMAIN as a 3D polyline.>>Image-1Image-1
  2. Next, change from Planning and Analysis workspace to Civil 3D workspace. Then go to Modify Tab=>Design Panel=>Design dropdown=>Convert 2D to 3D Polylines=>Use a crossing window to select ALL polylines=>Enter.Image-2Image-2
  3. Finally, select all polylines. To verify the operation, view the Properties Palette with ALL lines still selected. It will indicate the total number of polylines within your selection.Image-3Image-3 

 

 

 

Chicagolooper

EESignature

Message 10 of 11

O_Eckmann
Mentor
Mentor

Hi @ChicagoLooper ,

 

I don't know if it's due to my french version, but, when using PEDIT MULTIPLE to convert line to 2D polylines I lose Object Data. OP wants to keep Z value and OD.

Is it same for you?

 

Olivier

Olivier Eckmann

EESignature

0 Likes
Message 11 of 11

Camyran_M&Ey
Observer
Observer

Use "Join" command

0 Likes