mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
You can now switch contexts of of objects in bulk
This commit is contained in:
@@ -97,15 +97,29 @@ class SwitchRepresentation(bpy.types.Operator, Operator):
|
|||||||
should_switch_all_meshes: bpy.props.BoolProperty()
|
should_switch_all_meshes: bpy.props.BoolProperty()
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
core.switch_representation(
|
target = tool.Ifc.get().by_id(self.ifc_definition_id).ContextOfItems
|
||||||
tool.Geometry,
|
is_subcontext = target.is_a("IfcGeometricRepresentationSubContext")
|
||||||
obj=bpy.data.objects.get(self.obj) if self.obj else context.active_object,
|
for obj in context.selected_objects:
|
||||||
representation=tool.Ifc.get().by_id(self.ifc_definition_id),
|
element = tool.Ifc.get_entity(obj)
|
||||||
should_reload=self.should_reload,
|
if not element:
|
||||||
enable_dynamic_voids=self.disable_opening_subtractions,
|
continue
|
||||||
is_global=self.should_switch_all_meshes,
|
if is_subcontext:
|
||||||
should_sync_changes_first=True,
|
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):
|
class RemoveRepresentation(bpy.types.Operator, Operator):
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
import os
|
import os
|
||||||
import bpy
|
import bpy
|
||||||
import json
|
import json
|
||||||
|
import ifcopenshell
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
import blenderbim.core.patch as core
|
import blenderbim.core.patch as core
|
||||||
import blenderbim.bim.handler
|
import blenderbim.bim.handler
|
||||||
@@ -79,15 +80,15 @@ class ExecuteIfcPatch(bpy.types.Operator):
|
|||||||
else:
|
else:
|
||||||
arguments = [arg.get_value() for arg in props.ifc_patch_args_attr]
|
arguments = [arg.get_value() for arg in props.ifc_patch_args_attr]
|
||||||
|
|
||||||
ifcpatch.execute(
|
output = ifcpatch.execute(
|
||||||
{
|
{
|
||||||
"input": props.ifc_patch_input,
|
"input": ifcopenshell.open(props.ifc_patch_input),
|
||||||
"output": props.ifc_patch_output,
|
|
||||||
"recipe": props.ifc_patch_recipes,
|
"recipe": props.ifc_patch_recipes,
|
||||||
"arguments": arguments,
|
"arguments": arguments,
|
||||||
"log": os.path.join(context.scene.BIMProperties.data_dir, "process.log"),
|
"log": os.path.join(context.scene.BIMProperties.data_dir, "process.log"),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
ifcpatch.write(output, props.ifc_patch_output)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import bpy
|
import bpy
|
||||||
|
import ifcopenshell
|
||||||
import blenderbim.core.tool
|
import blenderbim.core.tool
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
|
|
||||||
@@ -31,4 +32,5 @@ class Patch(blenderbim.core.tool.Patch):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def run_migrate_patch(cls, infile, outfile, schema):
|
def run_migrate_patch(cls, infile, outfile, schema):
|
||||||
log = os.path.join(bpy.context.scene.BIMProperties.data_dir, "process.log")
|
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 set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||||
And I press "bim.assign_class"
|
And I press "bim.assign_class"
|
||||||
And the object "IfcWall/Cube" is selected
|
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_start" to "01/01/21"
|
||||||
And I set "scene.BIMWorkScheduleProperties.visualisation_finish" to "01/02/21"
|
And I set "scene.BIMWorkScheduleProperties.visualisation_finish" to "01/02/21"
|
||||||
And I set "scene.BIMWorkScheduleProperties.speed_types" to "FRAME_SPEED"
|
And I set "scene.BIMWorkScheduleProperties.speed_types" to "FRAME_SPEED"
|
||||||
|
|||||||
@@ -14,22 +14,17 @@ Pre-built packages
|
|||||||
|
|
||||||
1. Download the appropriate version for your operating system.
|
1. Download the appropriate version for your operating system.
|
||||||
|
|
||||||
+----------------+----------------+----------------+----------------+
|
+----------------+----------------+----------------+----------------+------------------+
|
||||||
| Linux 64bit | Windows 32bit | Windows 64bit | MacOS 64bit |
|
| Linux 64bit | Windows 32bit | Windows 64bit | MacOS 64bit | MacOS M1 64bit |
|
||||||
+================+================+================+================+
|
+================+================+================+================+==================+
|
||||||
| build-linux64_ | build-win32_ | build-win64_ | build-macos64_ |
|
| build-linux64_ | build-win32_ | build-win64_ | build-macos64_ | build-macosm164_ |
|
||||||
+----------------+----------------+----------------+----------------+
|
+----------------+----------------+----------------+----------------+------------------+
|
||||||
|
|
||||||
.. _build-linux64: https://s3.amazonaws.com/ifcopenshell-builds/IfcConvert-v0.7.0-dc67287-linux64.zip
|
.. _build-linux64: https://s3.amazonaws.com/ifcopenshell-builds/IfcConvert-v0.7.0-4fb910f-linux64.zip
|
||||||
.. _build-win32: https://s3.amazonaws.com/ifcopenshell-builds/IfcConvert-v0.7.0-dc67287-win32.zip
|
.. _build-win32: https://s3.amazonaws.com/ifcopenshell-builds/IfcConvert-v0.7.0-4fb910f-win32.zip
|
||||||
.. _build-win64: https://s3.amazonaws.com/ifcopenshell-builds/IfcConvert-v0.7.0-dc67287-win64.zip
|
.. _build-win64: https://s3.amazonaws.com/ifcopenshell-builds/IfcConvert-v0.7.0-4fb910f-win64.zip
|
||||||
.. _build-macos64: https://s3.amazonaws.com/ifcopenshell-builds/IfcConvert-v0.7.0-dc67287-macos64.zip
|
.. _build-macos64: https://s3.amazonaws.com/ifcopenshell-builds/IfcConvert-v0.7.0-4fb910f-macos64.zip
|
||||||
|
.. _build-macosm164: https://s3.amazonaws.com/ifcopenshell-builds/IfcConvert-v0.7.0-4fb910f-macosm164.zip
|
||||||
.. warning::
|
|
||||||
|
|
||||||
Versions for Mac ARM devices (M1 chip) are not yet available. You are free to
|
|
||||||
compile it yourself manually, but this requires a level of technical
|
|
||||||
expertise.
|
|
||||||
|
|
||||||
2. Unzip the downloaded file and run IfcConvert using the command line.
|
2. Unzip the downloaded file and run IfcConvert using the command line.
|
||||||
|
|
||||||
|
|||||||
@@ -56,11 +56,12 @@ Here is a minimal example of how to use IfcDiff as a library:
|
|||||||
|
|
||||||
import ifcpatch
|
import ifcpatch
|
||||||
|
|
||||||
ifcpatch.execute({
|
output = ifcpatch.execute({
|
||||||
"input": ifcopenshell.open("input.ifc"),
|
"input": ifcopenshell.open("input.ifc"),
|
||||||
"recipe": "ExtractElements",
|
"recipe": "ExtractElements",
|
||||||
"arguments": [".IfcWall"],
|
"arguments": [".IfcWall"],
|
||||||
})
|
})
|
||||||
|
ifcpatch.write(output, "output.ifc")
|
||||||
|
|
||||||
You can also alias it to a command:
|
You can also alias it to a command:
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,19 @@ def execute(args):
|
|||||||
else:
|
else:
|
||||||
patcher = recipe.Patcher(args["input"], ifc_file, logger, args["arguments"])
|
patcher = recipe.Patcher(args["input"], ifc_file, logger, args["arguments"])
|
||||||
patcher.patch()
|
patcher.patch()
|
||||||
return getattr(patcher, "file_patched", patcher.file)
|
output = getattr(patcher, "file_patched", patcher.file)
|
||||||
|
if isinstance(output, str):
|
||||||
|
with open(args["output"], "w") as text_file:
|
||||||
|
text_file.write(output)
|
||||||
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
def write(output, filepath):
|
||||||
|
if isinstance(output, str):
|
||||||
|
with open(filepath, "w") as text_file:
|
||||||
|
text_file.write(output)
|
||||||
|
else:
|
||||||
|
output.write(filepath)
|
||||||
|
|
||||||
|
|
||||||
def extract_docs(
|
def extract_docs(
|
||||||
|
|||||||
@@ -34,15 +34,11 @@ print("# Loading IFC file ...")
|
|||||||
args["input"] = ifcopenshell.open(args["input"])
|
args["input"] = ifcopenshell.open(args["input"])
|
||||||
|
|
||||||
print("# Patching ...")
|
print("# Patching ...")
|
||||||
ifc_file = ifcpatch.execute(args)
|
output = ifcpatch.execute(args)
|
||||||
|
|
||||||
print("# Writing patched file ...")
|
print("# Writing patched file ...")
|
||||||
if not args["output"]:
|
if not args["output"]:
|
||||||
args["output"] = args["input"]
|
args["output"] = args["input"]
|
||||||
if isinstance(ifc_file, str):
|
ifcpatch.write(output, args["output"])
|
||||||
with open(args["output"], "w") as text_file:
|
|
||||||
text_file.write(ifc_file)
|
|
||||||
else:
|
|
||||||
ifc_file.write(args["output"])
|
|
||||||
|
|
||||||
print("# All tasks are complete :-)")
|
print("# All tasks are complete :-)")
|
||||||
|
|||||||
Reference in New Issue
Block a user