3D polyline Vector Z value to 2D polyline elevation...

Recommended Posts

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.

Share on other sites

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.

Share on other sites
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.

Share on other sites

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

M.R.

Share on other sites

Try something like this:

```[color=GREEN];;------------=={ 3D Polylines to LWPolylines }==-------------;;[/color]
[color=GREEN];;                                                            ;;[/color]
[color=GREEN];;  Converts a selection of 3D Polylines to LWPolylines with  ;;[/color]
[color=GREEN];;  elevation equal to the Z-component of the first vertex of ;;[/color]
[color=GREEN];;  the 3D Polyline. Retains all properties of the original   ;;[/color]
[color=GREEN];;  3D Polyline.                                              ;;[/color]
[color=GREEN];;------------------------------------------------------------;;[/color]
[color=GREEN];;------------------------------------------------------------;;[/color]

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

Share on other sites

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

Cheers up to Lee Mac and a big thank you.

Share on other sites

You're welcome scremin.

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.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.