mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 06:00:51 +00:00
Fix #2620. You can now run patches from models in memory.
This commit is contained in:
@@ -71,7 +71,7 @@ class ExecuteIfcPatch(bpy.types.Operator):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
input_file = context.scene.BIMPatchProperties.ifc_patch_input
|
input_file = context.scene.BIMPatchProperties.ifc_patch_input
|
||||||
return os.path.isfile(input_file) and "ifc" in os.path.splitext(input_file)[1].lower()
|
return input_file or context.scene.BIMPatchProperties.should_load_from_memory
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
props = context.scene.BIMPatchProperties
|
props = context.scene.BIMPatchProperties
|
||||||
@@ -80,10 +80,17 @@ 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]
|
||||||
|
|
||||||
|
if props.should_load_from_memory and tool.Ifc.get():
|
||||||
|
input_file = props.ifc_patch_input
|
||||||
|
file = tool.Ifc.get()
|
||||||
|
else:
|
||||||
|
input_file = props.ifc_patch_input
|
||||||
|
file = ifcopenshell.open(props.ifc_patch_input)
|
||||||
|
|
||||||
output = ifcpatch.execute(
|
output = ifcpatch.execute(
|
||||||
{
|
{
|
||||||
"input": props.ifc_patch_input,
|
"input": input_file,
|
||||||
"file": ifcopenshell.open(props.ifc_patch_input),
|
"file": file,
|
||||||
"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"),
|
||||||
|
|||||||
@@ -66,3 +66,4 @@ class BIMPatchProperties(PropertyGroup):
|
|||||||
ifc_patch_output: StringProperty(default="", name="IFC Patch Output IFC")
|
ifc_patch_output: StringProperty(default="", name="IFC Patch Output IFC")
|
||||||
ifc_patch_args: StringProperty(default="", name="Arguments")
|
ifc_patch_args: StringProperty(default="", name="Arguments")
|
||||||
ifc_patch_args_attr: CollectionProperty(type=Attribute, name="Arguments")
|
ifc_patch_args_attr: CollectionProperty(type=Attribute, name="Arguments")
|
||||||
|
should_load_from_memory: BoolProperty(default=False, name="Load from Memory")
|
||||||
|
|||||||
@@ -16,8 +16,9 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from blenderbim.bim.helper import prop_with_search
|
|
||||||
import bpy
|
import bpy
|
||||||
|
import blenderbim.tool as tool
|
||||||
|
from blenderbim.bim.helper import prop_with_search
|
||||||
from blenderbim.bim.helper import draw_attributes
|
from blenderbim.bim.helper import draw_attributes
|
||||||
|
|
||||||
|
|
||||||
@@ -40,9 +41,14 @@ class BIM_PT_patch(bpy.types.Panel):
|
|||||||
row = layout.row()
|
row = layout.row()
|
||||||
prop_with_search(row, props, "ifc_patch_recipes")
|
prop_with_search(row, props, "ifc_patch_recipes")
|
||||||
|
|
||||||
row = layout.row(align=True)
|
if tool.Ifc.get():
|
||||||
row.prop(props, "ifc_patch_input")
|
row = self.layout.row()
|
||||||
row.operator("bim.select_ifc_patch_input", icon="FILE_FOLDER", text="")
|
row.prop(props, "should_load_from_memory")
|
||||||
|
|
||||||
|
if not tool.Ifc.get() or not props.should_load_from_memory:
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.prop(props, "ifc_patch_input")
|
||||||
|
row.operator("bim.select_ifc_patch_input", icon="FILE_FOLDER", text="")
|
||||||
|
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(props, "ifc_patch_output")
|
row.prop(props, "ifc_patch_output")
|
||||||
|
|||||||
@@ -1,7 +1,16 @@
|
|||||||
@patch
|
@patch
|
||||||
Feature: Patch
|
Feature: Patch
|
||||||
|
|
||||||
Scenario: Execute IFC Patch
|
Scenario: Execute IFC Patch - file in memory
|
||||||
|
Given an empty IFC project
|
||||||
|
And I set "scene.BIMPatchProperties.ifc_patch_recipes" to "OffsetObjectPlacements"
|
||||||
|
And I set "scene.BIMPatchProperties.should_load_from_memory" to "True"
|
||||||
|
And I set "scene.BIMPatchProperties.ifc_patch_output" to "{cwd}/test/files/basic-patched.ifc"
|
||||||
|
And I set "scene.BIMPatchProperties.ifc_patch_args" to "[123454321,0,0,0]"
|
||||||
|
When I press "bim.execute_ifc_patch(use_json_for_args=True)"
|
||||||
|
Then the file "{cwd}/test/files/basic-patched.ifc" should contain "123454321"
|
||||||
|
|
||||||
|
Scenario: Execute IFC Patch - file from disk
|
||||||
Given an empty IFC project
|
Given an empty IFC project
|
||||||
And I set "scene.BIMPatchProperties.ifc_patch_recipes" to "OffsetObjectPlacements"
|
And I set "scene.BIMPatchProperties.ifc_patch_recipes" to "OffsetObjectPlacements"
|
||||||
And I set "scene.BIMPatchProperties.ifc_patch_input" to "{cwd}/test/files/basic.ifc"
|
And I set "scene.BIMPatchProperties.ifc_patch_input" to "{cwd}/test/files/basic.ifc"
|
||||||
|
|||||||
Reference in New Issue
Block a user