Support Forum

Get the direction of the section when the user selects a point or moves the move in section view [Gelöst]


I am trying to get the direction of the section when the user selects or moves the mouse in the section view. Could you provide some ideas on how to detect this? Thank you!

Anhänge (1)

Typ: image/png
22-mal heruntergeladen
Größe: 14,83 KiB

Lösung anzeigen Lösung verbergen

You can transform the vector (0, 0,-1) with the UVS's transformation matrix:

view_direction = AllplanGeo.Vector3D(0,0-1) * world_to_uvs

(0, 0,-1) is the view direction of the plan view, which is the starting point for the UVS transformation.

Best,
Bart

Hi,

can you give me more details?

  • which ALLPLAN version are you working with
  • briefly, what is the workflow, you are trying to implement: are you trying to select something in the UVS or trying to draw something there (perform coordinate input)

Best,
Bart

Hi bmarciniec,
I am using Allplan 2025 WIP.
The workflow is: I am trying to select a point. If it is in the section, it will be recognized, and the direction will be determined.
Then, the point will be transformed to the correct 3D position based on the section's direction.
Thank you

Anhänge (1)

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

Hi,

I assume, what you build is an interactor PythonPart. During the input, you are calling coord_input.GetInputPoint() somewhere in your code. Try to call coord_input.GetInputAssocView() directly after that. This should give you the AssocViewAdapter - basically the representation of the UVS, in which the point was clicked.

This adapter should have a transformation matrix. You can get it with GetTransformationMatrix. This matrix transforms elements from world coordinate system to UVS coordinates. What you need is the opposite. You want to transform the point from UVS to world coordinate system, so you will need the inverted matrix.

The code could look like this

    assoc_view = coord_input.GetInputAssocView()
    world_to_uvs = assoc_view.GetTransformationMatrix()

    # copy the matrix and invert it
    uvs_to_world = AllplanGeo.Matrix3D(world_to_uvs)
    uvs_to_world.GaussInvert()
    
    point_in_world = your_point_in_uvs * uvs_to_world

Please make sure, that the matrix you get is not an identity matrix. This would mean, that the GetInputAssocView() didn't delivered what it should. I know it worked, but now I cannot make it work on my PC.

Best,
Bart

I have tried that before, but after transforming, the point returns incorrectly.
- If I select a point when the section direction aligns with the Y-axis, the point always returns with Y = 0.
- If I select a point when the section direction aligns with the X-axis, the point always returns with X = 0.
I think the returned matrix is incorrect.

Anhänge (1)

Typ: image/png
18-mal heruntergeladen
Größe: 16,02 KiB

Actually, that is the expected outcome - the matrix is correct. This is due to the fact, that a UVS is only a 2D representation of the model. It's basically a collection of 2D-lines, with Z coordinate equal to 0. The 3rd dimension gets lost. So when you point on the lower-left corner of the column in the section 2-2 , you can only figure out its X and Z world coordinates. To figure out the Y coordinate, you would have to prompt for an "additional" point in the section 3-3.

This is how some of the native functions in ALLPLAN deal with input in UVS. E.g. when placing a mesh or a fixture in a UVS, you are always asked to click an additional point in another UVS (whose view direction does not align with the direction of the initial one) for exactly this purpose: figure out the third coordinate.

Best,
Bart

So, I need to find the third coordinate by another ways. That's why I asked how to get the direction of the section when selecting a point in the UVS view. Is there any way to retrieve that?

You can transform the vector (0, 0,-1) with the UVS's transformation matrix:

view_direction = AllplanGeo.Vector3D(0,0-1) * world_to_uvs

(0, 0,-1) is the view direction of the plan view, which is the starting point for the UVS transformation.

Best,
Bart

Thank you for your help in answering my question. I really appreciate it!