mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
New wall tool with hotkeys for rapid wall editing
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import bpy
|
||||
from . import operator, ui, grid, stair, door, window, slab, opening, pie
|
||||
from . import operator, prop, ui, grid, stair, door, window, slab, opening, pie, workspace
|
||||
|
||||
classes = (
|
||||
operator.AddTypeInstance,
|
||||
operator.AddWall,
|
||||
operator.JoinWall,
|
||||
operator.AlignWall,
|
||||
prop.BIMModelProperties,
|
||||
ui.BIM_PT_authoring,
|
||||
ui.BIM_PT_authoring_architectural,
|
||||
ui.BIM_PT_misc_utilities,
|
||||
@@ -32,6 +34,8 @@ addon_keymaps = []
|
||||
|
||||
|
||||
def register():
|
||||
bpy.utils.register_tool(workspace.WallTool, after={"builtin.scale_cage"}, separator=True, group=True)
|
||||
bpy.types.Scene.BIMModelProperties = bpy.props.PointerProperty(type=prop.BIMModelProperties)
|
||||
bpy.types.VIEW3D_MT_mesh_add.append(grid.add_object_button)
|
||||
bpy.types.VIEW3D_MT_mesh_add.append(stair.add_object_button)
|
||||
bpy.types.VIEW3D_MT_mesh_add.append(door.add_object_button)
|
||||
@@ -47,6 +51,8 @@ def register():
|
||||
|
||||
|
||||
def unregister():
|
||||
bpy.utils.unregister_tool(workspace.WallTool)
|
||||
del bpy.types.Scene.BIMModelProperties
|
||||
bpy.types.VIEW3D_MT_mesh_add.remove(grid.add_object_button)
|
||||
bpy.types.VIEW3D_MT_mesh_add.remove(stair.add_object_button)
|
||||
bpy.types.VIEW3D_MT_mesh_add.remove(door.add_object_button)
|
||||
|
||||
@@ -5,6 +5,7 @@ import ifcopenshell.util.type
|
||||
import ifcopenshell.util.unit
|
||||
import mathutils.geometry
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from math import pi
|
||||
from mathutils import Vector, Matrix
|
||||
from ifcopenshell.api.material.data import Data as MaterialData
|
||||
|
||||
@@ -13,15 +14,19 @@ class AddTypeInstance(bpy.types.Operator):
|
||||
bl_idname = "bim.add_type_instance"
|
||||
bl_label = "Add Type Instance"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
ifc_class: bpy.props.StringProperty()
|
||||
relating_type: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
tprops = context.scene.BIMTypeProperties
|
||||
if not tprops.ifc_class or not tprops.relating_type:
|
||||
ifc_class = self.ifc_class or tprops.ifc_class
|
||||
relating_type = self.relating_type or tprops.relating_type
|
||||
if not ifc_class or not relating_type:
|
||||
return {"FINISHED"}
|
||||
self.file = IfcStore.get_file()
|
||||
instance_class = ifcopenshell.util.type.get_applicable_entities(tprops.ifc_class, self.file.schema)[0]
|
||||
if instance_class in ["IfcWall", "IfcWallStandardCase"]:
|
||||
obj = DumbWallGenerator(self.file.by_id(int(tprops.relating_type))).generate()
|
||||
instance_class = ifcopenshell.util.type.get_applicable_entities(ifc_class, self.file.schema)[0]
|
||||
if ifc_class == "IfcWallType":
|
||||
obj = DumbWallGenerator(self.file.by_id(int(relating_type))).generate()
|
||||
if obj:
|
||||
return {"FINISHED"}
|
||||
# A cube
|
||||
@@ -58,6 +63,18 @@ class AddTypeInstance(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AddWall(bpy.types.Operator):
|
||||
bl_idname = "bim.add_wall"
|
||||
bl_label = "Add Wall"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
join_type: bpy.props.StringProperty()
|
||||
|
||||
def execute(self, context):
|
||||
props = context.scene.BIMModelProperties
|
||||
bpy.ops.bim.add_type_instance(ifc_class="IfcWallType", relating_type=int(props.relating_type))
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class JoinWall(bpy.types.Operator):
|
||||
bl_idname = "bim.join_wall"
|
||||
bl_label = "Join Wall"
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import bpy
|
||||
import ifcopenshell.util.type
|
||||
from blenderbim.bim.prop import StrProperty, Attribute
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from bpy.types import PropertyGroup
|
||||
from bpy.props import (
|
||||
PointerProperty,
|
||||
StringProperty,
|
||||
EnumProperty,
|
||||
BoolProperty,
|
||||
IntProperty,
|
||||
FloatProperty,
|
||||
FloatVectorProperty,
|
||||
CollectionProperty,
|
||||
)
|
||||
|
||||
relating_types_enum = []
|
||||
|
||||
|
||||
def purge():
|
||||
global relating_types_enum
|
||||
relating_types_enum = []
|
||||
|
||||
def getRelatingTypes(self, context):
|
||||
global relating_types_enum
|
||||
if len(relating_types_enum) < 1:
|
||||
elements = IfcStore.get_file().by_type("IfcWallType")
|
||||
relating_types_enum.extend((str(e.id()), e.Name, "") for e in elements)
|
||||
return relating_types_enum
|
||||
|
||||
class BIMModelProperties(PropertyGroup):
|
||||
relating_type: EnumProperty(items=getRelatingTypes, name="Relating Type")
|
||||
@@ -0,0 +1,56 @@
|
||||
import bpy
|
||||
from bpy.types import WorkSpaceTool
|
||||
|
||||
|
||||
class WallTool(WorkSpaceTool):
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_context_mode = "OBJECT"
|
||||
|
||||
bl_idname = "bim.wall_tool"
|
||||
bl_label = "Wall Tool"
|
||||
bl_description = "Gives you wall related superpowers"
|
||||
bl_icon = "ops.generic.select_circle"
|
||||
bl_widget = None
|
||||
# https://docs.blender.org/api/current/bpy.types.KeyMapItems.html
|
||||
bl_keymap = (
|
||||
# ("bim.wall_tool_op", {"type": 'MOUSEMOVE', "value": 'ANY'}, {"properties": []}),
|
||||
# ("mesh.add_wall", {"type": 'LEFTMOUSE', "value": 'PRESS'}, {"properties": []}),
|
||||
("bim.add_wall", {"type": "A", "value": "PRESS", "shift": True}, {"properties": []}),
|
||||
("bim.join_wall", {"type": "E", "value": "PRESS", "shift": True}, {"properties": [("join_type", "T")]}),
|
||||
("bim.join_wall", {"type": "T", "value": "PRESS", "shift": True}, {"properties": [("join_type", "L")]}),
|
||||
("bim.join_wall", {"type": "Y", "value": "PRESS", "shift": True}, {"properties": [("join_type", "V")]}),
|
||||
(
|
||||
"bim.align_wall",
|
||||
{"type": "X", "value": "PRESS", "shift": True},
|
||||
{"properties": [("align_type", "EXTERIOR")]},
|
||||
),
|
||||
(
|
||||
"bim.align_wall",
|
||||
{"type": "C", "value": "PRESS", "shift": True},
|
||||
{"properties": [("align_type", "CENTERLINE")]},
|
||||
),
|
||||
(
|
||||
"bim.align_wall",
|
||||
{"type": "V", "value": "PRESS", "shift": True},
|
||||
{"properties": [("align_type", "INTERIOR")]},
|
||||
),
|
||||
)
|
||||
|
||||
def draw_settings(context, layout, tool):
|
||||
props = context.scene.BIMModelProperties
|
||||
row = layout.row(align=True)
|
||||
row.prop(props, "relating_type", text="")
|
||||
|
||||
row.label(text="", icon="BLANK1")
|
||||
|
||||
row.label(text="", icon="EVENT_SHIFT")
|
||||
row.label(text="Add", icon="EVENT_A")
|
||||
row.label(text="Extend", icon="EVENT_E")
|
||||
row.label(text="Butt", icon="EVENT_T")
|
||||
row.label(text="Mitre", icon="EVENT_Y")
|
||||
row.label(text="Flip", icon="EVENT_F")
|
||||
row.label(text="Split", icon="EVENT_S")
|
||||
row.label(text="", icon="EVENT_X")
|
||||
row.label(text="", icon="EVENT_C")
|
||||
row.label(text="", icon="EVENT_V")
|
||||
row.label(text="Align")
|
||||
@@ -11,9 +11,9 @@ def get_colour_settings(material):
|
||||
transparency = bsdf.inputs["Alpha"].default_value
|
||||
diffuse_colour = bsdf.inputs["Base Color"].default_value
|
||||
return {
|
||||
"SurfaceColour": material.diffuse_color,
|
||||
"SurfaceColour": tuple(material.diffuse_color),
|
||||
"Transparency": transparency,
|
||||
"DiffuseColour": diffuse_colour,
|
||||
"DiffuseColour": tuple(diffuse_colour),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user