Jump to content

3d polyline to polyline


daiharv

Recommended Posts

Is there a way of converting 3d polylines to polylines with an elevation?

 

I have a dwg of contour information, the contours are 3d polylines, because they are contours the z value is constant all along the line, so there no question what the elevation of the polyline would need to be.

 

I need to do this as I then need to import the dwg into a GIS programme called MapInfo whch doesn't read 3d polylines.

 

I have access to AutoCAD 2004 or 2005LT.

 

Any ideas?

Link to comment
Share on other sites

Is there a way of converting 3d polylines to polylines with an elevation?

 

I have a dwg of contour information, the contours are 3d polylines, because they are contours the z value is constant all along the line, so there no question what the elevation of the polyline would need to be.

 

Interesting. What kind of program creates 3Dpolylines for contours?

 

Oh well, Toolpac from http://www.dotsoft.com includes this tool among its 650+ tools.

 

If it's worth your billable time to find a freebie - start here : http://management.cadalyst.com/cadman/article/articleDetail.jsp?id=101136

Link to comment
Share on other sites

Actually I think you might develop a lisp or VBA application to take the coordinates of vertices of all the 3D polylines in the drawing, make new 2D polylines usind "x" and "y" coordinates only, then move to the deasired height and delete the old 3D polyline....

Link to comment
Share on other sites

Actually I think you might develop a lisp or VBA application to take the coordinates of vertices of all the 3D polylines in the drawing, make new 2D polylines usind "x" and "y" coordinates only, then move to the deasired height and delete the old 3D polyline....

 

That's fine if you know lisp and you get paid to churn out lisp code. Most production drafters/designers fit neither category.

Link to comment
Share on other sites

May be I could write a VBA routine for you to substitute 3D polylines with 2d ones and each polyline elevation will be equal to the Z-coordinate of the first point of the old 3D polyline. If that is what you need drop a line... and send me your e-mail address

Link to comment
Share on other sites

Joro-

No need to write it, Tony T. wrote one years ago, it's free at the link I posted above.

 

OK, here's the direct link - http://members.bellatlantic.net/~vze2vjds/free.htm

 

Well that code is kinda scrambled. below is partly formatted code that I got to work:

 

;; CVPOLY.LSP Copyright 1996, 1997 Tony Tanzillo all rights reserved
;; ;; Converts 3D polylines to 2D polylines that lie on
;; the XY plane of the current UCS.
(setq filter:3dpoly '( (-4 . "<AND") (0 . "POLYLINE") (-4 . "&=") (70 .  (-4 . "AND>") ) )
(defun get (key alist) (cdr (assoc key alist)) )
(defun UCSZdir ()
 (trans '(0 0 1) 0 1)
)
(defun UCSPoint2D (wcspoint)
 ( (lambda (p) (list (car p) (cadr p) 0.0) ) (trans wcspoint 0 1) )
)
(defun mapvertex (e function / e d rslt)
 (while (/= "SEQEND" (get 0 (setq d (entget (setq e (entnext e)) '("*"))))
)
(setq rslt (cons ( (lambda (function data / e d rslt) (apply function (list data)) ) function d ) rslt ) ) ) (reverse rslt) )
(defun cvpoly (pline / data ucs)
 (setq data (entget pline '("*"))) (entmake (subst (cons 70 (logand (get 70 data) (~ ))
(assoc 70 data) (subst (cons 210 (setq ucs (ucszdir))) (assoc 210 data) (subst '(100 . "AcDb2dPolyline") '(100 . "AcDb3dPolyline") data ) ) )
)
(mapvertex pline '(lambda (data) (if (zerop (logand (get 70 data) 9))
 (entmake (list '(0 . "VERTEX") '(100 . "AcDbEntity") (assoc 8 data) '(100 . "AcDbVertex") '(100 . "AcDb2dVertex")
 (cons 10 (UCSPoint2d (get 10 data))) (cons 70 (logand (get 70 data) (~ 32))) ) ) ) ))
 (entmake '((0 . "SEQEND"))) (entdel pline) 
)
(defun C:CVPOLY ( / ss i) 
 (cond 
     ( (not (setq ss (ssget filter:3dpoly))) (princ "\nNo 3D Polylines selected."))
     (t (setvar "CMDECHO" 0) (command "._UNDO" "_Begin") (repeat (setq i (sslength ss)) (cvpoly (ssname ss (setq i (1- i)))) ) (command "._UNDO" "_En") ) )   (princ) 
)
(princ "\nCVPOLY.LSP Copyright 1997 Tony Tanzillo") (princ "\nCVPOLY command loaded.")
(princ)
;; END CVPOLY.LSP

Link to comment
Share on other sites

  • 2 weeks later...

damn, doesn't quite work a treat.

 

The LSP does convert all the 3D polylines to 2D polylines but the elevation is zero on all the resultant polylines.

 

Does anyone know if this LSP could be amneded to retain the height data?

 

Or is there another LSP out there that dioes this already.

 

many thanks.

Link to comment
Share on other sites

Have checked the freebies @ dotsoft and LSP routines at CADalyst, but I can't find anything for my needs there.

 

Follwed your link to the CADalyst site which gives an explanation of how the LSP works, but this LSP gives the 2D polylines no height data, I need it to remember the height data ("a 2D polyline with an elevation").

 

I don't understand LSP routines enough to amend it myself.

 

Although in the link you sent it says

 

"George Anderson of Eugene, Oregon, e-mailed a request to turn 3D polylines into 2D polylines. Several routines he downloaded from the Internet claimed to perform this function, but all failed to set the z coordinate to zero."

 

I could do with one of these routines I think.

 

 

Many thanks.

Link to comment
Share on other sites

  • 2 years later...
  • 2 years later...
  • 2 weeks later...

I use a little program quite regulary called Cad Tools. It has quite a few handy items including some convert tools such as 3D Polyline >> Polyline. Also others like Circle >> 3D Polyline.

 

Heres the link if anybody does'nt already know about it.

 

http://www.glamsen.se/CadTools.htm

 

Hope its helpful to someone. Cheers

Link to comment
Share on other sites

  • 5 years later...

;;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 . "

(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: ")

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...