mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
Implement resource quantity sets for parametric quantification
This commit is contained in:
@@ -13,10 +13,12 @@ classes = (
|
|||||||
prop.PsetProperties,
|
prop.PsetProperties,
|
||||||
prop.MaterialPsetProperties,
|
prop.MaterialPsetProperties,
|
||||||
prop.TaskPsetProperties,
|
prop.TaskPsetProperties,
|
||||||
|
prop.ResourcePsetProperties,
|
||||||
ui.BIM_PT_object_psets,
|
ui.BIM_PT_object_psets,
|
||||||
ui.BIM_PT_object_qtos,
|
ui.BIM_PT_object_qtos,
|
||||||
ui.BIM_PT_material_psets,
|
ui.BIM_PT_material_psets,
|
||||||
ui.BIM_PT_task_qtos,
|
ui.BIM_PT_task_qtos,
|
||||||
|
ui.BIM_PT_resource_qtos,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -24,9 +26,11 @@ def register():
|
|||||||
bpy.types.Object.PsetProperties = bpy.props.PointerProperty(type=prop.PsetProperties)
|
bpy.types.Object.PsetProperties = bpy.props.PointerProperty(type=prop.PsetProperties)
|
||||||
bpy.types.Material.PsetProperties = bpy.props.PointerProperty(type=prop.MaterialPsetProperties)
|
bpy.types.Material.PsetProperties = bpy.props.PointerProperty(type=prop.MaterialPsetProperties)
|
||||||
bpy.types.Scene.TaskPsetProperties = bpy.props.PointerProperty(type=prop.TaskPsetProperties)
|
bpy.types.Scene.TaskPsetProperties = bpy.props.PointerProperty(type=prop.TaskPsetProperties)
|
||||||
|
bpy.types.Scene.ResourcePsetProperties = bpy.props.PointerProperty(type=prop.ResourcePsetProperties)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
del bpy.types.Object.PsetProperties
|
del bpy.types.Object.PsetProperties
|
||||||
del bpy.types.Material.PsetProperties
|
del bpy.types.Material.PsetProperties
|
||||||
del bpy.types.Scene.TaskPsetProperties
|
del bpy.types.Scene.TaskPsetProperties
|
||||||
|
del bpy.types.Scene.ResourcePsetProperties
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ def get_pset_props(context, obj, obj_type):
|
|||||||
return obj.PsetProperties
|
return obj.PsetProperties
|
||||||
elif obj_type == "Task":
|
elif obj_type == "Task":
|
||||||
return context.scene.TaskPsetProperties
|
return context.scene.TaskPsetProperties
|
||||||
|
elif obj_type == "Resource":
|
||||||
|
return context.scene.ResourcePsetProperties
|
||||||
|
|
||||||
|
|
||||||
def get_pset_obj_ifc_definition_id(context, obj, obj_type):
|
def get_pset_obj_ifc_definition_id(context, obj, obj_type):
|
||||||
@@ -33,6 +35,10 @@ def get_pset_obj_ifc_definition_id(context, obj, obj_type):
|
|||||||
return context.scene.BIMTaskTreeProperties.tasks[
|
return context.scene.BIMTaskTreeProperties.tasks[
|
||||||
context.scene.BIMWorkScheduleProperties.active_task_index
|
context.scene.BIMWorkScheduleProperties.active_task_index
|
||||||
].ifc_definition_id
|
].ifc_definition_id
|
||||||
|
elif obj_type == "Resource":
|
||||||
|
return context.scene.BIMResourceTreeProperties.resources[
|
||||||
|
context.scene.BIMResourceProperties.active_resource_index
|
||||||
|
].ifc_definition_id
|
||||||
|
|
||||||
|
|
||||||
class TogglePsetExpansion(bpy.types.Operator):
|
class TogglePsetExpansion(bpy.types.Operator):
|
||||||
|
|||||||
@@ -61,6 +61,17 @@ def getTaskQtoNames(self, context):
|
|||||||
return qtonames[ifc_class]
|
return qtonames[ifc_class]
|
||||||
|
|
||||||
|
|
||||||
|
def getResourceQtoNames(self, context):
|
||||||
|
global qtonames
|
||||||
|
rprops = context.scene.BIMResourceProperties
|
||||||
|
rtprops = context.scene.BIMResourceTreeProperties
|
||||||
|
ifc_class = IfcStore.get_file().by_id(rtprops.resources[rprops.active_resource_index].ifc_definition_id).is_a()
|
||||||
|
if ifc_class not in qtonames:
|
||||||
|
psets = blenderbim.bim.schema.ifc.psetqto.get_applicable(ifc_class, qto_only=True)
|
||||||
|
qtonames[ifc_class] = [(p.Name, p.Name, "") for p in psets]
|
||||||
|
return qtonames[ifc_class]
|
||||||
|
|
||||||
|
|
||||||
def getQtoNames(self, context):
|
def getQtoNames(self, context):
|
||||||
global qtonames
|
global qtonames
|
||||||
if "/" in context.active_object.name:
|
if "/" in context.active_object.name:
|
||||||
@@ -92,3 +103,10 @@ class TaskPsetProperties(PropertyGroup):
|
|||||||
active_pset_name: StringProperty(name="Pset Name")
|
active_pset_name: StringProperty(name="Pset Name")
|
||||||
properties: CollectionProperty(name="Properties", type=Attribute)
|
properties: CollectionProperty(name="Properties", type=Attribute)
|
||||||
qto_name: EnumProperty(items=getTaskQtoNames, name="Qto Name")
|
qto_name: EnumProperty(items=getTaskQtoNames, name="Qto Name")
|
||||||
|
|
||||||
|
|
||||||
|
class ResourcePsetProperties(PropertyGroup):
|
||||||
|
active_pset_id: IntProperty(name="Active Pset ID")
|
||||||
|
active_pset_name: StringProperty(name="Pset Name")
|
||||||
|
properties: CollectionProperty(name="Properties", type=Attribute)
|
||||||
|
qto_name: EnumProperty(items=getResourceQtoNames, name="Qto Name")
|
||||||
|
|||||||
@@ -254,3 +254,36 @@ class BIM_PT_task_qtos(Panel):
|
|||||||
qtos = [(qto_id, Data.qtos[qto_id]) for qto_id in Data.products[ifc_definition_id]["qtos"]]
|
qtos = [(qto_id, Data.qtos[qto_id]) for qto_id in Data.products[ifc_definition_id]["qtos"]]
|
||||||
for qto_id, qto in sorted(qtos, key = lambda v: v[1]["Name"]):
|
for qto_id, qto in sorted(qtos, key = lambda v: v[1]["Name"]):
|
||||||
draw_psetqto_ui(context, qto_id, qto, props, self.layout, "Task")
|
draw_psetqto_ui(context, qto_id, qto, props, self.layout, "Task")
|
||||||
|
|
||||||
|
|
||||||
|
class BIM_PT_resource_qtos(Panel):
|
||||||
|
bl_label = "IFC Resource Quantity Sets"
|
||||||
|
bl_idname = "BIM_PT_resource_qtos"
|
||||||
|
bl_space_type = "PROPERTIES"
|
||||||
|
bl_region_type = "WINDOW"
|
||||||
|
bl_context = "scene"
|
||||||
|
bl_parent_id = "BIM_PT_resources"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
props = context.scene.BIMResourceProperties
|
||||||
|
total_resources = len(context.scene.BIMResourceTreeProperties.resources)
|
||||||
|
if total_resources > 0 and props.active_resource_index < total_resources:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
props = context.scene.ResourcePsetProperties
|
||||||
|
rprops = context.scene.BIMResourceProperties
|
||||||
|
rtprops = context.scene.BIMResourceTreeProperties
|
||||||
|
ifc_definition_id = rtprops.resources[rprops.active_resource_index].ifc_definition_id
|
||||||
|
if ifc_definition_id not in Data.products:
|
||||||
|
Data.load(IfcStore.get_file(), ifc_definition_id)
|
||||||
|
row = self.layout.row(align=True)
|
||||||
|
row.prop(props, "qto_name", text="")
|
||||||
|
op = row.operator("bim.add_qto", icon="ADD", text="")
|
||||||
|
op.obj_type = "Resource"
|
||||||
|
|
||||||
|
qtos = [(qto_id, Data.qtos[qto_id]) for qto_id in Data.products[ifc_definition_id]["qtos"]]
|
||||||
|
for qto_id, qto in sorted(qtos, key = lambda v: v[1]["Name"]):
|
||||||
|
draw_psetqto_ui(context, qto_id, qto, props, self.layout, "Resource")
|
||||||
|
|||||||
Reference in New Issue
Block a user