mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 10:11:46 +00:00
You can now convert ArchiCAD spaces across multiple stories to Revit rooms
This commit is contained in:
@@ -82,7 +82,8 @@ class ExecuteIfcPatch(bpy.types.Operator):
|
|||||||
|
|
||||||
output = ifcpatch.execute(
|
output = ifcpatch.execute(
|
||||||
{
|
{
|
||||||
"input": ifcopenshell.open(props.ifc_patch_input),
|
"input": props.ifc_patch_input,
|
||||||
|
"file": ifcopenshell.open(props.ifc_patch_input),
|
||||||
"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"),
|
||||||
|
|||||||
@@ -37,8 +37,10 @@ def execute(args):
|
|||||||
:param args: A dictionary of arguments, corresponding to the parameters
|
:param args: A dictionary of arguments, corresponding to the parameters
|
||||||
listed subsequent to this in this docstring.
|
listed subsequent to this in this docstring.
|
||||||
:type args: dict
|
:type args: dict
|
||||||
:param input: An IFC model to apply the patch recipe to.
|
:param input: A filepath to the incoming IFC file.
|
||||||
:type input: ifcopenshell.file.file
|
:type input: str
|
||||||
|
:param file: An IFC model to apply the patch recipe to.
|
||||||
|
:type file: ifcopenshell.file.file
|
||||||
:param recipe: The name of the recipe. This is the same as the filename of
|
:param recipe: The name of the recipe. This is the same as the filename of
|
||||||
the recipe. E.g. "ExtractElements".
|
the recipe. E.g. "ExtractElements".
|
||||||
:type recipe: str
|
:type recipe: str
|
||||||
@@ -57,7 +59,8 @@ def execute(args):
|
|||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
output = ifcpatch.execute({
|
output = ifcpatch.execute({
|
||||||
"input": ifcopenshell.open("input.ifc"),
|
"input": "input.ifc",
|
||||||
|
"file": ifcopenshell.open("input.ifc"),
|
||||||
"recipe": "ExtractElements",
|
"recipe": "ExtractElements",
|
||||||
"arguments": [".IfcWall"],
|
"arguments": [".IfcWall"],
|
||||||
})
|
})
|
||||||
@@ -70,9 +73,9 @@ def execute(args):
|
|||||||
recipes = getattr(__import__("ifcpatch.recipes.{}".format(args["recipe"])), "recipes")
|
recipes = getattr(__import__("ifcpatch.recipes.{}".format(args["recipe"])), "recipes")
|
||||||
recipe = getattr(recipes, args["recipe"])
|
recipe = getattr(recipes, args["recipe"])
|
||||||
if recipe.Patcher.__init__.__doc__ is not None:
|
if recipe.Patcher.__init__.__doc__ is not None:
|
||||||
patcher = recipe.Patcher(args["input"], ifc_file, logger, *args["arguments"])
|
patcher = recipe.Patcher(args["input"], args["file"], logger, *args["arguments"])
|
||||||
else:
|
else:
|
||||||
patcher = recipe.Patcher(args["input"], ifc_file, logger, args["arguments"])
|
patcher = recipe.Patcher(args["input"], args["file"], logger, args["arguments"])
|
||||||
patcher.patch()
|
patcher.patch()
|
||||||
output = getattr(patcher, "file_patched", patcher.file)
|
output = getattr(patcher, "file_patched", patcher.file)
|
||||||
return output
|
return output
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ parser.add_argument("-a", "--arguments", nargs="+", help="Specify custom argumen
|
|||||||
args = vars(parser.parse_args())
|
args = vars(parser.parse_args())
|
||||||
|
|
||||||
print("# Loading IFC file ...")
|
print("# Loading IFC file ...")
|
||||||
args["input"] = ifcopenshell.open(args["input"])
|
args["file"] = ifcopenshell.open(args["input"])
|
||||||
|
|
||||||
print("# Patching ...")
|
print("# Patching ...")
|
||||||
output = ifcpatch.execute(args)
|
output = ifcpatch.execute(args)
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ class Patcher:
|
|||||||
|
|
||||||
def patch(self):
|
def patch(self):
|
||||||
import bpy
|
import bpy
|
||||||
|
import blenderbim.tool as tool
|
||||||
|
import ifcopenshell
|
||||||
|
import ifcopenshell.util.element
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
from mathutils import Vector, Matrix
|
from mathutils import Vector, Matrix
|
||||||
|
|
||||||
@@ -59,14 +62,16 @@ class Patcher:
|
|||||||
)
|
)
|
||||||
wall.matrix_world.translation = new_origin
|
wall.matrix_world.translation = new_origin
|
||||||
|
|
||||||
for obj in bpy.context.visible_objects:
|
|
||||||
if "IfcBuildingStorey" in obj.name and len(bpy.data.collections.get(obj.name).children) > 0:
|
|
||||||
target_z = obj.location.z
|
|
||||||
|
|
||||||
for obj in bpy.context.visible_objects:
|
for obj in bpy.context.visible_objects:
|
||||||
bpy.context.view_layer.update()
|
bpy.context.view_layer.update()
|
||||||
if "IfcSpace" not in obj.name:
|
if "IfcSpace" not in obj.name:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
element = tool.Ifc.get_entity(obj)
|
||||||
|
storey = ifcopenshell.util.element.get_aggregate(element)
|
||||||
|
storey_obj = tool.Ifc.get_object(storey)
|
||||||
|
target_z = storey_obj.location.z
|
||||||
|
|
||||||
local_target_z = (obj.matrix_world.inverted() @ Vector((0, 0, target_z))).z
|
local_target_z = (obj.matrix_world.inverted() @ Vector((0, 0, target_z))).z
|
||||||
local_target_zup = (obj.matrix_world.inverted() @ Vector((0, 0, target_z + 3))).z
|
local_target_zup = (obj.matrix_world.inverted() @ Vector((0, 0, target_z + 3))).z
|
||||||
for v in obj.data.vertices:
|
for v in obj.data.vertices:
|
||||||
@@ -79,7 +84,7 @@ class Patcher:
|
|||||||
bpy.ops.bim.update_representation(
|
bpy.ops.bim.update_representation(
|
||||||
ifc_representation_class="IfcExtrudedAreaSolid/IfcArbitraryProfileDefWithVoids"
|
ifc_representation_class="IfcExtrudedAreaSolid/IfcArbitraryProfileDefWithVoids"
|
||||||
)
|
)
|
||||||
for context in IfcStore.get_file().by_type("IfcGeometricRepresentationContext"):
|
for context in IfcStore.get_file().by_type("IfcGeometricRepresentationContext", include_subtypes=False):
|
||||||
if context.Precision:
|
if context.Precision:
|
||||||
context.Precision = 10
|
context.Precision = 10
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user