def scene_load_post(_): def convert(id, *prop_groups): prop_map = {"export_path": "path", "engine_path": "studiomdl_custom_path", "export_format": "format"} for p_g in prop_groups: for prop in [prop for prop in p_g.__dict__.keys() if prop[0] != '_']: val = id.get("smd_" + (prop_map[prop] if prop in prop_map else prop)) if val != None: id.vs[prop] = val for prop in id.keys(): if prop.startswith("smd_"): del id[prop] for s in bpy.data.scenes: convert(s, ValveSource_SceneProps) game_path_changed(s, bpy.context) engine_path_changed(s, bpy.context) for ob in bpy.data.objects: convert(ob, ValveSource_ObjectProps, ExportableProps) for a in bpy.data.armatures: convert(a, ValveSource_ArmatureProps) for g in bpy.data.groups: convert(g, ValveSource_GroupProps, ExportableProps) for g in bpy.data.curves: convert(g, ValveSource_CurveProps, ShapeTypeProps) for g in bpy.data.meshes: convert(g, ValveSource_MeshProps, ShapeTypeProps) if scene_load_post in scene_update_post: scene_update_post.remove(scene_load_post)
def RemoveHandler(): #Scene upate handler if handler_key in driver_namespace: if driver_namespace[handler_key] in frame_change_post: frame_change_post.remove(driver_namespace[handler_key]) #print("Handler Removed") if driver_namespace[handler_key] in scene_update_post: scene_update_post.remove(driver_namespace[handler_key]) #print("Handler Removed") del driver_namespace[handler_key]
def scene_load_post(_): def convert(id, *prop_groups): prop_map = { "export_path": "path", "engine_path": "studiomdl_custom_path", "export_format": "format" } for p_g in prop_groups: for prop in [ prop for prop in p_g.__dict__.keys() if prop[0] != '_' ]: val = id.get("smd_" + (prop_map[prop] if prop in prop_map else prop)) if val != None: id.vs[prop] = val for prop in id.keys(): if prop.startswith("smd_"): del id[prop] for s in bpy.data.scenes: if hasattr(s, "vs"): convert(s, ValveSource_SceneProps) game_path_changed(s, bpy.context) engine_path_changed(s, bpy.context) for ob in bpy.data.objects: convert(ob, ValveSource_ObjectProps, ExportableProps) for a in bpy.data.armatures: convert(a, ValveSource_ArmatureProps) for g in bpy.data.groups: convert(g, ValveSource_GroupProps, ExportableProps) for c in bpy.data.curves: convert(c, ValveSource_CurveProps, ShapeTypeProps) for m in bpy.data.meshes: convert(m, ValveSource_MeshProps, ShapeTypeProps) for vert_map in m.vertex_colors: if vert_map.name == "ValveSource_VertexPaintTintColor": vert_map.name = "valvesource_vertex_paint" elif vert_map.name == "ValveSource_VertexPaintBlendParams": vert_map.name = "valvesource_vertex_blend" elif vert_map.name == "ValveSource_VertexPaintBlendParams.001": vert_map.name = "valvesource_vertex_blend1" if scene_load_post in scene_update_post: scene_update_post.remove(scene_load_post)
def scene_load_post(_): def convert(id,*prop_groups): prop_map = { "export_path":"path", "engine_path":"studiomdl_custom_path", "export_format":"format" } for p_g in prop_groups: for prop in [prop for prop in p_g.__dict__.keys() if prop[0] != '_']: val = id.get("smd_" + (prop_map[prop] if prop in prop_map else prop)) if val != None: id.vs[prop] = val for prop in id.keys(): if prop.startswith("smd_"): del id[prop] for s in bpy.data.scenes: if hasattr(s,"vs"): convert(s,ValveSource_SceneProps) game_path_changed(s,bpy.context) engine_path_changed(s,bpy.context) for ob in bpy.data.objects: convert(ob,ValveSource_ObjectProps, ExportableProps) for a in bpy.data.armatures: convert(a,ValveSource_ArmatureProps) for g in bpy.data.groups: convert(g,ValveSource_GroupProps, ExportableProps) for c in bpy.data.curves: convert(c,ValveSource_CurveProps, ShapeTypeProps) for m in bpy.data.meshes: convert(m,ValveSource_MeshProps, ShapeTypeProps) for vert_map in m.vertex_colors: if vert_map.name == "ValveSource_VertexPaintTintColor": vert_map.name = "valvesource_vertex_paint" elif vert_map.name == "ValveSource_VertexPaintBlendParams": vert_map.name = "valvesource_vertex_blend" elif vert_map.name == "ValveSource_VertexPaintBlendParams.001": vert_map.name = "valvesource_vertex_blend1" if scene_load_post in scene_update_post: scene_update_post.remove(scene_load_post)
def unhook_scene_update(): if scene_update in scene_update_post: scene_update_post.remove(scene_update)
# Python doesn't reload package sub-modules at the same time as __init__.py! import imp import sys for filename in [f for f in os.listdir(os.path.dirname(os.path.realpath(__file__))) if f.endswith(".py")]: if filename == os.path.basename(__file__): continue mod = sys.modules.get("{}.{}".format(__name__, filename[:-3])) if mod: imp.reload(mod) # clear out any scene update funcs hanging around, e.g. after a script reload from bpy.app.handlers import scene_update_post for func in scene_update_post: if func.__module__.startswith(__name__): scene_update_post.remove(func) from . import datamodel, import_smd, export_smd, flex, GUI from .utils import * class ValveSource_Exportable(bpy.types.PropertyGroup): ob_type = StringProperty() icon = StringProperty() item_name = StringProperty() def get_id(self): try: if self.ob_type == 'GROUP': return bpy.data.groups[self.item_name] if self.ob_type in ['ACTION', 'OBJECT']:
def unregister(): scene_update_post.remove(update)