mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 22:43:41 +00:00
Code review with myoualid for IFC resource module
This commit is contained in:
@@ -6,22 +6,17 @@ classes = (
|
||||
operator.DisableEditingResource,
|
||||
operator.EnableEditingResource,
|
||||
operator.LoadResources,
|
||||
operator.AddCrewResource,
|
||||
operator.AddSubcontractResource,
|
||||
operator.AddEquipementResource,
|
||||
operator.AddLaborResource,
|
||||
operator.AddProductResource,
|
||||
operator.AddMaterialResource,
|
||||
operator.AddResource,
|
||||
operator.EditResource,
|
||||
operator.RemoveResource,
|
||||
operator.EnableEditingNestedResource,
|
||||
operator.LoadNestedResourceProperties,
|
||||
# operator.DisableNestedResourceEditingUI,
|
||||
operator.LoadResourceProperties,
|
||||
operator.ExpandResource,
|
||||
operator.ContractResource,
|
||||
prop.Resource,
|
||||
prop.BIMResourceProperties,
|
||||
prop.BIMResourceTreeProperties,
|
||||
ui.BIM_PT_resources,
|
||||
ui.BIM_UL_nested_resources,
|
||||
ui.BIM_UL_resources,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -7,20 +7,37 @@ from ifcopenshell.api.resource.data import Data
|
||||
|
||||
class LoadResources(bpy.types.Operator):
|
||||
bl_idname = "bim.load_resources"
|
||||
bl_label = "Load Work Plans"
|
||||
bl_label = "Load Resources"
|
||||
|
||||
def execute(self, context):
|
||||
props = context.scene.BIMResourceProperties
|
||||
while len(props.resources) > 0:
|
||||
props.resources.remove(0)
|
||||
for ifc_definition_id, resource in Data.resources.items():
|
||||
new = props.resources.add()
|
||||
new.ifc_definition_id = ifc_definition_id
|
||||
new.name = resource["Name"] or "Unnamed"
|
||||
props.is_loaded = True
|
||||
bpy.ops.bim.disable_editing_resource()
|
||||
self.props = context.scene.BIMResourceProperties
|
||||
self.tprops = context.scene.BIMResourceTreeProperties
|
||||
while len(self.tprops.resources) > 0:
|
||||
self.tprops.resources.remove(0)
|
||||
|
||||
self.contracted_resources = json.loads(self.props.contracted_resources)
|
||||
for resource_id, data in Data.resources.items():
|
||||
if not data["HasContext"]:
|
||||
continue
|
||||
self.create_new_resource_li(resource_id, 0)
|
||||
bpy.ops.bim.load_resource_properties()
|
||||
self.props.is_editing = True
|
||||
return {"FINISHED"}
|
||||
|
||||
def create_new_resource_li(self, related_object_id, level_index):
|
||||
resource = Data.resources[related_object_id]
|
||||
new = self.tprops.resources.add()
|
||||
new.ifc_definition_id = related_object_id
|
||||
new.is_expanded = related_object_id not in self.contracted_resources
|
||||
new.level_index = level_index
|
||||
if resource["RelatedObjects"]:
|
||||
new.has_children = True
|
||||
if new.is_expanded:
|
||||
for related_object_id in resource["RelatedObjects"]:
|
||||
self.create_new_resource_li(related_object_id, level_index + 1)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class EnableEditingResource(bpy.types.Operator):
|
||||
bl_idname = "bim.enable_editing_resource"
|
||||
bl_label = "Enable Editing Resource"
|
||||
@@ -32,12 +49,11 @@ class EnableEditingResource(bpy.types.Operator):
|
||||
while len(self.props.resource_attributes) > 0:
|
||||
self.props.resource_attributes.remove(0)
|
||||
self.enable_editing_resource()
|
||||
self.props.is_editing = "RESOURCE"
|
||||
return {"FINISHED"}
|
||||
|
||||
def enable_editing_resource(self):
|
||||
data = Data.resources[self.resource]
|
||||
for attribute in IfcStore.get_schema().declaration_by_name("IfcCrewResource").all_attributes():
|
||||
for attribute in IfcStore.get_schema().declaration_by_name(data["type"]).all_attributes():
|
||||
data_type = ifcopenshell.util.attribute.get_primitive_type(attribute)
|
||||
if data_type == "entity" or isinstance(data_type, tuple):
|
||||
continue
|
||||
@@ -54,54 +70,21 @@ class EnableEditingResource(bpy.types.Operator):
|
||||
new.enum_value = data[attribute.name()]
|
||||
|
||||
|
||||
class EnableEditingNestedResource(bpy.types.Operator):
|
||||
bl_idname = "bim.enable_editing_nested_resources"
|
||||
bl_label = "Enable Editing Nested Resource"
|
||||
class LoadResourceProperties(bpy.types.Operator):
|
||||
bl_idname = "bim.load_resource_properties"
|
||||
bl_label = "Load Resource Properties"
|
||||
resource: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
self.props = context.scene.BIMResourceProperties
|
||||
self.tprops = context.scene.BIMResourceTreeProperties
|
||||
self.props.active_resource_id = self.resource
|
||||
while len(self.tprops.nested_resources) > 0:
|
||||
self.tprops.nested_resources.remove(0)
|
||||
|
||||
self.contracted_nested_resources = json.loads(self.props.contracted_nested_resources)
|
||||
for related_object_id in Data.resources[self.resource]["RelatedObjects"]:
|
||||
self.create_new_nested_resource_li(related_object_id, 0)
|
||||
bpy.ops.bim.load_nested_resource_properties()
|
||||
self.props.is_editing = "NESTED_RESOURCE"
|
||||
return {"FINISHED"}
|
||||
|
||||
def create_new_nested_resource_li(self, related_object_id, level_index):
|
||||
nested_resource = Data.nested_resources[related_object_id]
|
||||
new = self.tprops.nested_resources.add()
|
||||
new.ifc_definition_id = related_object_id
|
||||
new.is_expanded = related_object_id not in self.contracted_nested_resources
|
||||
new.level_index = level_index
|
||||
if nested_resource["RelatedObjects"]:
|
||||
new.has_children = True
|
||||
if new.is_expanded:
|
||||
for related_object_id in nested_resource["RelatedObjects"]:
|
||||
self.create_new_nested_resource_li(related_object_id, level_index + 1)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class LoadNestedResourceProperties(bpy.types.Operator):
|
||||
bl_idname = "bim.load_nested_resource_properties"
|
||||
bl_label = "Load nested_resource Properties"
|
||||
nested_resource: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
self.props = context.scene.BIMResourceProperties
|
||||
self.tprops = context.scene.BIMResourceTreeProperties
|
||||
self.props.is_nested_resource_update_enabled = False
|
||||
for item in self.tprops.nested_resources:
|
||||
if self.nested_resource and item.ifc_definition_id != self.nested_resource:
|
||||
self.props.is_resource_update_enabled = False
|
||||
for item in self.tprops.resources:
|
||||
if self.resource and item.ifc_definition_id != self.resource:
|
||||
continue
|
||||
nested_resource = Data.nested_resources[item.ifc_definition_id]
|
||||
item.name = nested_resource["Name"] or "Unnamed"
|
||||
self.props.is_nested_resource_update_enabled = True
|
||||
resource = Data.resources[item.ifc_definition_id]
|
||||
item.name = resource["Name"] or "Unnamed"
|
||||
self.props.is_resource_update_enabled = True
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -119,102 +102,27 @@ class DisableResourceEditingUI(bpy.types.Operator):
|
||||
bl_label = "Disable Resources Editing UI"
|
||||
|
||||
def execute(self, context):
|
||||
context.scene.BIMResourceProperties.is_loaded = False
|
||||
context.scene.BIMResourceProperties.is_editing = False
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AddSubcontractResource(bpy.types.Operator):
|
||||
bl_idname = "bim.add_subcontract_resource"
|
||||
bl_label = "Add Subcontract Resource"
|
||||
class AddResource(bpy.types.Operator):
|
||||
bl_idname = "bim.add_resource"
|
||||
bl_label = "Add resource"
|
||||
ifc_class: bpy.props.StringProperty()
|
||||
resource: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
if self.resource:
|
||||
ifcopenshell.api.run(
|
||||
"resource.add_subcontract_resource",
|
||||
ifcopenshell.api.run(
|
||||
"resource.add_resource",
|
||||
IfcStore.get_file(),
|
||||
resource=IfcStore.get_file().by_id(self.resource)
|
||||
)
|
||||
else:
|
||||
ifcopenshell.api.run("resource.add_subcontract_resource", IfcStore.get_file())
|
||||
Data.load(IfcStore.get_file())
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AddCrewResource(bpy.types.Operator):
|
||||
bl_idname = "bim.add_crew_resource"
|
||||
bl_label = "Add Crew Resource"
|
||||
resource: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
if self.resource:
|
||||
ifcopenshell.api.run(
|
||||
"resource.add_crew_resource",
|
||||
IfcStore.get_file(),
|
||||
resource=IfcStore.get_file().by_id(self.resource)
|
||||
)
|
||||
else:
|
||||
ifcopenshell.api.run("resource.add_crew_resource", IfcStore.get_file())
|
||||
Data.load(IfcStore.get_file())
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AddEquipementResource(bpy.types.Operator):
|
||||
bl_idname = "bim.add_equipment_resource"
|
||||
bl_label = "Add Equipement Resource"
|
||||
resource: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
ifcopenshell.api.run(
|
||||
"resource.add_equipment_resource",
|
||||
IfcStore.get_file(),
|
||||
resource=IfcStore.get_file().by_id(self.resource)
|
||||
parent_resource=IfcStore.get_file().by_id(self.resource) if self.resource else None,
|
||||
ifc_class=self.ifc_class,
|
||||
)
|
||||
Data.load(IfcStore.get_file())
|
||||
bpy.ops.bim.load_resources()
|
||||
return {"FINISHED"}
|
||||
|
||||
class AddLaborResource(bpy.types.Operator):
|
||||
bl_idname = "bim.add_labor_resource"
|
||||
bl_label = "Add Labor Resource"
|
||||
resource: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
ifcopenshell.api.run(
|
||||
"resource.add_labor_resource",
|
||||
IfcStore.get_file(),
|
||||
resource=IfcStore.get_file().by_id(self.resource)
|
||||
)
|
||||
Data.load(IfcStore.get_file())
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AddMaterialResource(bpy.types.Operator):
|
||||
bl_idname = "bim.add_material_resource"
|
||||
bl_label = "Add Material Resource"
|
||||
resource: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
ifcopenshell.api.run(
|
||||
"resource.add_material_resource",
|
||||
IfcStore.get_file(),
|
||||
resource=IfcStore.get_file().by_id(self.resource)
|
||||
)
|
||||
Data.load(IfcStore.get_file())
|
||||
return {"FINISHED"}
|
||||
|
||||
class AddProductResource(bpy.types.Operator):
|
||||
bl_idname = "bim.add_product_resource"
|
||||
bl_label = "Add Product Resource"
|
||||
resource: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
ifcopenshell.api.run(
|
||||
"resource.add_product_resource",
|
||||
IfcStore.get_file(),
|
||||
resource=IfcStore.get_file().by_id(self.resource)
|
||||
)
|
||||
Data.load(IfcStore.get_file())
|
||||
return {"FINISHED"}
|
||||
|
||||
class EditResource(bpy.types.Operator):
|
||||
bl_idname = "bim.edit_resource"
|
||||
@@ -223,7 +131,7 @@ class EditResource(bpy.types.Operator):
|
||||
def execute(self, context):
|
||||
props = context.scene.BIMResourceProperties
|
||||
attributes = {}
|
||||
for attribute in props.nested_resource_attributes:
|
||||
for attribute in props.resource_attributes:
|
||||
if attribute.is_null:
|
||||
attributes[attribute.name] = None
|
||||
else:
|
||||
@@ -238,6 +146,7 @@ class EditResource(bpy.types.Operator):
|
||||
**{"resource": self.file.by_id(props.active_resource_id), "attributes": attributes},
|
||||
)
|
||||
Data.load(IfcStore.get_file())
|
||||
bpy.ops.bim.load_resource_properties(resource=props.active_resource_id)
|
||||
bpy.ops.bim.disable_editing_resource()
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -254,4 +163,37 @@ class RemoveResource(bpy.types.Operator):
|
||||
resource=IfcStore.get_file().by_id(self.resource),
|
||||
)
|
||||
Data.load(IfcStore.get_file())
|
||||
bpy.ops.bim.load_resources()
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class ExpandResource(bpy.types.Operator):
|
||||
bl_idname = "bim.expand_resource"
|
||||
bl_label = "Expand Resource"
|
||||
resource: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
props = context.scene.BIMResourceProperties
|
||||
self.file = IfcStore.get_file()
|
||||
contracted_resources = json.loads(props.contracted_resources)
|
||||
contracted_resources.remove(self.resource)
|
||||
props.contracted_resources = json.dumps(contracted_resources)
|
||||
Data.load(self.file)
|
||||
bpy.ops.bim.load_resources()
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class ContractResource(bpy.types.Operator):
|
||||
bl_idname = "bim.contract_resource"
|
||||
bl_label = "Contract Resource"
|
||||
resource: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
props = context.scene.BIMResourceProperties
|
||||
self.file = IfcStore.get_file()
|
||||
contracted_resources = json.loads(props.contracted_resources)
|
||||
contracted_resources.append(self.resource)
|
||||
props.contracted_resources = json.dumps(contracted_resources)
|
||||
Data.load(self.file)
|
||||
bpy.ops.bim.load_resources()
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -16,27 +16,39 @@ from bpy.props import (
|
||||
)
|
||||
|
||||
|
||||
def updateResourceName(self, context):
|
||||
props = context.scene.BIMResourceProperties
|
||||
if not props.is_resource_update_enabled or self.name == "Unnamed":
|
||||
return
|
||||
self.file = IfcStore.get_file()
|
||||
ifcopenshell.api.run(
|
||||
"resource.edit_resource",
|
||||
self.file,
|
||||
**{"resource": self.file.by_id(self.ifc_definition_id), "attributes": {"Name": self.name}},
|
||||
)
|
||||
Data.load(IfcStore.get_file())
|
||||
if props.active_resource_id == self.ifc_definition_id:
|
||||
attribute = props.resource_attributes.get("Name")
|
||||
attribute.string_value = self.name
|
||||
|
||||
|
||||
class Resource(PropertyGroup):
|
||||
name: StringProperty(name="Name")
|
||||
name: StringProperty(name="Name", update=updateResourceName)
|
||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||
has_children: BoolProperty(name="Has Children")
|
||||
is_expanded: BoolProperty(name="Is Expanded")
|
||||
level_index: IntProperty(name="Level Index")
|
||||
|
||||
|
||||
class BIMResourceTreeProperties(PropertyGroup):
|
||||
nested_resources: CollectionProperty(name="nested_resources", type=Resource)
|
||||
resources: CollectionProperty(name="Resources", type=Resource)
|
||||
|
||||
|
||||
class BIMResourceProperties(PropertyGroup):
|
||||
resource_attributes: CollectionProperty(name="Resource Attributes", type=Attribute)
|
||||
is_editing: StringProperty(name="Is Editing")
|
||||
is_editing: BoolProperty(name="Is Editing")
|
||||
active_resource_index: IntProperty(name="Active Resource Index")
|
||||
active_resource_id: IntProperty(name="Active Resource Id")
|
||||
active_nested_resource_index: IntProperty(name="Active nested_resource Index")
|
||||
active_nested_resource_id: IntProperty(name="Active nested_resource Id")
|
||||
nested_resource_attributes: CollectionProperty(name="nested_resource Attributes", type=Attribute)
|
||||
contracted_nested_resources: StringProperty(name="Contracted nested_resource Items", default="[]")
|
||||
is_nested_resource_update_enabled: BoolProperty(name="Is nested_resource Update Enabled", default=True)
|
||||
resources: CollectionProperty(name="Resource", type=Resource)
|
||||
contracted_resources: StringProperty(name="Contracted Resources", default="[]")
|
||||
is_resource_update_enabled: BoolProperty(name="Is Resource Update Enabled", default=True)
|
||||
is_loaded: BoolProperty(name="Is Editing")
|
||||
|
||||
@@ -2,6 +2,7 @@ from bpy.types import Panel, UIList
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from ifcopenshell.api.resource.data import Data
|
||||
|
||||
|
||||
class BIM_PT_resources(Panel):
|
||||
bl_label = "IFC Resources"
|
||||
bl_idname = "BIM_PT_resources"
|
||||
@@ -17,48 +18,54 @@ class BIM_PT_resources(Panel):
|
||||
def draw(self, context):
|
||||
self.props = context.scene.BIMResourceProperties
|
||||
self.tprops = context.scene.BIMResourceTreeProperties
|
||||
row = self.layout.row()
|
||||
if self.props.is_loaded:
|
||||
row.operator("bim.disable_resource_editing_ui", text="CANCEL EDITING RESOURCES", icon="CANCEL")
|
||||
else:
|
||||
row.operator("bim.load_resources", text="Load Resources", icon="GREASEPENCIL")
|
||||
|
||||
if not Data.is_loaded:
|
||||
Data.load(IfcStore.get_file())
|
||||
if self.props.is_loaded:
|
||||
row = self.layout.row(align=True)
|
||||
row.operator("bim.add_subcontract_resource", text="Add Subcontract", icon="FILE_TICK")
|
||||
row.operator("bim.add_crew_resource", text="Add Crew", icon="COMMUNITY")
|
||||
for resource_id, resource in Data.resources.items():
|
||||
self.draw_resource_ui(resource_id, resource)
|
||||
|
||||
def draw_resource_ui(self, resource_id, resource):
|
||||
row = self.layout.row()
|
||||
row.label(text=resource["Name"] or "Unnamed", icon="BOOKMARKS")
|
||||
if self.props.active_resource_id and self.props.active_resource_id == resource_id:
|
||||
if self.props.is_editing == "RESOURCE":
|
||||
row.operator("bim.edit_resource", text="", icon="CHECKMARK")
|
||||
elif self.props.is_editing == "NESTED_RESOURCE":
|
||||
row.operator("bim.add_subcontract_resource", text="", icon="FILE_TICK").resource = resource_id
|
||||
row.operator("bim.add_crew_resource", text="", icon="COMMUNITY").resource = resource_id
|
||||
row.operator("bim.add_equipment_resource", text="", icon="TOOL_SETTINGS").resource = resource_id
|
||||
row.operator("bim.add_labor_resource", text="", icon="ARMATURE_DATA").resource = resource_id
|
||||
row.operator("bim.add_material_resource", text="", icon="MATERIAL").resource = resource_id
|
||||
row.operator("bim.add_product_resource", text="", icon="PACKAGE").resource = resource_id
|
||||
row.operator("bim.edit_resource", text="", icon="CHECKMARK")#.resource = resource_id
|
||||
#TODO add if statement in operator for editing resource so that it doesnt toggle the wrong panel
|
||||
row.operator("bim.disable_editing_resource", text="", icon="CANCEL")
|
||||
elif self.props.active_resource_id:
|
||||
row.operator("bim.remove_resource", text="", icon="X").resource = resource_id
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text=f"{len(Data.resources)} Resources Found")
|
||||
if self.props.is_editing:
|
||||
row.operator("bim.disable_resource_editing_ui", text="", icon="CANCEL")
|
||||
else:
|
||||
row.operator("bim.enable_editing_nested_resources", text="", icon="ACTION").resource = resource_id
|
||||
row.operator("bim.enable_editing_resource", text="", icon="GREASEPENCIL").resource = resource_id
|
||||
row.operator("bim.load_resources", text="", icon="GREASEPENCIL")
|
||||
|
||||
if self.props.active_resource_id == resource_id:
|
||||
if self.props.is_editing == "RESOURCE":
|
||||
self.draw_editable_resource_ui()
|
||||
elif self.props.is_editing == "NESTED_RESOURCE":
|
||||
self.draw_editable_nested_resource_ui(resource_id)
|
||||
if not self.props.is_editing:
|
||||
return
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
op = row.operator("bim.add_resource", text="Add SubContract", icon="FILE_TICK")
|
||||
op.ifc_class = "IfcSubContractResource"
|
||||
op.resource = 0
|
||||
op = row.operator("bim.add_resource", text="Add Crew", icon="COMMUNITY")
|
||||
op.ifc_class = "IfcCrewResource"
|
||||
op.resource = 0
|
||||
|
||||
icon_map = {
|
||||
"IfcConstructionEquipmentResource": "TOOL_SETTINGS",
|
||||
"IfcLaborResource": "OUTLINER_OB_ARMATURE",
|
||||
"IfcConstructionMaterialResource": "MATERIAL",
|
||||
"IfcConstructionProductResource": "PACKAGE",
|
||||
}
|
||||
|
||||
total_resources = len(self.tprops.resources)
|
||||
if total_resources and self.props.active_resource_index < total_resources:
|
||||
row = self.layout.row(align=True)
|
||||
for ifc_class, icon in icon_map.items():
|
||||
label = ifc_class.replace("Ifc", "").replace("Construction", "").replace("Resource", "")
|
||||
op = row.operator("bim.add_resource", text=label, icon=icon)
|
||||
op.resource = self.tprops.resources[self.props.active_resource_index].ifc_definition_id
|
||||
op.ifc_class = ifc_class
|
||||
|
||||
self.layout.template_list(
|
||||
"BIM_UL_resources",
|
||||
"",
|
||||
self.tprops,
|
||||
"resources",
|
||||
self.props,
|
||||
"active_resource_index",
|
||||
)
|
||||
if self.props.active_resource_id:
|
||||
self.draw_editable_resource_ui()
|
||||
|
||||
def draw_editable_resource_ui(self):
|
||||
for attribute in self.props.resource_attributes:
|
||||
@@ -76,36 +83,18 @@ class BIM_PT_resources(Panel):
|
||||
if attribute.is_optional:
|
||||
row.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="")
|
||||
|
||||
def draw_editable_nested_resource_ui(self, resource_id):
|
||||
self.layout.template_list(
|
||||
"BIM_UL_nested_resources",
|
||||
"",
|
||||
self.tprops,
|
||||
"nested_resources",
|
||||
self.props,
|
||||
"active_nested_resource_index",
|
||||
)
|
||||
if self.props.active_nested_resource_id:
|
||||
self.draw_editable_nested_resource_attributes_ui()
|
||||
|
||||
|
||||
def draw_editable_nested_resource_attributes_ui(self):
|
||||
for attribute in self.props.nested_resource_attributes:
|
||||
row = self.layout.row(align=True)
|
||||
if attribute.data_type == "string":
|
||||
row.prop(attribute, "string_value", text=attribute.name)
|
||||
elif attribute.data_type == "boolean":
|
||||
row.prop(attribute, "bool_value", text=attribute.name)
|
||||
elif attribute.data_type == "integer":
|
||||
row.prop(attribute, "int_value", text=attribute.name)
|
||||
elif attribute.data_type == "enum":
|
||||
row.prop(attribute, "enum_value", text=attribute.name)
|
||||
if attribute.is_optional:
|
||||
row.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="")
|
||||
|
||||
|
||||
class BIM_UL_nested_resources(UIList):
|
||||
class BIM_UL_resources(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
resource = Data.resources[item.ifc_definition_id]
|
||||
icon_map = {
|
||||
"IfcSubContractResource": "FILE_TICK",
|
||||
"IfcCrewResource": "COMMUNITY",
|
||||
"IfcConstructionEquipmentResource": "TOOL_SETTINGS",
|
||||
"IfcLaborResource": "OUTLINER_OB_ARMATURE",
|
||||
"IfcConstructionMaterialResource": "MATERIAL",
|
||||
"IfcConstructionProductResource": "PACKAGE",
|
||||
}
|
||||
if item:
|
||||
props = context.scene.BIMResourceProperties
|
||||
row = layout.row(align=True)
|
||||
@@ -114,21 +103,25 @@ class BIM_UL_nested_resources(UIList):
|
||||
if item.has_children:
|
||||
if item.is_expanded:
|
||||
row.operator(
|
||||
"bim.contract_nested_resource", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN"
|
||||
).nested_resource = item.ifc_definition_id
|
||||
"bim.contract_resource", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN"
|
||||
).resource = item.ifc_definition_id
|
||||
else:
|
||||
row.operator(
|
||||
"bim.expand_nested_resource", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT"
|
||||
).nested_resource = item.ifc_definition_id
|
||||
|
||||
if props.active_nested_resource_id == item.ifc_definition_id:
|
||||
row.operator("bim.edit_nested_resource", text="", icon="CHECKMARK")
|
||||
row.operator("bim.disable_editing_nested_resource", text="", icon="CANCEL")
|
||||
elif props.active_nested_resource_id:
|
||||
row.operator("bim.add_nested_resource", text="", icon="ADD").nested_resource = item.ifc_definition_id
|
||||
row.operator("bim.remove_nested_resource", text="", icon="X").nested_resource = item.ifc_definition_id
|
||||
"bim.expand_resource", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT"
|
||||
).resource = item.ifc_definition_id
|
||||
else:
|
||||
row.operator("bim.enable_editing_nested_resource_time", text="", icon="TIME").nested_resource = item.ifc_definition_id
|
||||
row.operator("bim.enable_editing_nested_resource", text="", icon="GREASEPENCIL").nested_resource = item.ifc_definition_id
|
||||
row.operator("bim.add_nested_resource", text="", icon="ADD").nested_resource = item.ifc_definition_id
|
||||
row.operator("bim.remove_nested_resource", text="", icon="X").nested_resource = item.ifc_definition_id
|
||||
row.label(text="", icon="DOT")
|
||||
row.prop(item, "name", emboss=False, text="", icon=icon_map[resource["type"]])
|
||||
|
||||
if props.active_resource_id == item.ifc_definition_id:
|
||||
row.operator("bim.edit_resource", text="", icon="CHECKMARK")
|
||||
row.operator("bim.disable_editing_resource", text="", icon="CANCEL")
|
||||
elif props.active_resource_id:
|
||||
row.operator("bim.add_resource", text="", icon="ADD").resource = item.ifc_definition_id
|
||||
row.operator("bim.remove_resource", text="", icon="X").resource = item.ifc_definition_id
|
||||
else:
|
||||
row.operator(
|
||||
"bim.enable_editing_resource", text="", icon="GREASEPENCIL"
|
||||
).resource = item.ifc_definition_id
|
||||
|
||||
row.operator("bim.remove_resource", text="", icon="X").resource = item.ifc_definition_id
|
||||
|
||||
Reference in New Issue
Block a user