mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-03 21:38:12 +00:00
Add ability to map representations. See #1222.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
class Usecase:
|
||||
def __init__(self, file, settings=None):
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"product": None,
|
||||
"representation": None,
|
||||
}
|
||||
self.ifc_vertices = []
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
self.get_mapping_source()
|
||||
|
||||
self.zero = self.file.createIfcCartesianPoint((0.0, 0.0, 0.0))
|
||||
self.x_axis = self.file.createIfcDirection((1.0, 0.0, 0.0))
|
||||
self.y_axis = self.file.createIfcDirection((0.0, 1.0, 0.0))
|
||||
self.z_axis = self.file.createIfcDirection((0.0, 0.0, 1.0))
|
||||
mapping_target = self.file.createIfcCartesianTransformationOperator3D(
|
||||
self.x_axis, self.y_axis, self.zero, 1, self.z_axis
|
||||
)
|
||||
mapped_item = self.file.createIfcMappedItem(self.get_mapping_source(), mapping_target)
|
||||
return self.file.create_entity(
|
||||
"IfcShapeRepresentation",
|
||||
**{
|
||||
"ContextOfItems": self.settings["representation"].ContextOfItems,
|
||||
"RepresentationIdentifier": self.settings["representation"].RepresentationIdentifier,
|
||||
"RepresentationType": "MappedRepresentation",
|
||||
"Items": [mapped_item],
|
||||
}
|
||||
)
|
||||
|
||||
def get_mapping_source(self):
|
||||
if self.settings["representation"].RepresentationMap:
|
||||
return self.settings["representation"].RepresentationMap[0]
|
||||
return self.file.create_entity(
|
||||
"IfcRepresentationMap",
|
||||
**{
|
||||
"MappingOrigin": self.file.createIfcAxis2Placement3D(zero, z_axis, x_axis),
|
||||
"MappedRepresentation": self.settings["representation"],
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user