mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 13:52:23 +00:00
You can now assign reps to type products. See #1222.
This commit is contained in:
@@ -1,18 +1,34 @@
|
|||||||
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 = {"product": None, "representation": None}
|
||||||
"product": None,
|
|
||||||
"representation": None
|
|
||||||
}
|
|
||||||
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):
|
||||||
definition = self.settings["product"].Representation
|
if self.settings["product"].is_a("IfcProduct"):
|
||||||
if not definition:
|
definition = self.settings["product"].Representation
|
||||||
definition = self.file.createIfcProductDefinitionShape()
|
if not definition:
|
||||||
self.settings["product"].Representation = definition
|
definition = self.file.createIfcProductDefinitionShape()
|
||||||
representations = list(definition.Representations) if definition.Representations else []
|
self.settings["product"].Representation = definition
|
||||||
representations.append(self.settings["representation"])
|
representations = list(definition.Representations) if definition.Representations else []
|
||||||
definition.Representations = representations
|
representations.append(self.settings["representation"])
|
||||||
|
definition.Representations = representations
|
||||||
|
elif self.settings["product"].is_a("IfcTypeProduct"):
|
||||||
|
if self.settings["product"].RepresentationMaps:
|
||||||
|
maps = list(self.settings["product"].RepresentationMaps)
|
||||||
|
else:
|
||||||
|
maps = []
|
||||||
|
self.zero = self.file.createIfcCartesianPoint((0.0, 0.0, 0.0))
|
||||||
|
self.x_axis = self.file.createIfcDirection((1.0, 0.0, 0.0))
|
||||||
|
self.z_axis = self.file.createIfcDirection((0.0, 0.0, 1.0))
|
||||||
|
maps.append(
|
||||||
|
self.file.create_entity(
|
||||||
|
"IfcRepresentationMap",
|
||||||
|
**{
|
||||||
|
"MappingOrigin": self.file.createIfcAxis2Placement3D(self.zero, self.z_axis, self.x_axis),
|
||||||
|
"MappedRepresentation": self.settings["representation"],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.settings["product"].RepresentationMaps = maps
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class Usecase:
|
|||||||
return self.file.create_entity(
|
return self.file.create_entity(
|
||||||
"IfcRepresentationMap",
|
"IfcRepresentationMap",
|
||||||
**{
|
**{
|
||||||
"MappingOrigin": self.file.createIfcAxis2Placement3D(zero, z_axis, x_axis),
|
"MappingOrigin": self.file.createIfcAxis2Placement3D(self.zero, self.z_axis, self.x_axis),
|
||||||
"MappedRepresentation": self.settings["representation"],
|
"MappedRepresentation": self.settings["representation"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user