mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 22:11:36 +00:00
BBIM 4D: Auto Update Resource Usage from resource tree
This commit is contained in:
@@ -46,13 +46,12 @@ def purge():
|
|||||||
|
|
||||||
def updateResourceName(self, context):
|
def updateResourceName(self, context):
|
||||||
props = context.scene.BIMResourceProperties
|
props = context.scene.BIMResourceProperties
|
||||||
if not props.is_resource_update_enabled or self.name == "Unnamed":
|
if not props.is_resource_update_enabled:
|
||||||
return
|
return
|
||||||
self.file = IfcStore.get_file()
|
tool.Ifc.run(
|
||||||
ifcopenshell.api.run(
|
|
||||||
"resource.edit_resource",
|
"resource.edit_resource",
|
||||||
self.file,
|
resource=tool.Ifc.get().by_id(self.ifc_definition_id),
|
||||||
**{"resource": self.file.by_id(self.ifc_definition_id), "attributes": {"Name": self.name}},
|
attributes={"Name": self.name},
|
||||||
)
|
)
|
||||||
if props.active_resource_id == self.ifc_definition_id:
|
if props.active_resource_id == self.ifc_definition_id:
|
||||||
attribute = props.resource_attributes.get("Name")
|
attribute = props.resource_attributes.get("Name")
|
||||||
@@ -77,6 +76,24 @@ def update_active_resource_index(self, context):
|
|||||||
tool.Resource.load_productivity_data()
|
tool.Resource.load_productivity_data()
|
||||||
|
|
||||||
|
|
||||||
|
def updateResourceUsage(self, context):
|
||||||
|
props = context.scene.BIMResourceProperties
|
||||||
|
if not props.is_resource_update_enabled:
|
||||||
|
return
|
||||||
|
|
||||||
|
if self.schedule_usage == "":
|
||||||
|
return
|
||||||
|
resource = tool.Ifc.get().by_id(self.ifc_definition_id)
|
||||||
|
if not resource.Usage:
|
||||||
|
tool.Ifc.run(
|
||||||
|
"resource.add_resource_time",
|
||||||
|
resource=resource,
|
||||||
|
)
|
||||||
|
resource.Usage.ScheduleUsage = self.schedule_usage
|
||||||
|
blenderbim.bim.module.pset.data.refresh()
|
||||||
|
tool.Resource.load_resource_properties()
|
||||||
|
|
||||||
|
|
||||||
class ISODuration(PropertyGroup):
|
class ISODuration(PropertyGroup):
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name")
|
||||||
years: IntProperty(name="Years", default=0)
|
years: IntProperty(name="Years", default=0)
|
||||||
@@ -90,7 +107,7 @@ class ISODuration(PropertyGroup):
|
|||||||
class Resource(PropertyGroup):
|
class Resource(PropertyGroup):
|
||||||
name: StringProperty(name="Name", update=updateResourceName)
|
name: StringProperty(name="Name", update=updateResourceName)
|
||||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||||
schedule_usage: FloatProperty(name="Schedule Usage")
|
schedule_usage: FloatProperty(name="Schedule Usage", update=updateResourceUsage)
|
||||||
has_children: BoolProperty(name="Has Children")
|
has_children: BoolProperty(name="Has Children")
|
||||||
is_expanded: BoolProperty(name="Is Expanded")
|
is_expanded: BoolProperty(name="Is Expanded")
|
||||||
level_index: IntProperty(name="Level Index")
|
level_index: IntProperty(name="Level Index")
|
||||||
|
|||||||
Reference in New Issue
Block a user