You can now flip clipping planes

This commit is contained in:
Dion Moult
2024-02-29 20:39:29 +11:00
parent 3ef4927e55
commit 02e9cb06b4
3 changed files with 26 additions and 0 deletions
@@ -33,6 +33,7 @@ classes = (
operator.EnableCulling, operator.EnableCulling,
operator.EnableEditingHeader, operator.EnableEditingHeader,
operator.ExportIFC, operator.ExportIFC,
operator.FlipClippingPlane,
operator.ImportIFC, operator.ImportIFC,
operator.LinkIfc, operator.LinkIfc,
operator.LoadLink, operator.LoadLink,
@@ -37,6 +37,7 @@ from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.ui import IFCFileSelector from blenderbim.bim.ui import IFCFileSelector
from blenderbim.bim import import_ifc from blenderbim.bim import import_ifc
from blenderbim.bim import export_ifc from blenderbim.bim import export_ifc
from math import radians
from pathlib import Path from pathlib import Path
from mathutils import Vector, Matrix from mathutils import Vector, Matrix
from bpy.app.handlers import persistent from bpy.app.handlers import persistent
@@ -1876,3 +1877,20 @@ class CreateClippingPlane(bpy.types.Operator):
self.mouse_x = event.mouse_region_x self.mouse_x = event.mouse_region_x
self.mouse_y = event.mouse_region_y self.mouse_y = event.mouse_region_y
return self.execute(context) return self.execute(context)
class FlipClippingPlane(bpy.types.Operator):
bl_idname = "bim.flip_clipping_plane"
bl_label = "Flip Clipping Plane"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
return context.area.type == "VIEW_3D"
def execute(self, context):
obj = bpy.context.active_object
if obj in [cp.obj for cp in bpy.context.scene.BIMProjectProperties.clipping_planes]:
obj.rotation_euler[0] += radians(180)
bpy.context.view_layer.update()
return {"FINISHED"}
@@ -33,6 +33,7 @@ class QueryTool(bpy.types.WorkSpaceTool):
bl_keymap = ( bl_keymap = (
("bim.query_linked_element", {"type": "RIGHTMOUSE", "value": "PRESS"}, None), ("bim.query_linked_element", {"type": "RIGHTMOUSE", "value": "PRESS"}, None),
("bim.query_hotkey", {"type": "C", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_C")]}), ("bim.query_hotkey", {"type": "C", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_C")]}),
("bim.query_hotkey", {"type": "F", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_F")]}),
("bim.query_hotkey", {"type": "C", "value": "PRESS", "alt": True}, {"properties": [("hotkey", "A_C")]}), ("bim.query_hotkey", {"type": "C", "value": "PRESS", "alt": True}, {"properties": [("hotkey", "A_C")]}),
) )
@@ -43,6 +44,9 @@ class QueryTool(bpy.types.WorkSpaceTool):
row.label(text="", icon="EVENT_SHIFT") row.label(text="", icon="EVENT_SHIFT")
row.label(text="Add Clipping Plane", icon="EVENT_C") row.label(text="Add Clipping Plane", icon="EVENT_C")
row = layout.row(align=True) row = layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
row.label(text="Flip Clipping Plane", icon="EVENT_F")
row = layout.row(align=True)
row.label(text="", icon="EVENT_ALT") row.label(text="", icon="EVENT_ALT")
row.label(text="Disable Culling" if LinksData.enable_culling else "Enable Culling", icon="EVENT_C") row.label(text="Disable Culling" if LinksData.enable_culling else "Enable Culling", icon="EVENT_C")
@@ -65,6 +69,9 @@ class QueryHotkey(bpy.types.Operator):
def hotkey_S_C(self): def hotkey_S_C(self):
bpy.ops.bim.create_clipping_plane("INVOKE_DEFAULT") bpy.ops.bim.create_clipping_plane("INVOKE_DEFAULT")
def hotkey_S_F(self):
bpy.ops.bim.flip_clipping_plane("INVOKE_DEFAULT")
def hotkey_A_C(self): def hotkey_A_C(self):
if LinksData.enable_culling: if LinksData.enable_culling:
bpy.ops.bim.disable_culling() bpy.ops.bim.disable_culling()