shape_builder.create_axis2_placement_2d

This commit is contained in:
Andrej730
2024-09-11 15:05:18 +05:00
parent 35221ed772
commit fe0be0cdae
2 changed files with 17 additions and 14 deletions
@@ -228,10 +228,8 @@ class ShapeBuilder:
:return: IfcCircle
:rtype: ifcopenshell.entity_instance
"""
ifc_center = self.file.createIfcAxis2Placement2D(self.file.createIfcCartesianPoint(center))
ifc_center = self.create_axis2_placement_2d(center)
ifc_curve = self.file.createIfcCircle(ifc_center, radius)
# self.file_file.createIfcAxis2Placement2D(tool.Ifc.get().createIfcCartesianPoint(center[0:2]))
return ifc_curve
def plane(
@@ -324,9 +322,7 @@ class ShapeBuilder:
for further extrusion.
"""
direction = self.file.createIfcDirection(ref_x_direction)
ifc_position = self.file.createIfcAxis2Placement2D(
self.file.createIfcCartesianPoint(position), RefDirection=direction
)
ifc_position = self.create_axis2_placement_2d(position, direction)
ifc_ellipse = self.file.createIfcEllipse(
Position=ifc_position, SemiAxis1=x_axis_radius, SemiAxis2=y_axis_radius
)
@@ -373,9 +369,7 @@ class ShapeBuilder:
"OuterCurve": outer_curve,
}
if self.file.schema == "IFC2X3":
kwargs["Position"] = self.file.create_entity(
"IfcAxis2Placement2D", self.file.create_entity("IfcCartesianPoint", [0.0, 0.0])
)
kwargs["Position"] = self.create_axis2_placement_2d()
if inner_curves:
if not isinstance(inner_curves, collections.abc.Iterable):
@@ -584,6 +578,17 @@ class ShapeBuilder:
position=matrix[:, 3][:3].tolist(), z_axis=matrix[:, 2][:3].tolist(), x_axis=matrix[:, 0][:3].tolist()
)
def create_axis2_placement_2d(
self, position: VectorTuple = (0.0, 0.0), x_direction: Optional[VectorTuple] = None
) -> ifcopenshell.entity_instance:
"""Create IfcAxis2Placement2D."""
ref_direction = self.file.create_entity("IfcDirection", x_direction) if x_direction else None
return self.file.create_entity(
"IfcAxis2Placement2D",
Location=self.file.create_entity("IfcCartesianPoint", position),
RefDirection=ref_direction,
)
def mirror(
self,
curve_or_item: Union[ifcopenshell.entity_instance, list[ifcopenshell.entity_instance]],
@@ -31,12 +31,10 @@ class TestCreatingShapes(test.bootstrap.IFC4):
assert shape.verts
def test_create_IfcEllipse(self):
ifc_position = self.file.create_entity(
"IfcAxis2Placement2D",
self.file.create_entity("IfcCartesianPoint", V(0, 0)),
RefDirection=self.file.create_entity("IfcDirection", V(1, 0)),
builder = ShapeBuilder(self.file)
item = self.file.create_entity(
"IfcEllipse", Position=builder.create_axis2_placement_2d(), SemiAxis1=1.0, SemiAxis2=0.5
)
item = self.file.create_entity("IfcEllipse", Position=ifc_position, SemiAxis1=1.0, SemiAxis2=0.5)
settings = ifcopenshell.geom.settings()
shape = ifcopenshell.geom.create_shape(settings, item)
assert shape.verts