mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 10:51:13 +00:00
WIP Refactor patch module. See #1222.
This commit is contained in:
@@ -28,6 +28,7 @@ if bpy is not None:
|
|||||||
"material": None,
|
"material": None,
|
||||||
"model": None,
|
"model": None,
|
||||||
"owner": None,
|
"owner": None,
|
||||||
|
"patch": None,
|
||||||
"project": None,
|
"project": None,
|
||||||
"pset": None,
|
"pset": None,
|
||||||
"pset_template": None,
|
"pset_template": None,
|
||||||
@@ -110,9 +111,6 @@ if bpy is not None:
|
|||||||
operator.AddVariable,
|
operator.AddVariable,
|
||||||
operator.RemoveVariable,
|
operator.RemoveVariable,
|
||||||
operator.PropagateTextData,
|
operator.PropagateTextData,
|
||||||
operator.SelectIfcPatchInput,
|
|
||||||
operator.SelectIfcPatchOutput,
|
|
||||||
operator.ExecuteIfcPatch,
|
|
||||||
operator.SetOverrideColour,
|
operator.SetOverrideColour,
|
||||||
operator.AddDrawing,
|
operator.AddDrawing,
|
||||||
operator.RemoveDrawing,
|
operator.RemoveDrawing,
|
||||||
@@ -179,7 +177,6 @@ if bpy is not None:
|
|||||||
ui.BIM_PT_ifcclash,
|
ui.BIM_PT_ifcclash,
|
||||||
ui.BIM_PT_library,
|
ui.BIM_PT_library,
|
||||||
ui.BIM_PT_presentation_layers,
|
ui.BIM_PT_presentation_layers,
|
||||||
ui.BIM_PT_patch,
|
|
||||||
ui.BIM_PT_presentation_layer_data,
|
ui.BIM_PT_presentation_layer_data,
|
||||||
ui.BIM_PT_object_structural,
|
ui.BIM_PT_object_structural,
|
||||||
ui.BIM_PT_camera,
|
ui.BIM_PT_camera,
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import bpy
|
||||||
|
from . import ui, prop, operator
|
||||||
|
|
||||||
|
classes = (
|
||||||
|
operator.SelectIfcPatchInput,
|
||||||
|
operator.SelectIfcPatchOutput,
|
||||||
|
operator.ExecuteIfcPatch,
|
||||||
|
prop.BIMPatchProperties,
|
||||||
|
ui.BIM_PT_patch,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def register():
|
||||||
|
bpy.types.Scene.BIMPatchProperties = bpy.props.PointerProperty(type=prop.BIMPatchProperties)
|
||||||
|
|
||||||
|
|
||||||
|
def unregister():
|
||||||
|
del bpy.types.Scene.BIMPatchProperties
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import bpy
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
class SelectIfcPatchInput(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.select_ifc_patch_input"
|
||||||
|
bl_label = "Select IFC Patch Input"
|
||||||
|
filter_glob: bpy.props.StringProperty(default="*.ifc", options={"HIDDEN"})
|
||||||
|
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
context.scene.BIMPatchProperties.ifc_patch_input = self.filepath
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
context.window_manager.fileselect_add(self)
|
||||||
|
return {"RUNNING_MODAL"}
|
||||||
|
|
||||||
|
|
||||||
|
class SelectIfcPatchOutput(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.select_ifc_patch_output"
|
||||||
|
bl_label = "Select IFC Patch Output"
|
||||||
|
filename_ext = ".ifc"
|
||||||
|
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
context.scene.BIMPatchProperties.ifc_patch_output = self.filepath
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
context.window_manager.fileselect_add(self)
|
||||||
|
return {"RUNNING_MODAL"}
|
||||||
|
|
||||||
|
|
||||||
|
class ExecuteIfcPatch(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.execute_ifc_patch"
|
||||||
|
bl_label = "Execute IFCPatch"
|
||||||
|
file_format: bpy.props.StringProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
import ifcpatch
|
||||||
|
|
||||||
|
ifcpatch.execute(
|
||||||
|
{
|
||||||
|
"input": context.scene.BIMPatchProperties.ifc_patch_input,
|
||||||
|
"output": context.scene.BIMPatchProperties.ifc_patch_output,
|
||||||
|
"recipe": context.scene.BIMPatchProperties.ifc_patch_recipes,
|
||||||
|
"arguments": json.loads(context.scene.BIMPatchProperties.ifc_patch_args),
|
||||||
|
"log": context.scene.BIMProperties.data_dir + "process.log",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return {"FINISHED"}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import bpy
|
||||||
|
import importlib
|
||||||
|
from pathlib import Path
|
||||||
|
from blenderbim.bim.prop import StrProperty, Attribute
|
||||||
|
from bpy.types import PropertyGroup
|
||||||
|
from bpy.props import (
|
||||||
|
PointerProperty,
|
||||||
|
StringProperty,
|
||||||
|
EnumProperty,
|
||||||
|
BoolProperty,
|
||||||
|
IntProperty,
|
||||||
|
FloatProperty,
|
||||||
|
FloatVectorProperty,
|
||||||
|
CollectionProperty,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
ifcpatchrecipes_enum = []
|
||||||
|
|
||||||
|
|
||||||
|
def getIfcPatchRecipes(self, context):
|
||||||
|
global ifcpatchrecipes_enum
|
||||||
|
if len(ifcpatchrecipes_enum) < 1:
|
||||||
|
ifcpatchrecipes_enum.clear()
|
||||||
|
ifcpatch_path = Path(importlib.util.find_spec("ifcpatch").submodule_search_locations[0])
|
||||||
|
for filename in ifcpatch_path.joinpath("recipes").glob("*.py"):
|
||||||
|
f = str(filename.stem)
|
||||||
|
if f == "__init__":
|
||||||
|
continue
|
||||||
|
ifcpatchrecipes_enum.append((f, f, ""))
|
||||||
|
return ifcpatchrecipes_enum
|
||||||
|
|
||||||
|
|
||||||
|
class BIMPatchProperties(PropertyGroup):
|
||||||
|
ifc_patch_recipes: EnumProperty(items=getIfcPatchRecipes, name="Recipes")
|
||||||
|
ifc_patch_input: StringProperty(default="", name="IFC Patch Input IFC")
|
||||||
|
ifc_patch_output: StringProperty(default="", name="IFC Patch Output IFC")
|
||||||
|
ifc_patch_args: StringProperty(default="", name="Arguments")
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import bpy
|
||||||
|
from bpy.types import Panel
|
||||||
|
|
||||||
|
|
||||||
|
class BIM_PT_patch(Panel):
|
||||||
|
bl_label = "IFC Patch"
|
||||||
|
bl_idname = "BIM_PT_patch"
|
||||||
|
bl_options = {"DEFAULT_CLOSED"}
|
||||||
|
bl_space_type = "PROPERTIES"
|
||||||
|
bl_region_type = "WINDOW"
|
||||||
|
bl_context = "scene"
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
layout.use_property_split = True
|
||||||
|
|
||||||
|
scene = context.scene
|
||||||
|
props = scene.BIMPatchProperties
|
||||||
|
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(props, "ifc_patch_recipes")
|
||||||
|
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.prop(props, "ifc_patch_output")
|
||||||
|
row.operator("bim.select_ifc_patch_output", icon="FILE_FOLDER", text="")
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(props, "ifc_patch_args")
|
||||||
|
|
||||||
|
row = layout.row()
|
||||||
|
op = row.operator("bim.execute_ifc_patch")
|
||||||
@@ -413,24 +413,6 @@ class SelectExternalMaterialDir(bpy.types.Operator):
|
|||||||
return {"RUNNING_MODAL"}
|
return {"RUNNING_MODAL"}
|
||||||
|
|
||||||
|
|
||||||
class ExecuteIfcPatch(bpy.types.Operator):
|
|
||||||
bl_idname = "bim.execute_ifc_patch"
|
|
||||||
bl_label = "Execute IFCPatch"
|
|
||||||
file_format: bpy.props.StringProperty()
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
import ifcpatch
|
|
||||||
|
|
||||||
ifcpatch.execute(
|
|
||||||
{
|
|
||||||
"input": bpy.context.scene.BIMProperties.ifc_patch_input,
|
|
||||||
"output": bpy.context.scene.BIMProperties.ifc_patch_output,
|
|
||||||
"recipe": bpy.context.scene.BIMProperties.ifc_patch_recipes,
|
|
||||||
"arguments": json.loads("[" + bpy.context.scene.BIMProperties.ifc_patch_args + "]"),
|
|
||||||
"log": bpy.context.scene.BIMProperties.data_dir + "process.log",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
|
|
||||||
class ExportClashSets(bpy.types.Operator):
|
class ExportClashSets(bpy.types.Operator):
|
||||||
@@ -1732,36 +1714,6 @@ class PropagateTextData(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class SelectIfcPatchInput(bpy.types.Operator):
|
|
||||||
bl_idname = "bim.select_ifc_patch_input"
|
|
||||||
bl_label = "Select IFC Patch Input"
|
|
||||||
filter_glob: bpy.props.StringProperty(default="*.ifc", options={"HIDDEN"})
|
|
||||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
bpy.context.scene.BIMProperties.ifc_patch_input = self.filepath
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
def invoke(self, context, event):
|
|
||||||
context.window_manager.fileselect_add(self)
|
|
||||||
return {"RUNNING_MODAL"}
|
|
||||||
|
|
||||||
|
|
||||||
class SelectIfcPatchOutput(bpy.types.Operator):
|
|
||||||
bl_idname = "bim.select_ifc_patch_output"
|
|
||||||
bl_label = "Select IFC Patch Output"
|
|
||||||
filename_ext = ".ifc"
|
|
||||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
bpy.context.scene.BIMProperties.ifc_patch_output = self.filepath
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
def invoke(self, context, event):
|
|
||||||
context.window_manager.fileselect_add(self)
|
|
||||||
return {"RUNNING_MODAL"}
|
|
||||||
|
|
||||||
|
|
||||||
class SetOverrideColour(bpy.types.Operator):
|
class SetOverrideColour(bpy.types.Operator):
|
||||||
bl_idname = "bim.set_override_colour"
|
bl_idname = "bim.set_override_colour"
|
||||||
bl_label = "Set Override Colour"
|
bl_label = "Set Override Colour"
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ cwd = os.path.dirname(os.path.realpath(__file__))
|
|||||||
diagram_scales_enum = []
|
diagram_scales_enum = []
|
||||||
profiledef_enum = []
|
profiledef_enum = []
|
||||||
availablematerialpsets_enum = []
|
availablematerialpsets_enum = []
|
||||||
ifcpatchrecipes_enum = []
|
|
||||||
titleblocks_enum = []
|
titleblocks_enum = []
|
||||||
materialpsetnames_enum = []
|
materialpsetnames_enum = []
|
||||||
attributes_enum = []
|
attributes_enum = []
|
||||||
@@ -211,18 +210,6 @@ def getAttributeEnumValues(self, context):
|
|||||||
return [(e, e, "") for e in json.loads(self.enum_items)]
|
return [(e, e, "") for e in json.loads(self.enum_items)]
|
||||||
|
|
||||||
|
|
||||||
def getIfcPatchRecipes(self, context):
|
|
||||||
global ifcpatchrecipes_enum
|
|
||||||
if len(ifcpatchrecipes_enum) < 1:
|
|
||||||
ifcpatchrecipes_enum.clear()
|
|
||||||
ifcpatch_path = Path(importlib.util.find_spec("ifcpatch").submodule_search_locations[0])
|
|
||||||
for filename in ifcpatch_path.joinpath("recipes").glob("*.py"):
|
|
||||||
f = str(filename.stem)
|
|
||||||
if f == "__init__":
|
|
||||||
continue
|
|
||||||
ifcpatchrecipes_enum.append((f, f, ""))
|
|
||||||
return ifcpatchrecipes_enum
|
|
||||||
|
|
||||||
def getTitleblocks(self, context):
|
def getTitleblocks(self, context):
|
||||||
global titleblocks_enum
|
global titleblocks_enum
|
||||||
if len(titleblocks_enum) < 1:
|
if len(titleblocks_enum) < 1:
|
||||||
@@ -503,10 +490,6 @@ class BIMProperties(PropertyGroup):
|
|||||||
smart_clash_groups: CollectionProperty(name="Smart Clash Groups", type=SmartClashGroup)
|
smart_clash_groups: CollectionProperty(name="Smart Clash Groups", type=SmartClashGroup)
|
||||||
active_smart_group_index: IntProperty(name="Active Smart Group Index")
|
active_smart_group_index: IntProperty(name="Active Smart Group Index")
|
||||||
smart_clash_grouping_max_distance: IntProperty(name="Smart Clash Grouping Max Distance", default=3, soft_min=1, soft_max=10)
|
smart_clash_grouping_max_distance: IntProperty(name="Smart Clash Grouping Max Distance", default=3, soft_min=1, soft_max=10)
|
||||||
ifc_patch_recipes: EnumProperty(items=getIfcPatchRecipes, name="Recipes")
|
|
||||||
ifc_patch_input: StringProperty(default="", name="IFC Patch Input IFC")
|
|
||||||
ifc_patch_output: StringProperty(default="", name="IFC Patch Output IFC")
|
|
||||||
ifc_patch_args: StringProperty(default="", name="Arguments")
|
|
||||||
area_unit: EnumProperty(
|
area_unit: EnumProperty(
|
||||||
default="SQUARE_METRE",
|
default="SQUARE_METRE",
|
||||||
items=[
|
items=[
|
||||||
|
|||||||
@@ -403,36 +403,6 @@ class BIM_PT_library(Panel):
|
|||||||
layout.row().prop(scene.BIMLibrary, "description")
|
layout.row().prop(scene.BIMLibrary, "description")
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_patch(Panel):
|
|
||||||
bl_label = "IFC Patch"
|
|
||||||
bl_idname = "BIM_PT_patch"
|
|
||||||
bl_options = {"DEFAULT_CLOSED"}
|
|
||||||
bl_space_type = "PROPERTIES"
|
|
||||||
bl_region_type = "WINDOW"
|
|
||||||
bl_context = "scene"
|
|
||||||
|
|
||||||
def draw(self, context):
|
|
||||||
layout = self.layout
|
|
||||||
layout.use_property_split = True
|
|
||||||
|
|
||||||
scene = context.scene
|
|
||||||
props = scene.BIMProperties
|
|
||||||
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(props, "ifc_patch_recipes")
|
|
||||||
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.prop(props, "ifc_patch_output")
|
|
||||||
row.operator("bim.select_ifc_patch_output", icon="FILE_FOLDER", text="")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(props, "ifc_patch_args")
|
|
||||||
|
|
||||||
row = layout.row()
|
|
||||||
op = row.operator("bim.execute_ifc_patch")
|
|
||||||
|
|
||||||
|
|
||||||
class BIM_UL_generic(bpy.types.UIList):
|
class BIM_UL_generic(bpy.types.UIList):
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||||
if item:
|
if item:
|
||||||
|
|||||||
Reference in New Issue
Block a user