BIM: prevent user to remove core properties

This commit is contained in:
Florian Foinant-Willig
2025-03-16 20:50:02 +01:00
committed by Kacper Donat
parent d5e2fdf8fd
commit 8a4c61ec5a
43 changed files with 568 additions and 551 deletions

View File

@@ -98,24 +98,24 @@ def create(ifcentity):
if hasattr(obj, attr):
continue
elif isinstance(value, int):
obj.addProperty("App::PropertyInteger", attr, "IFC")
obj.addProperty("App::PropertyInteger", attr, "IFC", locked=True)
setattr(obj, attr, value)
elif isinstance(value, float):
obj.addProperty("App::PropertyFloat", attr, "IFC")
obj.addProperty("App::PropertyFloat", attr, "IFC", locked=True)
setattr(obj, attr, value)
elif isinstance(value, ifcopenshell.entity_instance):
value = create(value)
obj.addProperty("App::PropertyLink", attr, "IFC")
obj.addProperty("App::PropertyLink", attr, "IFC", locked=True)
setattr(obj, attr, value)
elif isinstance(value, (list, tuple)) and value:
if isinstance(value[0], ifcopenshell.entity_instance):
nvalue = []
for elt in value:
nvalue.append(create(elt))
obj.addProperty("App::PropertyLinkList", attr, "IFC")
obj.addProperty("App::PropertyLinkList", attr, "IFC", locked=True)
setattr(obj, attr, nvalue)
else:
obj.addProperty("App::PropertyString", attr, "IFC")
obj.addProperty("App::PropertyString", attr, "IFC", locked=True)
if value is not None:
setattr(obj, attr, str(value))
for parent in ifcfile.get_inverse(ifcentity):