mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Work schedule psets are now supported, so you can set work day/week/month durations
This commit is contained in:
@@ -34,12 +34,14 @@ classes = (
|
||||
prop.TaskPsetProperties,
|
||||
prop.ResourcePsetProperties,
|
||||
prop.ProfilePsetProperties,
|
||||
prop.WorkSchedulePsetProperties,
|
||||
ui.BIM_PT_object_psets,
|
||||
ui.BIM_PT_object_qtos,
|
||||
ui.BIM_PT_material_psets,
|
||||
ui.BIM_PT_task_qtos,
|
||||
ui.BIM_PT_resource_qtos,
|
||||
ui.BIM_PT_profile_psets,
|
||||
ui.BIM_PT_work_schedule_psets,
|
||||
)
|
||||
|
||||
|
||||
@@ -49,6 +51,7 @@ def register():
|
||||
bpy.types.Scene.TaskPsetProperties = bpy.props.PointerProperty(type=prop.TaskPsetProperties)
|
||||
bpy.types.Scene.ResourcePsetProperties = bpy.props.PointerProperty(type=prop.ResourcePsetProperties)
|
||||
bpy.types.Scene.ProfilePsetProperties = bpy.props.PointerProperty(type=prop.ProfilePsetProperties)
|
||||
bpy.types.Scene.WorkSchedulePsetProperties = bpy.props.PointerProperty(type=prop.WorkSchedulePsetProperties)
|
||||
|
||||
|
||||
def unregister():
|
||||
@@ -57,3 +60,4 @@ def unregister():
|
||||
del bpy.types.Scene.TaskPsetProperties
|
||||
del bpy.types.Scene.ResourcePsetProperties
|
||||
del bpy.types.Scene.ProfilePsetProperties
|
||||
del bpy.types.Scene.WorkSchedulePsetProperties
|
||||
|
||||
@@ -43,6 +43,8 @@ def get_pset_props(context, obj, obj_type):
|
||||
return context.scene.ResourcePsetProperties
|
||||
elif obj_type == "Profile":
|
||||
return context.scene.ProfilePsetProperties
|
||||
elif obj_type == "WorkSchedule":
|
||||
return context.scene.WorkSchedulePsetProperties
|
||||
|
||||
|
||||
def get_pset_obj_ifc_definition_id(context, obj, obj_type):
|
||||
@@ -64,7 +66,8 @@ def get_pset_obj_ifc_definition_id(context, obj, obj_type):
|
||||
return context.scene.BIMProfileProperties.profiles[
|
||||
context.scene.BIMProfileProperties.active_profile_index
|
||||
].ifc_definition_id
|
||||
|
||||
elif obj_type == "WorkSchedule":
|
||||
return context.scene.BIMWorkScheduleProperties.active_work_schedule_id
|
||||
|
||||
|
||||
class TogglePsetExpansion(bpy.types.Operator):
|
||||
|
||||
@@ -101,6 +101,15 @@ def getProfilePsetNames(self, context):
|
||||
return psetnames[ifc_class]
|
||||
|
||||
|
||||
def getWorkSchedulePsetNames(self, context):
|
||||
global psetnames
|
||||
ifc_class = "IfcWorkSchedule"
|
||||
if ifc_class not in psetnames:
|
||||
psets = blenderbim.bim.schema.ifc.psetqto.get_applicable(ifc_class, pset_only=True)
|
||||
psetnames[ifc_class] = [(p.Name, p.Name, "") for p in psets]
|
||||
return psetnames[ifc_class]
|
||||
|
||||
|
||||
def getQtoNames(self, context):
|
||||
global qtonames
|
||||
if "/" in context.active_object.name:
|
||||
@@ -146,3 +155,10 @@ class ProfilePsetProperties(PropertyGroup):
|
||||
active_pset_name: StringProperty(name="Pset Name")
|
||||
properties: CollectionProperty(name="Properties", type=Attribute)
|
||||
pset_name: EnumProperty(items=getProfilePsetNames, name="Pset Name")
|
||||
|
||||
|
||||
class WorkSchedulePsetProperties(PropertyGroup):
|
||||
active_pset_id: IntProperty(name="Active Pset ID")
|
||||
active_pset_name: StringProperty(name="Pset Name")
|
||||
properties: CollectionProperty(name="Properties", type=Attribute)
|
||||
pset_name: EnumProperty(items=getWorkSchedulePsetNames, name="Pset Name")
|
||||
|
||||
@@ -332,3 +332,33 @@ class BIM_PT_profile_psets(Panel):
|
||||
psets = [(pset_id, Data.psets[pset_id]) for pset_id in Data.products[ifc_definition_id]["psets"]]
|
||||
for pset_id, pset in sorted(psets, key=lambda v: v[1]["Name"]):
|
||||
draw_psetqto_ui(context, pset_id, pset, props, self.layout, "Profile")
|
||||
|
||||
|
||||
class BIM_PT_work_schedule_psets(Panel):
|
||||
bl_label = "IFC Work Schedule Property Sets"
|
||||
bl_idname = "BIM_PT_work_schedule_psets"
|
||||
bl_space_type = "PROPERTIES"
|
||||
bl_region_type = "WINDOW"
|
||||
bl_context = "scene"
|
||||
bl_parent_id = "BIM_PT_work_schedules"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
props = context.scene.BIMWorkScheduleProperties
|
||||
if not context.scene.BIMWorkScheduleProperties.active_work_schedule_id:
|
||||
return False
|
||||
return True
|
||||
|
||||
def draw(self, context):
|
||||
props = context.scene.WorkSchedulePsetProperties
|
||||
ifc_definition_id = context.scene.BIMWorkScheduleProperties.active_work_schedule_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, "pset_name", text="")
|
||||
op = row.operator("bim.add_pset", icon="ADD", text="")
|
||||
op.obj_type = "WorkSchedule"
|
||||
|
||||
psets = [(pset_id, Data.psets[pset_id]) for pset_id in Data.products[ifc_definition_id]["psets"]]
|
||||
for pset_id, pset in sorted(psets, key=lambda v: v[1]["Name"]):
|
||||
draw_psetqto_ui(context, pset_id, pset, props, self.layout, "WorkSchedule")
|
||||
|
||||
Reference in New Issue
Block a user