[Help] How to Get Elevation Values

Hi there,

I want to get the elevation value as the attached picture shown.

I’ve got the parameter of the objects, I can see the coordinates from the “Position” in the list.

I need to extract the elevation values out of this list. Please help. Appreciate.

String.Split to break the values at the commas.

List.LastItem to get just last item in the new sublists (your Z values).

String.Replace to remove the last floating bracket.

Hi Jacob,

Thanks for trying to help.

Not sure what I have done is right base on your instruction. However, there is an error occur, shown on screen capture.

@Seanc9XFAH if that point you better use Point.Z node

or else use like below,

1 Like

Try use stringfromobject before string.split

1 Like

Hi @Seanc9XFAH,

The values you see are a tuple of coordinates from an AutoCAD Point3d object. You can get the Z values directly with a couple lines of Python.

import clr

clr.AddReference('AcMgd')
clr.AddReference('AcDbMgd')

from Autodesk.AutoCAD.Geometry import *

tuples = IN[0]
output = []

if not isinstance(tuples, list):
	tuples = [tuples] 
for i in range(0, len(tuples)):
	output.append(tuples[i].Z)

OUT = output
5 Likes

Thanks for you help. However, I have copied your scripts in Python Script, but it seens that got error on it.

Could you share your dyn flie to me?

It’s probably the structure of your input list. The code I shared would work with a single value or a one-dimensional list. If you need it to work with multiple list levels, it would need to be modified. The simple fix would be to flatten the input list of coordinates first before feeding it into the Python script.

Did you tried like this?

2 Likes

It’s not actually a string element so you can’t work with the data as a string.

Sadly I don’t have C3D experience to recreate the data set (as simple as it may be) so I can’t really help out here… Wonder if you could just type a.Z; in a code block and be done with it though.

1 Like

Hi @Seanc9XFAH ,

As previously mentioned above by @jacob.small and @chuongmep, just convert objects to string. Below is a sample.

Hope this helps,
Assem

3 Likes

Appreciate so much. It is works well now