mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 21:42:28 +00:00
Forgot to commit test numpy chunking code and workspace tools
This commit is contained in:
@@ -1593,12 +1593,10 @@ class LoadLinkedProject(bpy.types.Operator):
|
|||||||
start = time.time()
|
start = time.time()
|
||||||
|
|
||||||
self.filepath = self.filepath or "/home/dion/drive/ifcs/racbasicsampleproject.ifc"
|
self.filepath = self.filepath or "/home/dion/drive/ifcs/racbasicsampleproject.ifc"
|
||||||
|
print("Processing", self.filepath)
|
||||||
|
|
||||||
self.collection = bpy.data.collections.new("IfcProject/" + os.path.basename(self.filepath))
|
self.collection = bpy.data.collections.new("IfcProject/" + os.path.basename(self.filepath))
|
||||||
self.file = ifcopenshell.open(self.filepath)
|
self.file = ifcopenshell.open(self.filepath)
|
||||||
# self.file = ifcopenshell.open('/home/dion/test.ifc')
|
|
||||||
# self.file = ifcopenshell.open('/home/dion/drive/ifcs/TXG_sample_project-fixed-IFC4.ifc')
|
|
||||||
# self.file = ifcopenshell.open("/home/dion/tmp/petrubug/F-ELECT.ifc")
|
|
||||||
print("Finished opening")
|
print("Finished opening")
|
||||||
|
|
||||||
self.db_filepath = self.filepath + ".cache.sqlite"
|
self.db_filepath = self.filepath + ".cache.sqlite"
|
||||||
@@ -1627,9 +1625,20 @@ class LoadLinkedProject(bpy.types.Operator):
|
|||||||
)
|
)
|
||||||
self.meshes = {}
|
self.meshes = {}
|
||||||
self.blender_mats = {}
|
self.blender_mats = {}
|
||||||
|
blender_mats = {}
|
||||||
|
|
||||||
total_materials = 0
|
default_mat = np.array([[1, 1, 1, 1]], dtype=np.float32)
|
||||||
self.materials = []
|
chunked_guids = []
|
||||||
|
chunked_guid_ids = []
|
||||||
|
chunked_verts = []
|
||||||
|
chunked_faces = []
|
||||||
|
chunked_materials = []
|
||||||
|
chunked_material_ids = []
|
||||||
|
material_offset = 0
|
||||||
|
max_slot_index = 0
|
||||||
|
chunk_size = 10000
|
||||||
|
r4 = np.array([[0, 0, 0, 1]])
|
||||||
|
offset = 0
|
||||||
|
|
||||||
ci = 0
|
ci = 0
|
||||||
if iterator.initialize():
|
if iterator.initialize():
|
||||||
@@ -1638,41 +1647,124 @@ class LoadLinkedProject(bpy.types.Operator):
|
|||||||
if len(shape.geometry.faces) > 1000: # 333 tris
|
if len(shape.geometry.faces) > 1000: # 333 tris
|
||||||
self.process_occurrence(shape)
|
self.process_occurrence(shape)
|
||||||
if not iterator.next():
|
if not iterator.next():
|
||||||
# The left over chunk
|
mats = np.concatenate(chunked_materials)
|
||||||
chunk = iterator.get_chunk()
|
midx = np.concatenate(chunked_material_ids)
|
||||||
for colour in chunk.colours:
|
mats, mapping = np.unique(mats, axis=0, return_inverse=True)
|
||||||
blender_mat = bpy.data.materials.new(str(total_materials))
|
midx = mapping[midx]
|
||||||
blender_mat.diffuse_color = list(colour)
|
|
||||||
self.materials.append(blender_mat)
|
|
||||||
total_materials += 1
|
|
||||||
self.create_object(chunk)
|
|
||||||
|
|
||||||
|
mat_results = []
|
||||||
|
for mat in mats:
|
||||||
|
mat = tuple(mat)
|
||||||
|
blender_mat = blender_mats.get(mat, None)
|
||||||
|
if not blender_mat:
|
||||||
|
blender_mat = bpy.data.materials.new("Chunk")
|
||||||
|
blender_mat.diffuse_color = mat
|
||||||
|
blender_mats[mat] = blender_mat
|
||||||
|
mat_results.append(blender_mat)
|
||||||
|
|
||||||
|
# The left over chunk
|
||||||
|
self.create_object(
|
||||||
|
np.concatenate(chunked_verts),
|
||||||
|
np.concatenate(chunked_faces),
|
||||||
|
mat_results,
|
||||||
|
midx,
|
||||||
|
chunked_guids,
|
||||||
|
chunked_guid_ids,
|
||||||
|
)
|
||||||
break
|
break
|
||||||
continue
|
continue
|
||||||
if iterator.process_chunk():
|
|
||||||
has_processed_chunk = True
|
|
||||||
ci += 1
|
|
||||||
if ci % 50 == 0:
|
|
||||||
print("Doing chunk", ci)
|
|
||||||
chunk = iterator.get_chunk()
|
|
||||||
|
|
||||||
for colour in chunk.colours:
|
ci += 1
|
||||||
blender_mat = bpy.data.materials.new(str(total_materials))
|
if ci % 50 == 0:
|
||||||
blender_mat.diffuse_color = list(colour)
|
print("Doing chunk", ci)
|
||||||
self.materials.append(blender_mat)
|
|
||||||
total_materials += 1
|
has_processed_chunk = False
|
||||||
self.create_object(chunk)
|
|
||||||
|
ms = np.vstack([default_mat, np.frombuffer(shape.geometry.colors_buffer).reshape((-1, 4))])
|
||||||
|
mi = np.frombuffer(shape.geometry.material_ids_buffer, dtype=np.int32)
|
||||||
|
chunked_materials.append(ms)
|
||||||
|
chunked_material_ids.append(mi + material_offset + 1)
|
||||||
|
material_offset += len(ms)
|
||||||
|
|
||||||
|
M4 = np.frombuffer(shape.transformation_buffer).reshape((4, 3))
|
||||||
|
M4 = np.concatenate((M4.T, r4))
|
||||||
|
vs = np.frombuffer(shape.geometry.verts_buffer).reshape((-1, 3))
|
||||||
|
vs = np.hstack((vs, np.ones((len(vs), 1))))
|
||||||
|
vs = (np.asmatrix(M4) * np.asmatrix(vs).T).T.A
|
||||||
|
vs = vs[:, :3].flatten()
|
||||||
|
fs = np.frombuffer(shape.geometry.faces_buffer, dtype=np.int32)
|
||||||
|
chunked_verts.append(vs)
|
||||||
|
chunked_faces.append(fs + offset)
|
||||||
|
offset += len(vs) // 3
|
||||||
|
|
||||||
|
chunked_guids.append(shape.guid)
|
||||||
|
if chunked_guid_ids:
|
||||||
|
chunked_guid_ids.append((len(fs) // 3) + chunked_guid_ids[-1])
|
||||||
|
else:
|
||||||
|
chunked_guid_ids.append(len(fs) // 3)
|
||||||
|
|
||||||
|
if offset > chunk_size:
|
||||||
|
has_processed_chunk = True
|
||||||
|
|
||||||
|
mats = np.concatenate(chunked_materials)
|
||||||
|
midx = np.concatenate(chunked_material_ids)
|
||||||
|
mats, mapping = np.unique(mats, axis=0, return_inverse=True)
|
||||||
|
midx = mapping[midx]
|
||||||
|
|
||||||
|
mat_results = []
|
||||||
|
for mat in mats:
|
||||||
|
mat = tuple(mat)
|
||||||
|
blender_mat = blender_mats.get(mat, None)
|
||||||
|
if not blender_mat:
|
||||||
|
blender_mat = bpy.data.materials.new("Chunk")
|
||||||
|
blender_mat.diffuse_color = mat
|
||||||
|
blender_mats[mat] = blender_mat
|
||||||
|
mat_results.append(blender_mat)
|
||||||
|
|
||||||
|
self.create_object(
|
||||||
|
np.concatenate(chunked_verts),
|
||||||
|
np.concatenate(chunked_faces),
|
||||||
|
mat_results,
|
||||||
|
midx,
|
||||||
|
chunked_guids,
|
||||||
|
chunked_guid_ids,
|
||||||
|
)
|
||||||
|
chunked_guids = []
|
||||||
|
chunked_guid_ids = []
|
||||||
|
chunked_verts = []
|
||||||
|
chunked_faces = []
|
||||||
|
chunked_materials = []
|
||||||
|
chunked_material_ids = []
|
||||||
|
material_offset = 0
|
||||||
|
max_slot_index = 0
|
||||||
|
offset = 0
|
||||||
|
|
||||||
if not iterator.next():
|
if not iterator.next():
|
||||||
if not has_processed_chunk:
|
if not has_processed_chunk:
|
||||||
|
mats = np.concatenate(chunked_materials)
|
||||||
|
midx = np.concatenate(chunked_material_ids)
|
||||||
|
mats, mapping = np.unique(mats, axis=0, return_inverse=True)
|
||||||
|
midx = mapping[midx]
|
||||||
|
|
||||||
|
mat_results = []
|
||||||
|
for mat in mats:
|
||||||
|
mat = tuple(mat)
|
||||||
|
blender_mat = blender_mats.get(mat, None)
|
||||||
|
if not blender_mat:
|
||||||
|
blender_mat = bpy.data.materials.new("Chunk")
|
||||||
|
blender_mat.diffuse_color = mat
|
||||||
|
blender_mats[mat] = blender_mat
|
||||||
|
mat_results.append(blender_mat)
|
||||||
|
|
||||||
# The left over chunk
|
# The left over chunk
|
||||||
chunk = iterator.get_chunk()
|
self.create_object(
|
||||||
for colour in chunk.colours:
|
np.concatenate(chunked_verts),
|
||||||
blender_mat = bpy.data.materials.new(str(total_materials))
|
np.concatenate(chunked_faces),
|
||||||
blender_mat.diffuse_color = list(colour)
|
mat_results,
|
||||||
self.materials.append(blender_mat)
|
midx,
|
||||||
total_materials += 1
|
chunked_guids,
|
||||||
self.create_object(chunk)
|
chunked_guid_ids,
|
||||||
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
bpy.context.scene.collection.children.link(self.collection)
|
bpy.context.scene.collection.children.link(self.collection)
|
||||||
@@ -1747,12 +1839,7 @@ class LoadLinkedProject(bpy.types.Operator):
|
|||||||
|
|
||||||
self.collection.objects.link(obj)
|
self.collection.objects.link(obj)
|
||||||
|
|
||||||
def create_object(self, chunk):
|
def create_object(self, verts, faces, materials, material_ids, guids, guid_ids):
|
||||||
verts = chunk.get_verts()
|
|
||||||
faces = chunk.get_faces()
|
|
||||||
materials = chunk.get_materials()
|
|
||||||
material_ids = chunk.get_material_ids()
|
|
||||||
|
|
||||||
num_vertices = len(verts) // 3
|
num_vertices = len(verts) // 3
|
||||||
if not num_vertices:
|
if not num_vertices:
|
||||||
return
|
return
|
||||||
@@ -1765,7 +1852,7 @@ class LoadLinkedProject(bpy.types.Operator):
|
|||||||
mesh = bpy.data.meshes.new("Mesh")
|
mesh = bpy.data.meshes.new("Mesh")
|
||||||
|
|
||||||
for material in materials:
|
for material in materials:
|
||||||
mesh.materials.append(self.materials[material])
|
mesh.materials.append(material)
|
||||||
|
|
||||||
mesh.vertices.add(num_vertices)
|
mesh.vertices.add(num_vertices)
|
||||||
mesh.vertices.foreach_set("co", verts)
|
mesh.vertices.foreach_set("co", verts)
|
||||||
@@ -1782,8 +1869,8 @@ class LoadLinkedProject(bpy.types.Operator):
|
|||||||
mesh.update()
|
mesh.update()
|
||||||
|
|
||||||
obj = bpy.data.objects.new("Chunk", mesh)
|
obj = bpy.data.objects.new("Chunk", mesh)
|
||||||
obj["guids"] = list(chunk.guids)
|
obj["guids"] = list(guids)
|
||||||
obj["guid_ids"] = list(chunk.guid_ids)
|
obj["guid_ids"] = list(guid_ids)
|
||||||
obj["db"] = self.db_filepath
|
obj["db"] = self.db_filepath
|
||||||
|
|
||||||
self.collection.objects.link(obj)
|
self.collection.objects.link(obj)
|
||||||
@@ -2098,7 +2185,7 @@ class RefreshClippingPlanes(bpy.types.Operator):
|
|||||||
obj = clipping_plane.obj
|
obj = clipping_plane.obj
|
||||||
if not obj:
|
if not obj:
|
||||||
continue
|
continue
|
||||||
print('doing', obj)
|
print("doing", obj)
|
||||||
|
|
||||||
bm = bmesh.new()
|
bm = bmesh.new()
|
||||||
bm.from_mesh(obj.data)
|
bm.from_mesh(obj.data)
|
||||||
@@ -2108,11 +2195,11 @@ class RefreshClippingPlanes(bpy.types.Operator):
|
|||||||
bm.faces.ensure_lookup_table()
|
bm.faces.ensure_lookup_table()
|
||||||
face = bm.faces[0]
|
face = bm.faces[0]
|
||||||
center = world_matrix @ face.calc_center_median()
|
center = world_matrix @ face.calc_center_median()
|
||||||
print('center', center)
|
print("center", center)
|
||||||
normal = world_matrix.to_3x3() @ face.normal * -1
|
normal = world_matrix.to_3x3() @ face.normal * -1
|
||||||
center += normal * -0.01
|
center += normal * -0.01
|
||||||
print('normal', normal)
|
print("normal", normal)
|
||||||
print('new center', center)
|
print("new center", center)
|
||||||
|
|
||||||
normal.normalize()
|
normal.normalize()
|
||||||
distance = -center.dot(normal)
|
distance = -center.dot(normal)
|
||||||
@@ -2212,7 +2299,7 @@ class asdfasdf(bpy.types.Operator):
|
|||||||
start = time.time()
|
start = time.time()
|
||||||
|
|
||||||
# self.filepath = "/home/dion/drive/ifcs/racbasicsampleproject.ifc"
|
# self.filepath = "/home/dion/drive/ifcs/racbasicsampleproject.ifc"
|
||||||
self.filepath = '/home/dion/drive/ifcs/TXG_sample_project-fixed-IFC4.ifc'
|
self.filepath = "/home/dion/drive/ifcs/TXG_sample_project-fixed-IFC4.ifc"
|
||||||
# self.filepath = "/home/dion/tmp/petrubug/F-ELECT.ifc"
|
# self.filepath = "/home/dion/tmp/petrubug/F-ELECT.ifc"
|
||||||
print("doing", self.filepath)
|
print("doing", self.filepath)
|
||||||
|
|
||||||
@@ -2336,8 +2423,8 @@ class qwerqwer(bpy.types.Operator):
|
|||||||
start = time.time()
|
start = time.time()
|
||||||
|
|
||||||
# self.filepath = "/home/dion/drive/ifcs/racbasicsampleproject.ifc"
|
# self.filepath = "/home/dion/drive/ifcs/racbasicsampleproject.ifc"
|
||||||
self.filepath = '/home/dion/drive/ifcs/TXG_sample_project-fixed-IFC4.ifc'
|
# self.filepath = '/home/dion/drive/ifcs/TXG_sample_project-fixed-IFC4.ifc'
|
||||||
# self.filepath = "/home/dion/tmp/petrubug/F-ELECT.ifc"
|
self.filepath = "/home/dion/tmp/petrubug/F-ELECT.ifc"
|
||||||
print("doing", self.filepath)
|
print("doing", self.filepath)
|
||||||
|
|
||||||
self.collection = bpy.data.collections.new("IfcProject/" + os.path.basename(self.filepath))
|
self.collection = bpy.data.collections.new("IfcProject/" + os.path.basename(self.filepath))
|
||||||
@@ -2371,9 +2458,6 @@ class qwerqwer(bpy.types.Operator):
|
|||||||
self.meshes = {}
|
self.meshes = {}
|
||||||
blender_mats = {}
|
blender_mats = {}
|
||||||
|
|
||||||
total_materials = 0
|
|
||||||
self.materials = []
|
|
||||||
|
|
||||||
chunked_verts = []
|
chunked_verts = []
|
||||||
chunked_faces = []
|
chunked_faces = []
|
||||||
chunked_materials = []
|
chunked_materials = []
|
||||||
@@ -2381,7 +2465,7 @@ class qwerqwer(bpy.types.Operator):
|
|||||||
material_offset = 0
|
material_offset = 0
|
||||||
max_slot_index = 0
|
max_slot_index = 0
|
||||||
chunk_size = 10000
|
chunk_size = 10000
|
||||||
r4 = np.array([[0,0,0,1]])
|
r4 = np.array([[0, 0, 0, 1]])
|
||||||
offset = 0
|
offset = 0
|
||||||
|
|
||||||
ci = 0
|
ci = 0
|
||||||
@@ -2389,14 +2473,14 @@ class qwerqwer(bpy.types.Operator):
|
|||||||
while True:
|
while True:
|
||||||
shape = iterator.get()
|
shape = iterator.get()
|
||||||
|
|
||||||
|
has_processed_chunk = False
|
||||||
|
|
||||||
ms = np.vstack([default_mat, np.frombuffer(shape.geometry.colors_buffer).reshape((-1, 4))])
|
ms = np.vstack([default_mat, np.frombuffer(shape.geometry.colors_buffer).reshape((-1, 4))])
|
||||||
mi = np.frombuffer(shape.geometry.material_ids_buffer, dtype=np.int32)
|
mi = np.frombuffer(shape.geometry.material_ids_buffer, dtype=np.int32)
|
||||||
chunked_materials.append(ms)
|
chunked_materials.append(ms)
|
||||||
chunked_material_ids.append(mi + material_offset + 1)
|
chunked_material_ids.append(mi + material_offset + 1)
|
||||||
material_offset += len(ms)
|
material_offset += len(ms)
|
||||||
|
|
||||||
has_processed_chunk = False
|
|
||||||
|
|
||||||
M4 = np.frombuffer(shape.transformation_buffer).reshape((4, 3))
|
M4 = np.frombuffer(shape.transformation_buffer).reshape((4, 3))
|
||||||
M4 = np.concatenate((M4.T, r4))
|
M4 = np.concatenate((M4.T, r4))
|
||||||
vs = np.frombuffer(shape.geometry.verts_buffer).reshape((-1, 3))
|
vs = np.frombuffer(shape.geometry.verts_buffer).reshape((-1, 3))
|
||||||
@@ -2426,7 +2510,9 @@ class qwerqwer(bpy.types.Operator):
|
|||||||
blender_mats[mat] = blender_mat
|
blender_mats[mat] = blender_mat
|
||||||
mat_results.append(blender_mat)
|
mat_results.append(blender_mat)
|
||||||
|
|
||||||
self.create_object(np.concatenate(chunked_verts), np.concatenate(chunked_faces), mat_results, midx)
|
self.create_object(
|
||||||
|
np.concatenate(chunked_verts), np.concatenate(chunked_faces), mat_results, midx
|
||||||
|
)
|
||||||
chunked_verts = []
|
chunked_verts = []
|
||||||
chunked_faces = []
|
chunked_faces = []
|
||||||
chunked_materials = []
|
chunked_materials = []
|
||||||
@@ -2454,7 +2540,9 @@ class qwerqwer(bpy.types.Operator):
|
|||||||
mat_results.append(blender_mat)
|
mat_results.append(blender_mat)
|
||||||
|
|
||||||
# The left over chunk
|
# The left over chunk
|
||||||
self.create_object(np.concatenate(chunked_verts), np.concatenate(chunked_faces), mat_results, midx)
|
self.create_object(
|
||||||
|
np.concatenate(chunked_verts), np.concatenate(chunked_faces), mat_results, midx
|
||||||
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
bpy.context.scene.collection.children.link(self.collection)
|
bpy.context.scene.collection.children.link(self.collection)
|
||||||
@@ -2509,7 +2597,7 @@ class qwerqwer2(bpy.types.Operator):
|
|||||||
start = time.time()
|
start = time.time()
|
||||||
|
|
||||||
# self.filepath = "/home/dion/drive/ifcs/racbasicsampleproject.ifc"
|
# self.filepath = "/home/dion/drive/ifcs/racbasicsampleproject.ifc"
|
||||||
self.filepath = '/home/dion/drive/ifcs/TXG_sample_project-fixed-IFC4.ifc'
|
self.filepath = "/home/dion/drive/ifcs/TXG_sample_project-fixed-IFC4.ifc"
|
||||||
# self.filepath = "/home/dion/tmp/petrubug/F-ELECT.ifc"
|
# self.filepath = "/home/dion/tmp/petrubug/F-ELECT.ifc"
|
||||||
print("doing", self.filepath)
|
print("doing", self.filepath)
|
||||||
|
|
||||||
@@ -2554,7 +2642,7 @@ class qwerqwer2(bpy.types.Operator):
|
|||||||
chunked_material_ids = []
|
chunked_material_ids = []
|
||||||
max_slot_index = 0
|
max_slot_index = 0
|
||||||
chunk_size = 10000
|
chunk_size = 10000
|
||||||
r4 = np.array([[0,0,0,1]])
|
r4 = np.array([[0, 0, 0, 1]])
|
||||||
offset = 0
|
offset = 0
|
||||||
|
|
||||||
ci = 0
|
ci = 0
|
||||||
@@ -2596,7 +2684,6 @@ class qwerqwer2(bpy.types.Operator):
|
|||||||
max_slot_index += 1
|
max_slot_index += 1
|
||||||
material_to_slot[-1] = slot_index
|
material_to_slot[-1] = slot_index
|
||||||
|
|
||||||
|
|
||||||
# Numpy alternative
|
# Numpy alternative
|
||||||
"""
|
"""
|
||||||
# Convert material_to_slot dictionary to a NumPy array
|
# Convert material_to_slot dictionary to a NumPy array
|
||||||
@@ -2660,7 +2747,6 @@ class qwerqwer2(bpy.types.Operator):
|
|||||||
# Discard the homogeneous coordinate and flatten the array
|
# Discard the homogeneous coordinate and flatten the array
|
||||||
return transformed_vertices[:, :3].flatten()
|
return transformed_vertices[:, :3].flatten()
|
||||||
|
|
||||||
|
|
||||||
def create_object(self, verts, faces, materials, material_ids):
|
def create_object(self, verts, faces, materials, material_ids):
|
||||||
num_vertices = len(verts) // 3
|
num_vertices = len(verts) // 3
|
||||||
if not num_vertices:
|
if not num_vertices:
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
|
import blenderbim.tool as tool
|
||||||
from bpy.types import WorkSpaceTool
|
from bpy.types import WorkSpaceTool
|
||||||
from blenderbim.bim.module.project.data import LinksData
|
from blenderbim.bim.module.project.data import LinksData
|
||||||
|
|
||||||
@@ -30,13 +31,42 @@ class QueryTool(bpy.types.WorkSpaceTool):
|
|||||||
bl_icon = "ops.generic.select_circle"
|
bl_icon = "ops.generic.select_circle"
|
||||||
bl_widget = None
|
bl_widget = None
|
||||||
bl_keymap = (
|
bl_keymap = (
|
||||||
("bim.query_linked_element", {"type": "LEFTMOUSE", "value": "PRESS"}, None),
|
("bim.query_linked_element", {"type": "RIGHTMOUSE", "value": "PRESS"}, None),
|
||||||
# ("bim.project_hotkey", {"type": "C", "value": "PRESS", "alt": True}, {"properties": [("hotkey", "A_C")]}),
|
("bim.query_hotkey", {"type": "C", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_C")]}),
|
||||||
|
("bim.query_hotkey", {"type": "C", "value": "PRESS", "alt": True}, {"properties": [("hotkey", "A_C")]}),
|
||||||
)
|
)
|
||||||
|
|
||||||
def draw_settings(context, layout, ws_tool):
|
def draw_settings(context, layout, ws_tool):
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.label(text="Query Object", icon="MOUSE_LMB")
|
row.label(text="Query Object", icon="MOUSE_RMB")
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.label(text="", icon="EVENT_SHIFT")
|
||||||
|
row.label(text="Add Clipping Plane", icon="EVENT_C")
|
||||||
row = layout.row(align=True)
|
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")
|
||||||
|
|
||||||
|
|
||||||
|
class QueryHotkey(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.query_hotkey"
|
||||||
|
bl_label = "Query Hotkey"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
hotkey: bpy.props.StringProperty()
|
||||||
|
description: bpy.props.StringProperty()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def description(cls, context, operator):
|
||||||
|
return operator.description or ""
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
getattr(self, f"hotkey_{self.hotkey}")()
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
def hotkey_S_C(self):
|
||||||
|
bpy.ops.bim.create_clipping_plane("INVOKE_DEFAULT")
|
||||||
|
|
||||||
|
def hotkey_A_C(self):
|
||||||
|
if LinksData.enable_culling:
|
||||||
|
bpy.ops.bim.disable_culling()
|
||||||
|
else:
|
||||||
|
bpy.ops.bim.enable_culling("INVOKE_DEFAULT")
|
||||||
|
|||||||
Reference in New Issue
Block a user