mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +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
|
from . import ui, prop, operator
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
operator.DisableResourceEditingUI,
|
|
||||||
operator.DisableEditingResource,
|
|
||||||
operator.EnableEditingResource,
|
|
||||||
operator.LoadResources,
|
|
||||||
operator.AddResource,
|
operator.AddResource,
|
||||||
operator.AddResourceQuantity,
|
operator.AddResourceQuantity,
|
||||||
operator.EditResource,
|
|
||||||
operator.RemoveResource,
|
|
||||||
operator.RemoveResourceQuantity,
|
|
||||||
operator.LoadResourceProperties,
|
|
||||||
operator.ExpandResource,
|
|
||||||
operator.ContractResource,
|
|
||||||
operator.AssignResource,
|
operator.AssignResource,
|
||||||
operator.UnassignResource,
|
operator.CalculateResourceWork,
|
||||||
operator.EnableEditingResourceTime,
|
operator.ConstrainResourceWork,
|
||||||
operator.EnableEditingResourceQuantity,
|
operator.ContractResource,
|
||||||
operator.EnableEditingResourceBaseQuantity,
|
operator.DisableEditingResource,
|
||||||
operator.EnableEditingResourceCosts,
|
operator.DisableEditingResourceCostValue,
|
||||||
operator.EnableEditingResourceCostValueFormula,
|
operator.DisableEditingResourceQuantity,
|
||||||
operator.EnableEditingResourceCostValue,
|
operator.DisableEditingResourceTime,
|
||||||
operator.EditResourceTime,
|
operator.DisableResourceEditingUI,
|
||||||
operator.EditResourceQuantity,
|
operator.EditProductivityData,
|
||||||
|
operator.EditResource,
|
||||||
operator.EditResourceCostValue,
|
operator.EditResourceCostValue,
|
||||||
operator.EditResourceCostValueFormula,
|
operator.EditResourceCostValueFormula,
|
||||||
operator.DisableEditingResourceTime,
|
operator.EditResourceQuantity,
|
||||||
operator.DisableEditingResourceQuantity,
|
operator.EditResourceTime,
|
||||||
operator.DisableEditingResourceCostValue,
|
operator.EnableEditingResource,
|
||||||
operator.CalculateResourceWork,
|
operator.EnableEditingResourceBaseQuantity,
|
||||||
|
operator.EnableEditingResourceCosts,
|
||||||
|
operator.EnableEditingResourceCostValue,
|
||||||
|
operator.EnableEditingResourceCostValueFormula,
|
||||||
|
operator.EnableEditingResourceQuantity,
|
||||||
|
operator.EnableEditingResourceTime,
|
||||||
|
operator.ExpandResource,
|
||||||
|
operator.GoToResource,
|
||||||
operator.ImportResources,
|
operator.ImportResources,
|
||||||
operator.EditProductivityData,
|
operator.LoadResourceProperties,
|
||||||
operator.ConstrainResourceWork,
|
operator.LoadResources,
|
||||||
|
operator.RemoveResource,
|
||||||
|
operator.RemoveResourceQuantity,
|
||||||
operator.RemoveUsageConstraint,
|
operator.RemoveUsageConstraint,
|
||||||
|
operator.UnassignResource,
|
||||||
prop.Resource,
|
prop.Resource,
|
||||||
prop.BIMResourceProperties,
|
prop.BIMResourceProperties,
|
||||||
prop.BIMResourceTreeProperties,
|
prop.BIMResourceTreeProperties,
|
||||||
|
|||||||
@@ -389,3 +389,15 @@ class RemoveUsageConstraint(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
core.remove_usage_constraint(
|
core.remove_usage_constraint(
|
||||||
tool.Ifc, tool.Resource, resource=tool.Ifc.get().by_id(self.resource), reference_path=self.attribute
|
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.remove_metric", metric=metric)
|
||||||
ifc.run("constraint.unassign_constraint", product=resource, constraint=constraint)
|
ifc.run("constraint.unassign_constraint", product=resource, constraint=constraint)
|
||||||
ifc.run("constraint.remove_constraint", 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_time(cls, resource): pass
|
||||||
def enable_editing_resource(cls, resource): pass
|
def enable_editing_resource(cls, resource): pass
|
||||||
def expand_resource(cls, resource): pass
|
def expand_resource(cls, resource): pass
|
||||||
|
def get_constraints(cls, resource): pass
|
||||||
def get_highlighted_resource(cls): 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_attributes(cls): pass
|
||||||
def get_productivity(cls, resource, should_inherit): pass
|
def get_productivity(cls, resource, should_inherit): pass
|
||||||
def get_resource_attributes(cls): pass
|
def get_resource_attributes(cls): pass
|
||||||
@@ -610,6 +613,9 @@ class Resource:
|
|||||||
def get_resource_quantity_attributes(cls): pass
|
def get_resource_quantity_attributes(cls): pass
|
||||||
def get_resource_time_attributes(cls): pass
|
def get_resource_time_attributes(cls): pass
|
||||||
def get_resource_time(cls, resource): 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 import_resources(cls, file_path): pass
|
||||||
def load_cost_value_attributes(cls, cost_value): pass
|
def load_cost_value_attributes(cls, cost_value): pass
|
||||||
def load_productivity_data(cls): pass
|
def load_productivity_data(cls): pass
|
||||||
@@ -617,11 +623,6 @@ class Resource:
|
|||||||
def load_resource_properties(cls): pass
|
def load_resource_properties(cls): pass
|
||||||
def load_resource_time_attributes(cls, resource_time): pass
|
def load_resource_time_attributes(cls, resource_time): pass
|
||||||
def load_resources(cls): 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
|
@interface
|
||||||
|
|||||||
@@ -279,6 +279,8 @@ class Resource(blenderbim.core.tool.Resource):
|
|||||||
def expand_resource(cls, resource):
|
def expand_resource(cls, resource):
|
||||||
props = bpy.context.scene.BIMResourceProperties
|
props = bpy.context.scene.BIMResourceProperties
|
||||||
contracted_resources = json.loads(props.contracted_resources)
|
contracted_resources = json.loads(props.contracted_resources)
|
||||||
|
if not resource.id() in contracted_resources:
|
||||||
|
return
|
||||||
contracted_resources.remove(resource.id())
|
contracted_resources.remove(resource.id())
|
||||||
props.contracted_resources = json.dumps(contracted_resources)
|
props.contracted_resources = json.dumps(contracted_resources)
|
||||||
|
|
||||||
@@ -410,4 +412,26 @@ class Resource(blenderbim.core.tool.Resource):
|
|||||||
"resource.add_resource_time",
|
"resource.add_resource_time",
|
||||||
resource=resource,
|
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