You can now switch contexts of of objects in bulk

This commit is contained in:
Dion Moult
2022-09-19 15:59:37 +10:00
parent 57e8e47061
commit 18387e7732
8 changed files with 58 additions and 37 deletions
@@ -97,15 +97,29 @@ class SwitchRepresentation(bpy.types.Operator, Operator):
should_switch_all_meshes: bpy.props.BoolProperty()
def _execute(self, context):
core.switch_representation(
tool.Geometry,
obj=bpy.data.objects.get(self.obj) if self.obj else context.active_object,
representation=tool.Ifc.get().by_id(self.ifc_definition_id),
should_reload=self.should_reload,
enable_dynamic_voids=self.disable_opening_subtractions,
is_global=self.should_switch_all_meshes,
should_sync_changes_first=True,
)
target = tool.Ifc.get().by_id(self.ifc_definition_id).ContextOfItems
is_subcontext = target.is_a("IfcGeometricRepresentationSubContext")
for obj in context.selected_objects:
element = tool.Ifc.get_entity(obj)
if not element:
continue
if is_subcontext:
representation = ifcopenshell.util.representation.get_representation(
element, target.ContextType, target.ContextIdentifier, target.TargetView
)
else:
representation = ifcopenshell.util.representation.get_representation(element, target.ContextType)
if not representation:
continue
core.switch_representation(
tool.Geometry,
obj=obj,
representation=representation,
should_reload=self.should_reload,
enable_dynamic_voids=self.disable_opening_subtractions,
is_global=self.should_switch_all_meshes,
should_sync_changes_first=True,
)
class RemoveRepresentation(bpy.types.Operator, Operator):
@@ -19,6 +19,7 @@
import os
import bpy
import json
import ifcopenshell
import blenderbim.tool as tool
import blenderbim.core.patch as core
import blenderbim.bim.handler
@@ -79,15 +80,15 @@ class ExecuteIfcPatch(bpy.types.Operator):
else:
arguments = [arg.get_value() for arg in props.ifc_patch_args_attr]
ifcpatch.execute(
output = ifcpatch.execute(
{
"input": props.ifc_patch_input,
"output": props.ifc_patch_output,
"input": ifcopenshell.open(props.ifc_patch_input),
"recipe": props.ifc_patch_recipes,
"arguments": arguments,
"log": os.path.join(context.scene.BIMProperties.data_dir, "process.log"),
}
)
ifcpatch.write(output, props.ifc_patch_output)
return {"FINISHED"}
+3 -1
View File
@@ -18,6 +18,7 @@
import os
import bpy
import ifcopenshell
import blenderbim.core.tool
import blenderbim.tool as tool
@@ -31,4 +32,5 @@ class Patch(blenderbim.core.tool.Patch):
@classmethod
def run_migrate_patch(cls, infile, outfile, schema):
log = os.path.join(bpy.context.scene.BIMProperties.data_dir, "process.log")
ifcpatch.execute({"input": infile, "output": outfile, "recipe": "Migrate", "arguments": [schema], "log": log})
output = ifcpatch.execute({"input": ifcopenshell.open(infile), "recipe": "Migrate", "arguments": [schema]})
ifcpatch.write(output, outfile)
@@ -388,7 +388,7 @@ Scenario: Animate the demolition of a wall
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
And I press "bim.assign_class"
And the object "IfcWall/Cube" is selected
And I press "bim.assign_process(task={task}, related_object=0)"
And I press "bim.assign_process(task={task}, related_object=0, related_object_type='PRODUCT')"
And I set "scene.BIMWorkScheduleProperties.visualisation_start" to "01/01/21"
And I set "scene.BIMWorkScheduleProperties.visualisation_finish" to "01/02/21"
And I set "scene.BIMWorkScheduleProperties.speed_types" to "FRAME_SPEED"