mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
feature to select a resource in resource tree from task ICOM list
This commit is contained in:
@@ -20,38 +20,39 @@ import bpy
|
||||
from . import ui, prop, operator
|
||||
|
||||
classes = (
|
||||
operator.DisableResourceEditingUI,
|
||||
operator.DisableEditingResource,
|
||||
operator.EnableEditingResource,
|
||||
operator.LoadResources,
|
||||
operator.AddResource,
|
||||
operator.AddResourceQuantity,
|
||||
operator.EditResource,
|
||||
operator.RemoveResource,
|
||||
operator.RemoveResourceQuantity,
|
||||
operator.LoadResourceProperties,
|
||||
operator.ExpandResource,
|
||||
operator.ContractResource,
|
||||
operator.AssignResource,
|
||||
operator.UnassignResource,
|
||||
operator.EnableEditingResourceTime,
|
||||
operator.EnableEditingResourceQuantity,
|
||||
operator.EnableEditingResourceBaseQuantity,
|
||||
operator.EnableEditingResourceCosts,
|
||||
operator.EnableEditingResourceCostValueFormula,
|
||||
operator.EnableEditingResourceCostValue,
|
||||
operator.EditResourceTime,
|
||||
operator.EditResourceQuantity,
|
||||
operator.CalculateResourceWork,
|
||||
operator.ConstrainResourceWork,
|
||||
operator.ContractResource,
|
||||
operator.DisableEditingResource,
|
||||
operator.DisableEditingResourceCostValue,
|
||||
operator.DisableEditingResourceQuantity,
|
||||
operator.DisableEditingResourceTime,
|
||||
operator.DisableResourceEditingUI,
|
||||
operator.EditProductivityData,
|
||||
operator.EditResource,
|
||||
operator.EditResourceCostValue,
|
||||
operator.EditResourceCostValueFormula,
|
||||
operator.DisableEditingResourceTime,
|
||||
operator.DisableEditingResourceQuantity,
|
||||
operator.DisableEditingResourceCostValue,
|
||||
operator.CalculateResourceWork,
|
||||
operator.EditResourceQuantity,
|
||||
operator.EditResourceTime,
|
||||
operator.EnableEditingResource,
|
||||
operator.EnableEditingResourceBaseQuantity,
|
||||
operator.EnableEditingResourceCosts,
|
||||
operator.EnableEditingResourceCostValue,
|
||||
operator.EnableEditingResourceCostValueFormula,
|
||||
operator.EnableEditingResourceQuantity,
|
||||
operator.EnableEditingResourceTime,
|
||||
operator.ExpandResource,
|
||||
operator.GoToResource,
|
||||
operator.ImportResources,
|
||||
operator.EditProductivityData,
|
||||
operator.ConstrainResourceWork,
|
||||
operator.LoadResourceProperties,
|
||||
operator.LoadResources,
|
||||
operator.RemoveResource,
|
||||
operator.RemoveResourceQuantity,
|
||||
operator.RemoveUsageConstraint,
|
||||
operator.UnassignResource,
|
||||
prop.Resource,
|
||||
prop.BIMResourceProperties,
|
||||
prop.BIMResourceTreeProperties,
|
||||
|
||||
@@ -389,3 +389,15 @@ class RemoveUsageConstraint(bpy.types.Operator, tool.Ifc.Operator):
|
||||
core.remove_usage_constraint(
|
||||
tool.Ifc, tool.Resource, resource=tool.Ifc.get().by_id(self.resource), reference_path=self.attribute
|
||||
)
|
||||
|
||||
|
||||
class GoToResource(bpy.types.Operator):
|
||||
bl_idname = "bim.go_to_resource"
|
||||
bl_label = "Go To Resource"
|
||||
bl_description = "Selects the resource in the Resource Panel"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
resource: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
core.go_to_resource(tool.Resource, resource=tool.Ifc.get().by_id(self.resource))
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -214,3 +214,6 @@ def remove_usage_constraint(ifc, resource_tool, resource, reference_path):
|
||||
ifc.run("constraint.remove_metric", metric=metric)
|
||||
ifc.run("constraint.unassign_constraint", product=resource, constraint=constraint)
|
||||
ifc.run("constraint.remove_constraint", constraint=constraint)
|
||||
|
||||
def go_to_resource(resource_tool, resource):
|
||||
resource_tool.go_to_resource(resource)
|
||||
|
||||
@@ -601,7 +601,10 @@ class Resource:
|
||||
def enable_editing_resource_time(cls, resource): pass
|
||||
def enable_editing_resource(cls, resource): pass
|
||||
def expand_resource(cls, resource): pass
|
||||
def get_constraints(cls, resource): pass
|
||||
def get_highlighted_resource(cls): pass
|
||||
def get_metric_reference(cls, metric, is_deep): pass
|
||||
def get_metrics(cls, constraint): pass
|
||||
def get_productivity_attributes(cls): pass
|
||||
def get_productivity(cls, resource, should_inherit): pass
|
||||
def get_resource_attributes(cls): pass
|
||||
@@ -610,6 +613,9 @@ class Resource:
|
||||
def get_resource_quantity_attributes(cls): pass
|
||||
def get_resource_time_attributes(cls): pass
|
||||
def get_resource_time(cls, resource): pass
|
||||
def go_to_resource(cls, resource): pass
|
||||
def has_metric_constraint(cls, resource, attribute): pass
|
||||
def has_usage_metric(cls, resource): pass
|
||||
def import_resources(cls, file_path): pass
|
||||
def load_cost_value_attributes(cls, cost_value): pass
|
||||
def load_productivity_data(cls): pass
|
||||
@@ -617,11 +623,6 @@ class Resource:
|
||||
def load_resource_properties(cls): pass
|
||||
def load_resource_time_attributes(cls, resource_time): pass
|
||||
def load_resources(cls): pass
|
||||
def get_constraints(cls, resource): pass
|
||||
def get_metrics(cls, constraint): pass
|
||||
def get_metric_reference(cls, metric, is_deep): pass
|
||||
def has_metric_constraint(cls, resource, attribute): pass
|
||||
def has_usage_metric(cls, resource): pass
|
||||
|
||||
|
||||
@interface
|
||||
|
||||
@@ -279,6 +279,8 @@ class Resource(blenderbim.core.tool.Resource):
|
||||
def expand_resource(cls, resource):
|
||||
props = bpy.context.scene.BIMResourceProperties
|
||||
contracted_resources = json.loads(props.contracted_resources)
|
||||
if not resource.id() in contracted_resources:
|
||||
return
|
||||
contracted_resources.remove(resource.id())
|
||||
props.contracted_resources = json.dumps(contracted_resources)
|
||||
|
||||
@@ -410,4 +412,26 @@ class Resource(blenderbim.core.tool.Resource):
|
||||
"resource.add_resource_time",
|
||||
resource=resource,
|
||||
)
|
||||
tool.Ifc.run("resource.edit_resource_time", resource_time=resource.Usage, attributes=attributes)
|
||||
tool.Ifc.run("resource.edit_resource_time", resource_time=resource.Usage, attributes=attributes)
|
||||
|
||||
@classmethod
|
||||
def go_to_resource(cls, resource):
|
||||
def get_ancestors_ids(resource):
|
||||
ids = []
|
||||
for rel in resource.Nests or []:
|
||||
ids.append(rel.RelatingObject.id())
|
||||
ids.extend(get_ancestors_ids(rel.RelatingObject))
|
||||
return ids
|
||||
|
||||
ancestors = get_ancestors_ids(resource)
|
||||
contracted_resources = json.loads(bpy.context.scene.BIMResourceProperties.contracted_resources)
|
||||
for ancestor in ancestors:
|
||||
if ancestor in contracted_resources:
|
||||
contracted_resources.remove(ancestor)
|
||||
bpy.context.scene.BIMResourceProperties.contracted_resources = json.dumps(contracted_resources)
|
||||
cls.load_resources()
|
||||
cls.load_resource_properties()
|
||||
|
||||
resource_props = bpy.context.scene.BIMResourceTreeProperties
|
||||
expanded_resources = [item.ifc_definition_id for item in resource_props.resources]
|
||||
bpy.context.scene.BIMResourceProperties.active_resource_index = expanded_resources.index(resource.id())
|
||||
|
||||
Reference in New Issue
Block a user