Skip to content

Commit

Permalink
[#6][#98]Function cleanup fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dwhite5914 committed Mar 14, 2016
1 parent c1ceae1 commit d055078
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
8 changes: 4 additions & 4 deletions io_export_cryblend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def __add_proxy(self, object_):
bpy.ops.object.origin_set(type="ORIGIN_CURSOR")
object_.select = False
bound_box.select = True
bpy.context.active_object = bound_box
utils.set_active(bound_box)
bpy.ops.object.origin_set(type="ORIGIN_CURSOR")
bpy.context.scene.cursor_location = old_cursor

Expand Down Expand Up @@ -390,7 +390,7 @@ def execute(self, context):
selected_vert[2]))
empty_object = bpy.context.active_object
empty_object.name = name_branch(True)
bpy.context.active_object = active_object
utils.set_active(active_object)
bpy.ops.object.mode_set(mode='EDIT')

message = "Adding Branch"
Expand Down Expand Up @@ -429,7 +429,7 @@ def execute(self, context):
selected_vert[2]))
empty_object = bpy.context.active_object
empty_object.name = name_branch(False)
bpy.context.active_object = active_object
utils.set_active(active_object)
bpy.ops.object.mode_set(mode='EDIT')

message = "Adding Branch Joint"
Expand Down Expand Up @@ -1511,7 +1511,7 @@ def execute(self, context):
uv = True
break
if not uv:
bpy.context.active_object = object_
utils.set_active(object_)
bpy.ops.mesh.uv_texture_add()
message = "Added UV map to {}".format(object_.name)
self.report({'INFO'}, message)
Expand Down
2 changes: 1 addition & 1 deletion io_export_cryblend/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def __export_library_geometries(self, parent_element):
libgeo = self.__doc.createElement("library_geometries")
parent_element.appendChild(libgeo)
for object_ in utils.get_type("geometry"):
bpy.context.active_object = object_
utils.set_active(object_)
if object_.mode != 'OBJECT':
bpy.ops.object.mode_set(mode='OBJECT')
object_.data.update(calc_tessface=1)
Expand Down
16 changes: 13 additions & 3 deletions io_export_cryblend/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ def get_node_name(node):


def get_node_type(node):
node_components = node.split(".")
node_components = node.name.split(".")
return node_components[-1]


Expand Down Expand Up @@ -686,7 +686,13 @@ def add_fakebones():
if armature is None:
return

skeleton = armature.data
try:
skeleton = bpy.data.armatures[armature.name]
except:
raise TypeError(
"Armature object name and object data name must " +
"be same! You may set it in properties or outliner editor.")

skeleton.pose_position = 'REST'
time.sleep(0.5)

Expand Down Expand Up @@ -856,7 +862,7 @@ def apply_animation_scale(armature):
cbPrint("Baked Animation successfully on empties.")
deselect_all()

bpy.context.active_object = armature
set_active(armature)
armature.select = True
bpy.ops.anim.keyframe_clear_v3d()

Expand Down Expand Up @@ -977,6 +983,10 @@ def deselect_all():
object_.select = False


def set_active(object_):
bpy.context.scene.objects.active = object_


def get_object_children(parent):
return [child for child in parent.children
if child.type in {'ARMATURE', 'EMPTY', 'MESH'}]
Expand Down

0 comments on commit d055078

Please sign in to comment.