mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 22:31:55 +00:00
constraint.assign_constraint - support batching #4474
This commit is contained in:
@@ -179,17 +179,15 @@ class AssignConstraint(bpy.types.Operator):
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
objs = [bpy.data.objects.get(self.obj)] if self.obj else context.selected_objects
|
||||
for obj in objs:
|
||||
obj_id = obj.BIMObjectProperties.ifc_definition_id
|
||||
if not obj_id:
|
||||
continue
|
||||
products = [self.file.by_id(obj_id) for obj in objs if (obj_id := obj.BIMObjectProperties.ifc_definition_id)]
|
||||
if products:
|
||||
ifcopenshell.api.run(
|
||||
"constraint.assign_constraint",
|
||||
self.file,
|
||||
**{
|
||||
"product": self.file.by_id(obj_id),
|
||||
"products": products,
|
||||
"constraint": self.file.by_id(self.constraint),
|
||||
},
|
||||
)
|
||||
|
||||
@@ -195,7 +195,7 @@ def add_usage_constraint(ifc, resource_tool, resource=None, reference_path=None)
|
||||
},
|
||||
)
|
||||
ifc.run("constraint.add_metric_reference", metric=metric, reference_path=reference_path)
|
||||
ifc.run("constraint.assign_constraint", product=resource, constraint=objective)
|
||||
ifc.run("constraint.assign_constraint", products=[resource], constraint=objective)
|
||||
|
||||
|
||||
def remove_usage_constraint(ifc, resource_tool, resource, reference_path):
|
||||
|
||||
Reference in New Issue
Block a user