[Bf-extensions-cvs] [66100ac] master: Add Chain: Cleanup, improve tooltip

lijenstina noreply at git.blender.org
Sun Mar 26 17:50:00 CEST 2017


Commit: 66100acb7648378c46f71c6b513dd522835afb1f
Author: lijenstina
Date:   Sun Mar 26 17:49:05 2017 +0200
Branches: master
https://developer.blender.org/rBA66100acb7648378c46f71c6b513dd522835afb1f

Add Chain: Cleanup, improve tooltip

Bumped version to 0.1.2
Pep8 Cleanup
imports as tuples
More descriptive tooltip

===================================================================

M	object_add_chain.py

===================================================================

diff --git a/object_add_chain.py b/object_add_chain.py
index 264b550..6ed2b96 100644
--- a/object_add_chain.py
+++ b/object_add_chain.py
@@ -19,21 +19,25 @@
 bl_info = {
     "name": "Add Chain",
     "author": "Brian Hinton (Nichod)",
-    "version": (0, 1, 1),
+    "version": (0, 1, 2),
     "blender": (2, 71, 0),
     "location": "Toolshelf > Create Tab",
     "description": "Adds Chain with curve guide for easy creation",
     "warning": "",
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
-        "Scripts/Object/Add_Chain",
+    "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
+                "Scripts/Object/Add_Chain",
     "category": "Object",
 }
 
 import bpy
-from bpy.types import Operator, Panel
+from bpy.types import (
+        Operator,
+        Panel,
+        )
+
 
 def Add_Chain():
-    ##Adds Empty to scene
+    # Adds Empty to scene
     bpy.ops.object.add(type='EMPTY',
                        view_align=False,
                        enter_editmode=False,
@@ -41,25 +45,25 @@ def Add_Chain():
                        rotation=(0, 0, 0),
                        )
 
-    ##Changes name of Empty to rot_link adds variable emp
+    # Changes name of Empty to rot_link adds variable emp
     emp = bpy.context.object
     emp.name = "rot_link"
 
-    ##Rotate emp ~ 90 degrees
+    # Rotate emp ~ 90 degrees
     emp.rotation_euler = [1.570796, 0, 0]
 
-    ##Adds Curve Path to scene
+    # Adds Curve Path to scene
     bpy.ops.curve.primitive_nurbs_path_add(view_align=False,
                                            enter_editmode=False,
                                            location=(0, 0, 0),
                                            rotation=(0, 0, 0),
                                            )
 
-    ##Change Curve name to deform adds variable curv
+    # Change Curve name to deform adds variable curv
     curv = bpy.context.object
     curv.name = "deform"
 
-    ##Inserts Torus primitive
+    # Inserts Torus primitive
     bpy.ops.mesh.primitive_torus_add(major_radius=1,
                                      minor_radius=0.25,
                                      major_segments=12,
@@ -68,35 +72,34 @@ def Add_Chain():
                                      abso_minor_rad=0.5,
                                      )
 
-    ##Positions Torus primitive to center of scene
+    # Positions Torus primitive to center of scene
     bpy.context.active_object.location = 0.0, 0.0, 0.0
 
-    ##Reseting Torus rotation in case of 'Align to view' option enabled
+    # Reseting Torus rotation in case of 'Align to view' option enabled
     bpy.context.active_object.rotation_euler = 0.0, 0.0, 0.0
 
-
-    ##Changes Torus name to chain adds variable tor
+    # Changes Torus name to chain adds variable tor
     tor = bpy.context.object
     tor.name = "chain"
 
-    ##Adds Array Modifier to tor
+    # Adds Array Modifier to tor
     bpy.ops.object.modifier_add(type='ARRAY')
 
-    ##Adds subsurf modifier tor
+    # Adds subsurf modifier tor
     bpy.ops.object.modifier_add(type='SUBSURF')
 
-    ##Smooths tor
+    # Smooths tor
     bpy.ops.object.shade_smooth()
 
-    ##Select curv
+    # Select curv
     sce = bpy.context.scene
     sce.objects.active = curv
 
-    ##Toggle into editmode
+    # Toggle into editmode
     bpy.ops.object.editmode_toggle()
 
-    ## TODO, may be better to move objects directly.
-    ##Translate curve object
+    # TODO, may be better to move objects directly.
+    # Translate curve object
     bpy.ops.transform.translate(value=(2, 0, 0),
                                 constraint_axis=(True, False, False),
                                 constraint_orientation='GLOBAL',
@@ -112,35 +115,39 @@ def Add_Chain():
                                 release_confirm=False,
                                 )
 
-    ##Toggle into objectmode
+    # Toggle into objectmode
     bpy.ops.object.editmode_toggle()
 
-    ##Select tor or chain
+    # Select tor or chain
     sce.objects.active = tor
 
-    ##Selects Array Modifier for editing
+    # Selects Array Modifier for editing
     array = tor.modifiers['Array']
 
-    ##Change Array Modifier Parameters
+    # Change Array Modifier Parameters
     array.fit_type = 'FIT_CURVE'
     array.curve = curv
     array.offset_object = emp
     array.use_object_offset = True
     array.relative_offset_displace = 0.549, 0.0, 0.0
 
-    ##Add curve modifier
+    # Add curve modifier
     bpy.ops.object.modifier_add(type='CURVE')
 
-    ##Selects Curve Modifier for editing
+    # Selects Curve Modifier for editing
     cur = tor.modifiers['Curve']
 
-    ##Change Curve Modifier Parameters
+    # Change Curve Modifier Parameters
     cur.object = curv
 
-class AddChain(bpy.types.Operator):
-    """Add a Chain"""
+
+class AddChain(Operator):
     bl_idname = "mesh.primitive_chain_add"
     bl_label = "Add Chain"
+    bl_description = ("Create a Chain segment with helper objects controlling modifiers:\n"
+                      "1) A Curve Modifier Object (deform) for the length and shape,\n"
+                      "Edit the Path to extend Chain Length\n"
+                      "2) An Empty (rot_link) as an Array Offset for rotation")
     bl_options = {'REGISTER', 'UNDO'}
 
     def execute(self, context):
@@ -148,6 +155,7 @@ class AddChain(bpy.types.Operator):
 
         return {'FINISHED'}
 
+
 class add_chain(Panel):
     bl_space_type = 'VIEW_3D'
     bl_region_type = 'TOOLS'
@@ -158,15 +166,18 @@ class add_chain(Panel):
 
     def draw(self, context):
         layout = self.layout
-        layout.operator(AddChain.bl_idname, text="Chain")
+        layout.operator(AddChain.bl_idname, text="Chain", icon="CONSTRAINT")
+
 
 def register():
     bpy.utils.register_module(__name__)
     pass
 
+
 def unregister():
     bpy.utils.unregister_module(__name__)
     pass
 
+
 if __name__ == "__main__":
     register()



More information about the Bf-extensions-cvs mailing list