mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 06:32:09 +00:00
Update to IfcResources panel and authoring subtypes of IfcConstructionResource with ifcopenshell.api
This commit is contained in:
@@ -16,7 +16,7 @@ classes = (
|
||||
operator.RemoveResource,
|
||||
operator.EnableEditingNestedResource,
|
||||
operator.LoadNestedResourceProperties,
|
||||
operator.DisableNestedResourceEditingUI,
|
||||
# operator.DisableNestedResourceEditingUI,
|
||||
prop.Resource,
|
||||
prop.BIMResourceProperties,
|
||||
prop.BIMResourceTreeProperties,
|
||||
|
||||
@@ -37,9 +37,9 @@ class EnableEditingResource(bpy.types.Operator):
|
||||
|
||||
def enable_editing_resource(self):
|
||||
data = Data.resources[self.resource]
|
||||
for attribute in IfcStore.get_schema().declaration_by_name("IfcResource").all_attributes():
|
||||
for attribute in IfcStore.get_schema().declaration_by_name("IfcCrewResource").all_attributes():
|
||||
data_type = ifcopenshell.util.attribute.get_primitive_type(attribute)
|
||||
if data_type == "entity":
|
||||
if data_type == "entity" or isinstance(data_type, tuple):
|
||||
continue
|
||||
new = self.props.resource_attributes.add()
|
||||
new.name = attribute.name()
|
||||
@@ -113,6 +113,7 @@ class DisableEditingResource(bpy.types.Operator):
|
||||
context.scene.BIMResourceProperties.active_resource_id = 0
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class DisableResourceEditingUI(bpy.types.Operator):
|
||||
bl_idname = "bim.disable_resource_editing_ui"
|
||||
bl_label = "Disable Resources Editing UI"
|
||||
@@ -121,13 +122,6 @@ class DisableResourceEditingUI(bpy.types.Operator):
|
||||
context.scene.BIMResourceProperties.is_loaded = False
|
||||
return {"FINISHED"}
|
||||
|
||||
class DisableNestedResourceEditingUI(bpy.types.Operator):
|
||||
bl_idname = "bim.disable_nested_resource_editing_ui"
|
||||
bl_label = "Disable Task Editing UI"
|
||||
|
||||
def execute(self, context):
|
||||
context.scene.BIMNestedResourceProperties.is_editing = False
|
||||
return {"FINISHED"}
|
||||
|
||||
class AddSubcontractResource(bpy.types.Operator):
|
||||
bl_idname = "bim.add_subcontract_resource"
|
||||
@@ -166,13 +160,13 @@ class AddCrewResource(bpy.types.Operator):
|
||||
|
||||
|
||||
class AddEquipementResource(bpy.types.Operator):
|
||||
bl_idname = "bim.add_equipement_resource"
|
||||
bl_idname = "bim.add_equipment_resource"
|
||||
bl_label = "Add Equipement Resource"
|
||||
resource: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
ifcopenshell.api.run(
|
||||
"resource.add_equipement_resource",
|
||||
"resource.add_equipment_resource",
|
||||
IfcStore.get_file(),
|
||||
resource=IfcStore.get_file().by_id(self.resource)
|
||||
)
|
||||
@@ -229,7 +223,7 @@ class EditResource(bpy.types.Operator):
|
||||
def execute(self, context):
|
||||
props = context.scene.BIMResourceProperties
|
||||
attributes = {}
|
||||
for attribute in props.cost_resource_attributes:
|
||||
for attribute in props.nested_resource_attributes:
|
||||
if attribute.is_null:
|
||||
attributes[attribute.name] = None
|
||||
else:
|
||||
|
||||
@@ -16,6 +16,8 @@ from bpy.props import (
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
class Resource(PropertyGroup):
|
||||
name: StringProperty(name="Name")
|
||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||
@@ -23,16 +25,18 @@ class Resource(PropertyGroup):
|
||||
is_expanded: BoolProperty(name="Is Expanded")
|
||||
level_index: IntProperty(name="Level Index")
|
||||
|
||||
class BIMResourceTreeProperties(PropertyGroup):
|
||||
nested_resources: CollectionProperty(name="nested_resources", type=Resource)
|
||||
|
||||
class BIMResourceProperties(PropertyGroup):
|
||||
resource_attributes: CollectionProperty(name="Resource Attributes", type=Attribute)
|
||||
is_editing: BoolProperty(name="Is Editing")
|
||||
is_editing: StringProperty(name="Is Editing")
|
||||
active_resource_index: IntProperty(name="Active Resource Index")
|
||||
active_resource_id: IntProperty(name="Active Resource Id")
|
||||
active_resource_index: 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)
|
||||
is_loaded: BoolProperty(name="Is Editing")
|
||||
active_nested_resource_id: IntProperty(name="Active Nested Ressource Id")
|
||||
active_nested_resource_index: IntProperty(name="Active Nested Resource Index")
|
||||
nested_resource_attributes: CollectionProperty(name="Nested Resource Attributes", type=Attribute)
|
||||
contracted_nested_resources: StringProperty(name="Contracted Cost Items", default="[]")
|
||||
|
||||
@@ -21,7 +21,6 @@ class BIM_PT_resources(Panel):
|
||||
if self.props.is_loaded:
|
||||
row.operator("bim.disable_resource_editing_ui", text="CANCEL EDITING RESOURCES", icon="CANCEL")
|
||||
else:
|
||||
row = self.layout.row()
|
||||
row.operator("bim.load_resources", text="Load Resources", icon="GREASEPENCIL")
|
||||
|
||||
if not Data.is_loaded:
|
||||
@@ -37,18 +36,23 @@ class BIM_PT_resources(Panel):
|
||||
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:
|
||||
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_equipement_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")
|
||||
row.operator("bim.disable_nested_resource_editing_ui", text="", icon="CANCEL")
|
||||
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
|
||||
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.remove_resource", text="", icon="X").resource = resource_id
|
||||
|
||||
if self.props.active_resource_id == resource_id:
|
||||
if self.props.is_editing == "RESOURCE":
|
||||
@@ -57,7 +61,7 @@ class BIM_PT_resources(Panel):
|
||||
self.draw_editable_nested_resource_ui(resource_id)
|
||||
|
||||
def draw_editable_resource_ui(self):
|
||||
for attribute in self.props.resources:
|
||||
for attribute in self.props.resource_attributes:
|
||||
row = self.layout.row(align=True)
|
||||
if attribute.data_type == "string":
|
||||
row.prop(attribute, "string_value", text=attribute.name)
|
||||
|
||||
Reference in New Issue
Block a user