icon

Forum de la communauté Allplan

[Question] Mapping 3D Objects to 2D Section Views


Hello,

I’m trying to figure out how 3D object coordinates can be mapped to their representation in 2D sections, essentially, I want to map from the 3D (global) space to the 2D (local) space of a section (see figure below). However, I’m struggling to achieve this.

When I implement a simple MultiElementSelectInteractor and select the section, I receive an object of type AllplanEleAdapter.ClippingPathBody_TypeUUID. The problem is that I cannot convert this to a PythonParts object, and it doesn’t seem to have any useful child or parent objects.

Is the section object even accessible with PythonParts, or is there another, better approach to work with sections?

Thanks in advance for your help!

Pièces-jointes (1)

Type: image/jpeg
Téléchargé 8 fois
Size: 46,04 KiB

Show most helpful answer Hide most helpful answer

Hi,

You will need to implement your own element selection interactor (or extend the MultiElementSelectInteractor, not sure what will work best for your case). In your custom interactor, directly after performing an element selection (literally directly after calling SelectElement), you need to call GetSelectedElementAssocView. If the element that was found, was found in a view/section, this will return a AssocViewElementAdapter with the transformation matrix. This matrix can be get with GetTransformationMatrix and it mapps your element from the global coordinate system to local coordinate system of the view.
If the element was not found in a section, calling IsNull() on the returned AssocViewAdapter will return True.

Hope that helps.

Cheers,
Bart

Hi,

You will need to implement your own element selection interactor (or extend the MultiElementSelectInteractor, not sure what will work best for your case). In your custom interactor, directly after performing an element selection (literally directly after calling SelectElement), you need to call GetSelectedElementAssocView. If the element that was found, was found in a view/section, this will return a AssocViewElementAdapter with the transformation matrix. This matrix can be get with GetTransformationMatrix and it mapps your element from the global coordinate system to local coordinate system of the view.
If the element was not found in a section, calling IsNull() on the returned AssocViewAdapter will return True.

Hope that helps.

Cheers,
Bart

Thank you for your quick response.
From your explanation, I now understand that if I can select the architectural elements through a CoordinateInput object, I can retrieve the transformation matrix using:

coordinate_input.GetSelectedElementAssocView().GetTransformationMatrix() -> Matrix3D

So, if I understand correctly, with this Matrix3D, calculating the 2D representation of any 3D point should be straightforward

However, a few points are still unclear:

1. Element selection
So far, I have been using the MultiElementSelectInteractor class to handle element selection:

self.selection_result = MultiElementSelectInteractorResult()
self.script_object_interactor = MultiElementSelectInteractor(
    self.selection_result,
    [AllplanEleAdapter.WallTier_TypeUUID],
    "Select walls"
) 

This approach provides the selection behavior I need, but it does not appear to expose its internal CoordinateInput object (Calling "self.script_object_interactor.__coord_input" draws an error). I attempted to subclass it; however, the API documentation only lists function names and arguments, making it difficult to understand how the selection is handled internally. More generally, it remains unclear how CoordinateInput operates within MultiElementSelectInteractor.
Is the source code for the Python API available by any chance?

2. Multiple associative views
Assuming I can select the desired architectural elements via a CoordinateInput class, how can I control which associative view is used?

For example, if the same wall appears in multiple sections (e.g., four different views), I would like to choose among those views. However, GetSelectedElementAssocView() only returns a single AssocViewElementAdapter, and it is not clear how that specific view is determined or how to influence the selection.

Thank you in advance for your help.