Skip to content

Commit 7eaef36

Browse files
committed
Ver. 1.2.0
- Add support for non-mesh objects (Curve, Surface, Metaball, Text) - Add support for objects that use Modifiers
1 parent e4133ba commit 7eaef36

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
bl_info = {
22
"name": "Snap Cursor to Bounding Box",
33
"author": "Toda Shuta",
4-
"version": (1, 1, 0),
4+
"version": (1, 2, 0),
55
"blender": (2, 79, 0),
66
"location": "View3D > Shift-S (Snap Menu)",
77
"description": "Snap Cursor to Bounding Box (Top, Center, Bottom)",

snap_cursor_to_bounding_box.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ def snapCursorToBoudingBox(context, report, *, mode="MIDDLE"):
77
selected_objects = context.selected_objects
88

99
for ob in selected_objects:
10-
if ob.type == "MESH":
11-
vertices.extend([ob.matrix_world * v.co for v in ob.data.vertices])
12-
else:
13-
report({"WARNING"}, "Ignored Unsupported Object: {}".format(ob.name))
10+
try:
11+
obj_data = ob.to_mesh(context.scene, True, "PREVIEW")
12+
vertices.extend([ob.matrix_world * v.co for v in obj_data.vertices])
13+
bpy.data.meshes.remove(obj_data)
14+
except RuntimeError:
15+
report({"WARNING"}, "Unsupported Object: `{}' [{}]".format(ob.name, ob.type))
1416

1517
if len(vertices) == 0:
1618
return {"CANCELLED"}
@@ -30,10 +32,12 @@ def addBoundingBoxEmptyCube(context, report):
3032
selected_objects = context.selected_objects
3133

3234
for ob in selected_objects:
33-
if ob.type == "MESH":
34-
vertices.extend([ob.matrix_world * v.co for v in ob.data.vertices])
35-
else:
36-
report({"WARNING"}, "Ignored Unsupported Object: {}".format(ob.name))
35+
try:
36+
obj_data = ob.to_mesh(context.scene, True, "PREVIEW")
37+
vertices.extend([ob.matrix_world * v.co for v in obj_data.vertices])
38+
bpy.data.meshes.remove(obj_data)
39+
except RuntimeError:
40+
report({"WARNING"}, "Unsupported Object: `{}' [{}]".format(ob.name, ob.type))
3741

3842
if len(vertices) == 0:
3943
return {"CANCELLED"}

0 commit comments

Comments
 (0)