mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 10:11:46 +00:00
Fix bug where you could create mapped representations without having a type product
This commit is contained in:
@@ -1,26 +1,24 @@
|
|||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, settings=None):
|
def __init__(self, file, settings=None):
|
||||||
self.file = file
|
self.file = file
|
||||||
self.settings = {
|
self.settings = {"representation": None}
|
||||||
"product": None,
|
|
||||||
"representation": None,
|
|
||||||
}
|
|
||||||
self.ifc_vertices = []
|
self.ifc_vertices = []
|
||||||
for key, value in settings.items():
|
for key, value in settings.items():
|
||||||
self.settings[key] = value
|
self.settings[key] = value
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
self.zero = self.file.createIfcCartesianPoint((0.0, 0.0, 0.0))
|
mapping_source = self.get_mapping_source()
|
||||||
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))
|
|
||||||
|
|
||||||
self.get_mapping_source()
|
if not mapping_source:
|
||||||
|
return
|
||||||
|
|
||||||
mapping_target = self.file.createIfcCartesianTransformationOperator3D(
|
zero = self.file.createIfcCartesianPoint((0.0, 0.0, 0.0))
|
||||||
self.x_axis, self.y_axis, self.zero, 1, self.z_axis
|
x_axis = self.file.createIfcDirection((1.0, 0.0, 0.0))
|
||||||
)
|
y_axis = self.file.createIfcDirection((0.0, 1.0, 0.0))
|
||||||
mapped_item = self.file.createIfcMappedItem(self.get_mapping_source(), mapping_target)
|
z_axis = self.file.createIfcDirection((0.0, 0.0, 1.0))
|
||||||
|
|
||||||
|
mapping_target = self.file.createIfcCartesianTransformationOperator3D(x_axis, y_axis, zero, 1, z_axis)
|
||||||
|
mapped_item = self.file.createIfcMappedItem(mapping_source, mapping_target)
|
||||||
return self.file.create_entity(
|
return self.file.create_entity(
|
||||||
"IfcShapeRepresentation",
|
"IfcShapeRepresentation",
|
||||||
**{
|
**{
|
||||||
@@ -32,12 +30,6 @@ class Usecase:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def get_mapping_source(self):
|
def get_mapping_source(self):
|
||||||
if self.settings["representation"].RepresentationMap:
|
for inverse in self.file.get_inverse(self.settings["representation"]):
|
||||||
return self.settings["representation"].RepresentationMap[0]
|
if inverse.is_a("IfcRepresentationMap"):
|
||||||
return self.file.create_entity(
|
return inverse
|
||||||
"IfcRepresentationMap",
|
|
||||||
**{
|
|
||||||
"MappingOrigin": self.file.createIfcAxis2Placement3D(self.zero, self.z_axis, self.x_axis),
|
|
||||||
"MappedRepresentation": self.settings["representation"],
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -243,13 +243,7 @@ class MapRepresentation(bpy.types.Operator):
|
|||||||
old_representation = None
|
old_representation = None
|
||||||
target_representation = self.file.by_id(obj_data.BIMMeshProperties.ifc_definition_id)
|
target_representation = self.file.by_id(obj_data.BIMMeshProperties.ifc_definition_id)
|
||||||
obj.data = obj_data
|
obj.data = obj_data
|
||||||
result = map_representation.Usecase(
|
result = map_representation.Usecase(self.file, {"representation": target_representation}).execute()
|
||||||
self.file,
|
|
||||||
{
|
|
||||||
"product": product,
|
|
||||||
"representation": target_representation,
|
|
||||||
},
|
|
||||||
).execute()
|
|
||||||
assign_representation.Usecase(self.file, {"product": product, "representation": result}).execute()
|
assign_representation.Usecase(self.file, {"product": product, "representation": result}).execute()
|
||||||
if old_representation:
|
if old_representation:
|
||||||
bpy.ops.bim.remove_representation(ifc_definition_id=old_representation.id())
|
bpy.ops.bim.remove_representation(ifc_definition_id=old_representation.id())
|
||||||
|
|||||||
Reference in New Issue
Block a user