mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
You can now edit psets of profiles
This commit is contained in:
@@ -42,6 +42,7 @@ class Usecase:
|
||||
def append_profile_def(self):
|
||||
if [e for e in self.file.by_type("IfcProfileDef") if e.ProfileName == self.settings["element"].ProfileName]:
|
||||
return
|
||||
self.whitelisted_inverse_attributes = {"IfcProfileDef": ["HasProperties"]}
|
||||
return self.add_element(self.settings["element"])
|
||||
|
||||
def append_type_product(self):
|
||||
|
||||
@@ -64,3 +64,15 @@ class Usecase:
|
||||
"Material": self.settings["product"],
|
||||
}
|
||||
)
|
||||
elif self.settings["product"].is_a("IfcProfileDef"):
|
||||
for definition in self.settings["product"].HasProperties or []:
|
||||
if definition.Name == self.settings["name"]:
|
||||
return definition
|
||||
|
||||
return self.file.create_entity(
|
||||
"IfcProfileProperties",
|
||||
**{
|
||||
"Name": self.settings["name"],
|
||||
"ProfileDefinition": self.settings["product"],
|
||||
}
|
||||
)
|
||||
|
||||
@@ -26,6 +26,8 @@ class Data:
|
||||
cls.add_type_product_psets(product, product_id)
|
||||
elif product.is_a("IfcMaterialDefinition"):
|
||||
cls.add_material_psets(product, product_id)
|
||||
elif product.is_a("IfcProfileDef"):
|
||||
cls.add_profile_psets(product, product_id)
|
||||
else:
|
||||
cls.add_product_psets(product, product_id)
|
||||
|
||||
@@ -44,6 +46,13 @@ class Data:
|
||||
for pset in product.HasProperties:
|
||||
cls.add_pset(pset, product_id)
|
||||
|
||||
@classmethod
|
||||
def add_profile_psets(cls, product, product_id):
|
||||
if not product.HasProperties:
|
||||
return
|
||||
for pset in product.HasProperties:
|
||||
cls.add_pset(pset, product_id)
|
||||
|
||||
@classmethod
|
||||
def add_product_psets(cls, product, product_id):
|
||||
if not hasattr(product, "IsDefinedBy") or not product.IsDefinedBy:
|
||||
@@ -59,7 +68,7 @@ class Data:
|
||||
@classmethod
|
||||
def add_pset(cls, pset, product_id):
|
||||
data = pset.get_info()
|
||||
if not pset.is_a("IfcMaterialProperties"):
|
||||
if not pset.is_a("IfcMaterialProperties") and not pset.is_a("IfcProfileProperties"):
|
||||
del data["OwnerHistory"]
|
||||
del data["HasProperties"]
|
||||
if hasattr(pset, "HasProperties"):
|
||||
|
||||
Reference in New Issue
Block a user