Toolpath's_1st Segment_Z Value

Toolpath's_1st Segment_Z Value

kmarkopouliotis
Advocate Advocate
573 Views
3 Replies
Message 1 of 4

Toolpath's_1st Segment_Z Value

kmarkopouliotis
Advocate
Advocate

Hi does anyone have an idea on how to get "Toolpath's_1st Segment_Z Value" ???

 

Thank you

0 Likes
574 Views
3 Replies
Replies (3)
Message 2 of 4

lokesh.kalia
Autodesk
Autodesk

Hi @kmarkopouliotis 
One way you can do it is via the function segment_get_point()

// Get details of the first point of the first segment
entity tp = entity('toolpath', 'mytp')
int segment_id = 0
int point_id = 0
object ptdata = segment_get_point(tp, segment_id, point_id)

// Round the z coord to 2 decimal places, to match the output in the 
// Reorder form. ptdata is a map, one of whose elements is an array
// with the xyz of the point.
real z_coord = ptdata['position'][2]
real rounded_z = round(z_coord, 2)

 

Another way is to obtain values directly from the form:

// Get the string in the first row and second column of the
// Toolpath Reorder form, which should be raised before values
// are obtained (the indices start from zero).
FORM TPLIST
string entry = list_cell_value('TPList.TPListView', 0, 1)

// This returns a string in the form "10, 20, 30". So, split the
// string.
string delim = ','
string list coords = tokens(entry, delim)

// This gives a list, whose 3rd element is the z-coord
real zval = coords[2]
print par $zval

 

 



Lokesh Kalia
Senior Manager, Software Development
0 Likes
Message 3 of 4

kmarkopouliotis
Advocate
Advocate

Thank you,

 

i'm trying to write an expression in order to have a quick observation of the toolpath's information....

0 Likes
Message 4 of 4

lokesh.kalia
Autodesk
Autodesk

In case you haven't considered it already, could you wrap either of those methods in a function and arrange to call that, e.g. something like:

 

FUNCTION first_segment_z(ENTITY tp, OUTPUT REAL zcoord)

 

 



Lokesh Kalia
Senior Manager, Software Development
0 Likes