icon

Support Forum

Comparison.DeterminePosition not operating as expected


Hello all,
I am experiencing a problem where the call to DeterminePosition systematically returns with eOutside tInvalid ArchElementTypes.

Context : I have to check, prior to inserting an opening, if the insertion point of the opening is actually contained in the 3D geometry of its parent

Action : For this, I made the method "is_contained_in_parent" as below

def is_contained_in_parent(self, placement_matrix: AllplanGeo.Matrix3D, parent: AllplanElementAdapter) -> bool:
"""
Find if opening insertion point is contained or not in parent
Args:
parent: name of the element in which the opening is to be placed
placement_matrix: matrix describing the placement of the opening

Returns:
Boolean: True if contained else False
"""
if parent.GetArchElementType() == AllplanElementAdapter.ArchElementType.tInvalid:
geometry_3d = parent.GetModelGeometry()
else:
geometry_3d = parent.GetGeometry()

t_vec = placement_matrix.GetTranslationVector()
insertion_point = AllplanGeo.Point3D(t_vec.X, t_vec.Y, t_vec.Z)
comparison_result_3d = AllplanGeo.Comparison.DeterminePosition(geometry_3d, insertion_point, 0.0)

return False if comparison_result_3d == AllplanGeo.eComparisionResult.eOutside else True

Results : The call to the method returns systematically eOutside for tInvalid ArchElementTypes even for point located in the 3D geometry

For example, with as below parameters, DeterminePosition returns eOutside

insertion_point=Point3D(694550, 164500, -5500) and

geometry_3d : Polyhedron3D(
Type(3)
IsNegative(0)
PartsCount(1)
EdgeCount(12)
FaceCount(6)
VertexCount(
Vertices(
(691050, 167000, -6500)
(691050, 148700, -6500)
(698250, 148700, -6500)
(698250, 167000, -6500)
(691050, 167000, -5500)
(691050, 148700, -5500)
(698250, 148700, -5500)
(698250, 167000, -5500)))

Is something wrong in the way I am using DeterminePosition ?

Thanks

Hilfreichste Antwort anzeigen Hilfreichste Antwort verbergen

Hi,

the point is located exactly on the top face, so maybe that is the reason. The function does not return eOnElement in case of polyhedrons, so the result in this case is not predictable. I tried a point exactly on the bottom face, and I got eInside.

What you can do is examine the position of the point projection on XY plane in the polyhedron's footprint (which is a Polygon2D):

footprint = AllplanGeo.PolyhedronUtil.GetFootprint(geometry_3d)
AllplanGeo.Comparison.DeterminePosition(geometry_3d, insertion_point.To2D)
And later examine it's position in Z direction.
Also, don't compare with 0 tolerance (floating point error). Always provide a number (might be small, like 1e-3) or leave it empty to use default tolerance.

I don't have a better solution for you, but maybe someone in this community will?

Best,
Bart

Hi,

the point is located exactly on the top face, so maybe that is the reason. The function does not return eOnElement in case of polyhedrons, so the result in this case is not predictable. I tried a point exactly on the bottom face, and I got eInside.

What you can do is examine the position of the point projection on XY plane in the polyhedron's footprint (which is a Polygon2D):

footprint = AllplanGeo.PolyhedronUtil.GetFootprint(geometry_3d)
AllplanGeo.Comparison.DeterminePosition(geometry_3d, insertion_point.To2D)
And later examine it's position in Z direction.
Also, don't compare with 0 tolerance (floating point error). Always provide a number (might be small, like 1e-3) or leave it empty to use default tolerance.

I don't have a better solution for you, but maybe someone in this community will?

Best,
Bart