Option to assign non-ifc bsdd properties #5404

Example - https://imgur.com/a/cPtEkX2

Also Attribute now has additional field "metadata" for storing some case specific data
This commit is contained in:
Andrej730
2024-09-20 11:40:05 +05:00
parent 1f4d973a79
commit 4f64d044ac
6 changed files with 29 additions and 10 deletions
@@ -68,9 +68,7 @@ class SearchBSDDClass(bpy.types.Operator):
class GetBSDDClassificationProperties(bpy.types.Operator): class GetBSDDClassificationProperties(bpy.types.Operator):
bl_idname = "bim.get_bsdd_classification_properties" bl_idname = "bim.get_bsdd_classification_properties"
bl_label = "Search bSDD Class Properties" bl_label = "Search bSDD Class Properties"
bl_description = ( bl_description = "Search for bSDD class properties for the currently selected class"
"Search for bSDD class properties for the currently selected class. All non-IFC properties are skipped"
)
bl_options = {"REGISTER", "UNDO"} bl_options = {"REGISTER", "UNDO"}
def execute(self, context): def execute(self, context):
@@ -66,6 +66,11 @@ class BIMBSDDProperties(PropertyGroup):
description="Whether to search only for bSDD classes that match active object's IFC class", description="Whether to search only for bSDD classes that match active object's IFC class",
default=True, default=True,
) )
use_only_ifc_properties: BoolProperty(
name="Only IFC Properties",
description="Whether to display and assign only properties from IFC dictionary",
default=True,
)
load_preview_domains: BoolProperty( load_preview_domains: BoolProperty(
name="Load Preview Domains", description="Whether it should load preview and inactive domains", default=False name="Load Preview Domains", description="Whether it should load preview and inactive domains", default=False
) )
@@ -422,6 +422,7 @@ class AddClassificationReferenceFromBSDD(bpy.types.Operator, tool.Ifc.Operator):
objects = [self.obj] objects = [self.obj]
props = context.scene.BIMClassificationProperties props = context.scene.BIMClassificationProperties
bprops = context.scene.BIMBSDDProperties bprops = context.scene.BIMBSDDProperties
use_only_ifc_properties: bool = bprops.use_only_ifc_properties
bsdd_classification = bprops.classifications[bprops.active_classification_index] bsdd_classification = bprops.classifications[bprops.active_classification_index]
@@ -456,7 +457,12 @@ class AddClassificationReferenceFromBSDD(bpy.types.Operator, tool.Ifc.Operator):
for classification_pset in bprops.classification_psets: for classification_pset in bprops.classification_psets:
properties = {} properties = {}
for prop in classification_pset.properties:
blender_properties = classification_pset.properties
if use_only_ifc_properties:
blender_properties = [p for p in blender_properties if p.metadata == "IFC"]
for prop in blender_properties:
properties[prop.name] = prop.get_value() properties[prop.name] = prop.get_value()
if classification_pset.name == "undefined_set": if classification_pset.name == "undefined_set":
@@ -175,6 +175,7 @@ class ReferenceUI:
row = self.layout.row() row = self.layout.row()
row.prop(self.bprops, "should_filter_ifc_class") row.prop(self.bprops, "should_filter_ifc_class")
row.prop(self.bprops, "use_only_ifc_properties")
if len(self.bprops.classifications): if len(self.bprops.classifications):
self.layout.template_list( self.layout.template_list(
@@ -199,11 +200,18 @@ class ReferenceUI:
row.operator("bim.get_bsdd_classification_properties", text="", icon="COPY_ID") row.operator("bim.get_bsdd_classification_properties", text="", icon="COPY_ID")
if len(self.bprops.classification_psets): if len(self.bprops.classification_psets):
use_only_ifc_properties = self.bprops.use_only_ifc_properties
for pset in self.bprops.classification_psets: for pset in self.bprops.classification_psets:
properties = pset.properties
if use_only_ifc_properties:
properties = [p for p in properties if p.metadata == "IFC"]
if not properties:
continue
box = self.layout.box() box = self.layout.box()
row = box.row() row = box.row()
row.label(text=pset.name, icon="COPY_ID") row.label(text=pset.name, icon="COPY_ID")
bonsai.bim.helper.draw_attributes(pset.properties, box) bonsai.bim.helper.draw_attributes(properties, box)
def draw_add_file_ui(self, context): def draw_add_file_ui(self, context):
if not self.data.data["active_classification_library"]: if not self.data.data["active_classification_library"]:
+2
View File
@@ -254,6 +254,7 @@ class Attribute(PropertyGroup):
display_name: StringProperty(name="Display Name", get=get_display_name) display_name: StringProperty(name="Display Name", get=get_display_name)
description: StringProperty(name="Description") description: StringProperty(name="Description")
ifc_class: StringProperty(name="Ifc Class") ifc_class: StringProperty(name="Ifc Class")
# TODO: make it enum
data_type: StringProperty(name="Data Type") data_type: StringProperty(name="Data Type")
string_value: StringProperty(name="Value", update=update_attribute_value, description=tooltip) string_value: StringProperty(name="Value", update=update_attribute_value, description=tooltip)
bool_value: BoolProperty(name="Value", update=update_attribute_value, description=tooltip) bool_value: BoolProperty(name="Value", update=update_attribute_value, description=tooltip)
@@ -288,6 +289,7 @@ class Attribute(PropertyGroup):
value_max: FloatProperty(description="This is used to validate int_value and float_value") value_max: FloatProperty(description="This is used to validate int_value and float_value")
value_max_constraint: BoolProperty(default=False, description="True if the numerical value has an upper bound") value_max_constraint: BoolProperty(default=False, description="True if the numerical value has an upper bound")
special_type: StringProperty(name="Special Value Type", default="") special_type: StringProperty(name="Special Value Type", default="")
metadata: StringProperty(name="Metadata", description="For storing some additional information about the attribute")
def get_value(self): def get_value(self):
if self.is_optional and self.is_null: if self.is_optional and self.is_null:
+5 -5
View File
@@ -37,9 +37,10 @@ class Bsdd(bonsai.core.tool.Bsdd):
new2.enum_items = json.dumps(data["possible_values"]) new2.enum_items = json.dumps(data["possible_values"])
new2.data_type = "enum" new2.data_type = "enum"
else: else:
new2.data_type = data_type_map[data["data_type"]] new2.data_type = data_type_map.get(data["data_type"], "string")
new2.description = data["description"] new2.description = data["description"]
new2.ifc_class = data["ifc_class"] new2.ifc_class = data["ifc_class"]
new2.metadata = data["dictionary"]
@classmethod @classmethod
def create_classes(cls, class_dict: list[bsdd.ClassSearchResponseClassContractV1]) -> None: def create_classes(cls, class_dict: list[bsdd.ClassSearchResponseClassContractV1]) -> None:
@@ -96,9 +97,7 @@ class Bsdd(bonsai.core.tool.Bsdd):
psets = {} psets = {}
for prop in properties: for prop in properties:
# prop is ClassPropertyContract. prop_dictionary = prop.get("propertyDictionaryName") or ""
if prop.get("propertyDictionaryName") != "IFC":
continue
pset = prop.get("propertySet", None) pset = prop.get("propertySet", None)
if not pset: if not pset:
continue continue
@@ -116,10 +115,11 @@ class Bsdd(bonsai.core.tool.Bsdd):
# so name should be exact. Fallback to name as propertyCode is nullable. # so name should be exact. Fallback to name as propertyCode is nullable.
prop_name = prop.get("propertyCode") or prop["name"] prop_name = prop.get("propertyCode") or prop["name"]
psets[pset][prop_name] = { psets[pset][prop_name] = {
"data_type": prop["dataType"], "data_type": prop.get("dataType"),
"possible_values": possible_values, "possible_values": possible_values,
"description": description, "description": description,
"ifc_class": ifc_class, "ifc_class": ifc_class,
"dictionary": prop_dictionary,
} }
return psets return psets