Support Forum

Get the Z coordinate in an 3D UVS view

Schlagworte:
  • 2025-0-3

Is it possible to get the Z coordinate of an element when selecting a point in a 3D UVS view?

I need to create level dimensions directly in the 3D view.

Thank you!

Anhänge (1)

Typ: image/png
19-mal heruntergeladen
Größe: 10,57 KiB

Hi,

I took the challenge. It wasn't easy, but I made it (see the attached script).

I created a small interactor that allows you to input a point on an edge. Assuming, that this happened in a UVS, the clicked point, the edge on which it was clicked (both in UVS coordinate system) and the UVS itself gets recognized and stored in the result class (ScriptObjectInteractors.ZCoordResult).

Then, in the ScriptObjects.ZCoordScriptObject class, in the start_next_input() method I do following:

  • get the transformation matrix of the uvs and invert it, to becoma a matrix that transforms the coordinates from the UVS to the world coordinate system
  • I transform the edge to the world coordinate system with this matrix
  • I define a ray pointing in the Z- direction and going through the point clicked in the UVS and also transform it to world
  • because the edge can be a line, arc or a b-spline, I convert it to a b-spline
  • I search for the intersection between the edge and the ray -> this will be the point clicked on the edge
  • I get the Z coordinate of it and print it

This works for a point clicked on an edge, like on your screen shot. Clicking the vertex won't bring any result.

Have a look on the script and feel free to reuse it. Now it only prints the elevation so you will need to adapt it to create a text like on your screenshot.

Best,
Bart

Anhänge (1)

Typ: application/zip
15-mal heruntergeladen
Größe: 3,65 KiB