[Bf-extensions-cvs] [21158cf1] master: Skinify: Small cleanup, use properties group
lijenstina
noreply at git.blender.org
Thu Jun 1 14:47:47 CEST 2017
Commit: 21158cf1554e7a224c5ac519143f7cc900ee3c51
Author: lijenstina
Date: Thu Jun 1 14:46:49 2017 +0200
Branches: master
https://developer.blender.org/rBA21158cf1554e7a224c5ac519143f7cc900ee3c51
Skinify: Small cleanup, use properties group
Bump version on 0.8.1
Pep8 cleanup
Move the properties to a PropertyGroup
they can be accessed with context.scene.skinify
Properties names and tooltips cleanup
Use layout.split for some of the UI code
Remove the app.handler on unregister and add
an additional check in the init_props function
===================================================================
M object_skinify.py
===================================================================
diff --git a/object_skinify.py b/object_skinify.py
index 206fa55b..354fedc0 100644
--- a/object_skinify.py
+++ b/object_skinify.py
@@ -19,7 +19,7 @@
bl_info = {
"name": "Skinify Rig",
"author": "Albert Makac (karab44)",
- "version": (0, 8),
+ "version": (0, 8, 1),
"blender": (2, 7, 8),
"location": "Properties > Bone > Skinify Rig (visible on pose mode only)",
"description": "Creates a mesh object from selected bones",
@@ -27,81 +27,40 @@ bl_info = {
"wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Object/Skinify",
"category": "Object"}
-# NOTE: there are some unused scene variables around commented out
-# is the persintent scene props needed or can a property group be used instead?
-
import bpy
from bpy.props import (
FloatProperty,
IntProperty,
- BoolProperty
+ BoolProperty,
+ PointerProperty,
+ )
+from bpy.types import (
+ Operator,
+ Panel,
+ PropertyGroup,
+ )
+from mathutils import (
+ Vector,
+ Euler,
)
-# from bpy_extras import object_utils
-from mathutils import Vector, Euler
from bpy.app.handlers import persistent
-bpy.types.Scene.sub_level = IntProperty(
- name="sub_level",
- min=0, max=4,
- default=1,
- description="mesh density"
- )
-bpy.types.Scene.thickness = FloatProperty(
- name="thickness",
- min=0.01,
- default=0.8,
- description="adjust shape thickness"
- )
-bpy.types.Scene.finger_thickness = FloatProperty(
- name="finger_thickness",
- min=0.01, max=1.0,
- default=0.25,
- description="adjust finger thickness relative to body"
- )
-bpy.types.Scene.connect_mesh = BoolProperty(
- name="solid_shape",
- default=False,
- description="makes solid shape from bone chains"
- )
-bpy.types.Scene.connect_parents = BoolProperty(
- name="fill_gaps",
- default=False,
- description="fills the gaps between parented bones"
- )
-bpy.types.Scene.generate_all = BoolProperty(
- name="all_shapes",
- default=False,
- description="generates shapes from all bones"
- )
-bpy.types.Scene.head_ornaments = BoolProperty(
- name="head_ornaments",
- default=False,
- description="includes head ornaments"
- )
-bpy.types.Scene.apply_mod = BoolProperty(
- name="apply_modifiers",
- default=True,
- description="applies Modifiers to mesh"
- )
-bpy.types.Scene.parent_armature = BoolProperty(
- name="parent_armature",
- default=True,
- description="applies mesh to Armature"
- )
-
# initialize properties
def init_props():
- scn = bpy.context.scene
+ # additional check - this should be a rare case if the handler
+ # wasn't removed for some reason and the addon is not toggled on/off
+ if hasattr(bpy.types.Scene, "skinify"):
+ scn = bpy.context.scene.skinify
- scn.connect_mesh = False
- scn.connect_parents = False
- scn.generate_all = False
- scn.thickness = 0.8
- scn.finger_thickness = 0.25
- scn.apply_mod = True
- scn.parent_armature = True
- scn.sub_level = 1
+ scn.connect_mesh = False
+ scn.connect_parents = False
+ scn.generate_all = False
+ scn.thickness = 0.8
+ scn.finger_thickness = 0.25
+ scn.apply_mod = True
+ scn.parent_armature = True
+ scn.sub_level = 1
# selects vertices
@@ -161,8 +120,8 @@ def generate_edges(mesh, shape_object, bones, scale, connect_mesh=False, connect
rig_type = 2
break
if b.name == 'spine' and b.rigify_type == 'spines.super_spine':
- ignore_list = ignore_list + rigify_new_ignore_list
- rig_type = 3
+ ignore_list = ignore_list + rigify_new_ignore_list
+ rig_type = 3
break
# edge generator loop
@@ -176,44 +135,43 @@ def generate_edges(mesh, shape_object, bones, scale, connect_mesh=False, connect
found = False
for i in ignore_list:
- if i in b.name.lower():
+ if i in b.name.lower():
found = True
break
if found and generate_all is False:
continue
-
- #fix for drawing rootbone and relationship lines
+
+ # fix for drawing rootbone and relationship lines
if 'root' in b.name.lower() and generate_all is False:
continue
-
# ignore any head ornaments
- if head_ornaments is False:
+ if head_ornaments is False:
if b.parent is not None:
-
- if 'head' in b.parent.name.lower() and not rig_type == 3:
+
+ if 'head' in b.parent.name.lower() and not rig_type == 3:
continue
-
- if 'face' in b.parent.name.lower() and rig_type == 3:
+
+ if 'face' in b.parent.name.lower() and rig_type == 3:
continue
if connect_parents:
if b.parent is not None and b.parent.bone.select is True and b.bone.use_connect is False:
if 'root' in b.parent.name.lower() and generate_all is False:
continue
- #ignore shoulder
+ # ignore shoulder
if 'shoulder' in b.name.lower() and connect_mesh is True:
continue
- #connect the upper arm directly with chest ommiting shoulders
+ # connect the upper arm directly with chest ommiting shoulders
if 'shoulder' in b.parent.name.lower() and connect_mesh is True:
vert1 = b.head
- vert2 = b.parent.parent.tail
-
+ vert2 = b.parent.parent.tail
+
else:
vert1 = b.head
vert2 = b.parent.tail
-
+
verts.append(vert1)
verts.append(vert2)
edges.append([idx, idx + 1])
@@ -230,8 +188,7 @@ def generate_edges(mesh, shape_object, bones, scale, connect_mesh=False, connect
(generate_all is False and (b.name == 'hips' and rig_type == 1) or
(b.name == 'spine' and rig_type == 2) or (b.name == 'spine' and rig_type == 3))):
continue
-
-
+
vert1 = b.head
vert2 = b.tail
verts.append(vert1)
@@ -263,8 +220,6 @@ def generate_mesh(shape_object, size, thickness=0.8, finger_thickness=0.25, sub_
"""
This function adds modifiers for generated edges
"""
- # scn = bpy.context.scene
-
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')
@@ -289,10 +244,11 @@ def generate_mesh(shape_object, size, thickness=0.8, finger_thickness=0.25, sub_
# calculate optimal thickness for defaults
bpy.ops.object.skin_root_mark(override)
bpy.ops.transform.skin_resize(override,
- value=(1 * thickness * (size / 10), 1 * thickness * (size / 10), 1 * thickness * (size / 10)),
- constraint_axis=(False, False, False), constraint_orientation='GLOBAL',
- mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH',
- proportional_size=1)
+ value=(1 * thickness * (size / 10), 1 * thickness * (size / 10), 1 * thickness * (size / 10)),
+ constraint_axis=(False, False, False), constraint_orientation='GLOBAL',
+ mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH',
+ proportional_size=1
+ )
shape_object.modifiers["Skin"].use_smooth_shade = True
shape_object.modifiers["Skin"].use_x_symmetry = True
@@ -303,10 +259,11 @@ def generate_mesh(shape_object, size, thickness=0.8, finger_thickness=0.25, sub_
bpy.ops.object.skin_loose_mark_clear(override, action='MARK')
# by default set fingers thickness to 25 percent of body thickness
bpy.ops.transform.skin_resize(override,
- value=(finger_thickness, finger_thickness, finger_thickness),
- constraint_axis=(False, False, False), constraint_orientation='GLOBAL',
- mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH',
- proportional_size=1)
+ value=(finger_thickness, finger_thickness, finger_thickness),
+ constraint_axis=(False, False, False), constraint_orientation='GLOBAL',
+ mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH',
+ proportional_size=1
+ )
# make loose hands only for better topology
# bpy.ops.mesh.select_all(action='DESELECT')
@@ -323,50 +280,53 @@ def generate_mesh(shape_object, size, thickness=0.8, finger_thickness=0.25, sub_
corrective_thickness = 2.5
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list