Browse Source

move blender script code into functions

master
poikilos 5 years ago
committed by Jacob Gustafson
parent
commit
ee31727094
  1. 22
      utilities/blender/generate_lua_collisionbox.py

22
utilities/blender/generate_lua_collisionbox.py

@ -42,12 +42,14 @@ import bpy
from mathutils import Vector
# from mathutils import Euler
ob1 = None
try:
def calculate_one():
ob1 = None
try:
ob1 = obj.select_get()
except:
except:
# < 2.8
ob1 = bpy.context.scene.objects.active
calculate_collisionbox(ob1)
class MessageBox(bpy.types.Operator):
@ -79,17 +81,19 @@ bpy.utils.register_class(MessageBox)
msgSuffix = ""
mesh = None
if ob1 is not None:
def calculate_collisionbox(ob1):
global msgSuffix
mesh = None
if ob1 is not None:
mesh = ob1.data
if ob1 is None:
if ob1 is None:
msg = "Nothing is selected."
bpy.ops.message.messagebox('INVOKE_DEFAULT', message = msg)
elif (mesh is not None) and (not hasattr(mesh, 'vertices')):
elif (mesh is not None) and (not hasattr(mesh, 'vertices')):
msg = "Collision box for armatures cannot be calculated."
bpy.ops.message.messagebox('INVOKE_DEFAULT', message = msg)
else:
else:
# extents1 = ob1.dimensions.copy()
obj1Loc = ob1.location
@ -245,3 +249,5 @@ else:
# Unregistering before user clicks the MessageBox will crash Blender!
# bpy.utils.unregister_class(MessageBox)
calculate_one()

Loading…
Cancel
Save