Jump to content

Recommended Posts

Posted

Hello everyone, I am quite new here in this forum and I was expecting some help.

Recently I've been working with water distribution models and I just faced a wasting time problem when working with elevation data. People in my office have to look for every elevation data in the topografic dwg and then write down all those numbers one by one in an Excel spreadsheet. I think this process is kinda waste of time, so I came here looking for some help. If anyone could help me I would apreciate it very much.

Basicaly, what I do actualy need is a lisp routine capable of converting a 3Dpolyline to a 2Dpolyline but changing also the 3D polylines' vector Z to the 2D polylines' elevation. For example: if I have a 3d polyline with vector Z value of 350 (meters), I want the lisp program to turn it into a 2D polyline with Elevation value of 350.

 

Thanks in advance..

Posted

3d polyline vertices (points) may have different Z coordinate... Are all them on the same elevation? If that's the case, the easiest way to do conversion is to explode 3d polyline, and then join lines into light 2d polyline (elevation will be preserved)...

 

M.R.

Posted
3d polyline vertices (points) may have different Z coordinate... Are all them on the same elevation? If that's the case, the easiest way to do conversion is to explode 3d polyline, and then join lines into light 2d polyline (elevation will be preserved)...

 

M.R.

 

Actualy all the vertices of the 3d polylines have exactly the same Z vector value. I want all the vertices to continue at the same "elevation".

I found a lisp program to convert 3d polylines to 2d polylines but the program prompts for every elevation change what becomes annoying.

I will try ot be more specific: imagine 100 3dpolylines with different VECTOR Z values. Every 3dpolylines have a lot of vertices but they are all in the same Vector Z (elevation). So what I need is a program to convert those 3d polylines into 2dpolylines but also the program must convert the Vector Z (3dpolylines elevation) to Elevation (2dpolyline).

Once the number of 3d polylines is enourmous in every file that I have to work with, it becomes a huge waste of time to change every single 3dpolyline one by one.

Posted

Just explode all 3d polylines and then join - all (new objects will be light 2d polylines with preserved elevations)...

 

M.R.

Posted (edited)

Try something like this:

;;------------=={ 3D Polylines to LWPolylines }==-------------;;
;;                                                            ;;
;;  Converts a selection of 3D Polylines to LWPolylines with  ;;
;;  elevation equal to the Z-component of the first vertex of ;;
;;  the 3D Polyline. Retains all properties of the original   ;;
;;  3D Polyline.                                              ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2012 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;

(defun c:3d2lw ( / e i l s v x )
   (if (setq s (ssget "_:L" '((0 . "POLYLINE") (-4 . "&=") (70 . 8))))
       (repeat (setq i (sslength s))
           (setq e (ssname  s (setq i (1- i)))
                 l (entget  e)
                 e (entnext e)
                 x (entget  e)
                 v nil
           )
           (while (eq "VERTEX" (cdr (assoc 0 x)))
               (setq v (cons (assoc 10 x) v)
                     e (entnext e)
                     x (entget  e)
               )
           )
           (if (entmake
                   (append
                       (list
                          '(000 . "LWPOLYLINE")
                          '(100 . "AcDbEntity")
                          '(100 . "AcDbPolyline")
                           (cons  038 (cadddr (last v)))
                           (cons  090 (length v))
                           (cons  070 (logand 129 (cdr (assoc 70 l))))
                           (assoc 008 l)
                           (cond ((assoc 006 l)) ('(006 . "BYLAYER")))
                           (cond ((assoc 039 l)) ('(039 . 0.0)))
                           (cond ((assoc 062 l)) ('(062 . 256)))
                           (cond ((assoc 370 l)) ('(370 . -1)))
                           (assoc 210 l)
                           (assoc 410 l)
                       )
                       (mapcar '(lambda ( v ) (list 10 (cadr v) (caddr v))) (reverse v))
                   )
               )
               (entdel (cdr (assoc -1 l)))
           )
       )
   )
   (princ)
)
(princ)
 
Edited by Lee Mac
Posted

Lee Mac you are the one.. The routine worked just fine.

 

Cheers up to Lee Mac and a big thank you.

  • 7 years later...
Posted

I know this is an old thread, but I am having the same issue and can't get Lee Mac's LSP to run using the command found in the source (3d2lw)

When I load the app, it also gives me this error: extra cdrs in dotted pair on input. I'm using AutoCAD 2018

I don't know how to code so I'm just trying to figure this out as I go.

Any advice appreciated!

Posted (edited)

@Groke

 

Correct the following line in the code:

(if (setq s (ssget "_:L" '((0 . "POLYLINE") (-4 . "&=") (70 . ))));<--MISSING Value with DXF code 70

With

(if (setq s (ssget "_:L" '((0 . "POLYLINE") (-4 . "&=") (70 . 8))));<-- CORRECTED

 

Edited by pkenewell
Posted

An alternative is to read Z, use flatten, then put property elevation to Z.

Posted (edited)
2 hours ago, pkenewell said:

@Groke

 

Correct the following line in the code:


(if (setq s (ssget "_:L" '((0 . "POLYLINE") (-4 . "&=") (70 . ))));<--MISSING Value with DXF code 70

With


(if (setq s (ssget "_:L" '((0 . "POLYLINE") (-4 . "&=") (70 . 0))));<-- CORRECTED

 

 

Shouldn't that be

(70 . 8)

 for a 3d polyline. IIRC this was one of the problems when then site moved over and 8 )  became a smilie 8) So you lost the 8 and a closing brace

Edited by dlanorh
Posted
On 3/3/2020 at 6:25 PM, groke said:

I know this is an old thread, but I am having the same issue and can't get Lee Mac's LSP to run using the command found in the source (3d2lw)

When I load the app, it also gives me this error: extra cdrs in dotted pair on input. I'm using AutoCAD 2018

I don't know how to code so I'm just trying to figure this out as I go.

Any advice appreciated!

 

I've now corrected the code in my post from 2012 that was damaged by the forum software update - I daren't think how many other code snippets are affected by this issue...

Posted (edited)
18 hours ago, dlanorh said:

Shouldn't that be


(70 . 8)

 for a 3d polyline. IIRC this was one of the problems when then site moved over and 8 )  became a smilie 8) So you lost the 8 and a closing brace

 

Oops you are right - thanks for the correction and the explanation to the OP! Updated my original post.

Edited by pkenewell

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