[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1801] contrib/py/scripts/addons/ gpencil_retopo: made retopo into a package.

Campbell Barton ideasman42 at gmail.com
Sat Apr 9 13:53:10 CEST 2011


Revision: 1801
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1801
Author:   campbellbarton
Date:     2011-04-09 11:53:10 +0000 (Sat, 09 Apr 2011)
Log Message:
-----------
made retopo into a package.

Modified Paths:
--------------
    contrib/py/scripts/addons/gpencil_retopo/retopo.py

Added Paths:
-----------
    contrib/py/scripts/addons/gpencil_retopo/__init__.py

Added: contrib/py/scripts/addons/gpencil_retopo/__init__.py
===================================================================
--- contrib/py/scripts/addons/gpencil_retopo/__init__.py	                        (rev 0)
+++ contrib/py/scripts/addons/gpencil_retopo/__init__.py	2011-04-09 11:53:10 UTC (rev 1801)
@@ -0,0 +1,111 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+
+bl_info = {
+    'name': "Grease Pencil Retopology",
+    'author': "Campbell Barton, Bart Crouch",
+    'version': (1, 0, 0),
+    'blender': (2, 5, 7),
+    'api': 36007,
+    'location': "View3D > Properties > Grease Pencil",
+    'warning': "",
+    'description': "Use Grease Pencil to retopologise a mesh.",
+    'wiki_url': "",
+    'tracker_url': "",
+    'category': 'Mesh'}
+
+
+import bpy
+
+# retopo operator
+class Retopo(bpy.types.Operator):
+    bl_idname = 'mesh.gp_retopo'
+    bl_label = "Retopo"
+    bl_description = "Convert Grease Pencil drawings to a mesh"
+    bl_options = {'REGISTER', 'UNDO'}
+    
+    precision = bpy.props.IntProperty(name="Precision",
+        description="Lower values result in more removed doubles and "\
+            "smoother less precise results",
+        default=15,
+        min=2,
+        soft_max = 100)
+    
+    @classmethod
+    def poll(cls, context):
+        return context.object
+    
+    def execute(self, context):
+        from . import retopo
+        scene, gp = retopo.initialise(context)
+        if not gp:
+            self.report('WARNING', "No grease pencil data found")
+            return {'CANCELLED'}
+
+        obj_new = retopo.calculate(gp, self.precision)
+        
+        bpy.ops.object.select_all(action='DESELECT')
+        scene.objects.active = obj_new
+        obj_new.select = True
+        
+        # nasty, recalc normals
+        bpy.ops.object.mode_set(mode='EDIT', toggle=False)
+        bpy.ops.mesh.normals_make_consistent(inside=False)
+        bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
+        
+        return {'FINISHED'}
+
+
+# draw function for integration in panels
+def panel_func(self, context):
+    self.layout.operator("mesh.gp_retopo")
+
+
+# define classes and panels for registration
+classes = [Retopo]
+panels = [bpy.types.VIEW3D_PT_tools_objectmode,
+    bpy.types.VIEW3D_PT_tools_meshedit,
+    bpy.types.VIEW3D_PT_tools_curveedit,
+    bpy.types.VIEW3D_PT_tools_surfaceedit,
+    bpy.types.VIEW3D_PT_tools_armatureedit,
+    bpy.types.VIEW3D_PT_tools_mballedit,
+    bpy.types.VIEW3D_PT_tools_latticeedit,
+    bpy.types.VIEW3D_PT_tools_posemode]
+
+
+# registering and menu integration
+def register():
+    for c in classes:
+        bpy.utils.register_class(c)
+    for panel in panels:
+        panel.append(panel_func)
+
+
+# unregistering and removing menus
+def unregister():
+    for c in classes:
+        bpy.utils.unregister_class(c)
+    for panel in panels:
+        panel.remove(panel_func)
+
+
+if __name__ == "__main__":
+    register()

Modified: contrib/py/scripts/addons/gpencil_retopo/retopo.py
===================================================================
--- contrib/py/scripts/addons/gpencil_retopo/retopo.py	2011-04-09 08:09:05 UTC (rev 1800)
+++ contrib/py/scripts/addons/gpencil_retopo/retopo.py	2011-04-09 11:53:10 UTC (rev 1801)
@@ -18,37 +18,16 @@
 
 # <pep8 compliant>
 
-
-bl_info = {
-    'name': "Grease Pencil Retopology",
-    'author': "Campbell Barton, Bart Crouch",
-    'version': (1, 0, 0),
-    'blender': (2, 5, 7),
-    'api': 36007,
-    'location': "View3D > Properties > Grease Pencil",
-    'warning': "",
-    'description': "Use Grease Pencil to retopologise a mesh.",
-    'wiki_url': "",
-    'tracker_url': "",
-    'category': 'Mesh'}
-
-
 import bpy
 from math import radians
 from mathutils.geometry import intersect_point_line, intersect_line_line
 
 
 # gather initial data and prepare for retopologising
-def initialise(poll=False):
-    scene = bpy.context.scene
-    obj = bpy.context.object
-    
-    # if we're only polling, we've got enough information
-    if poll and obj:
-        return(True)
-    elif poll:
-        return(False)
-    
+def initialise(context):
+    scene = context.scene
+    obj = context.object
+
     gp = None
     if obj:
         gp = obj.grease_pencil
@@ -57,7 +36,7 @@
     
     if gp:
         bpy.ops.object.mode_set(mode='OBJECT')
-    
+
     return(scene, gp)
 
 
@@ -509,77 +488,3 @@
     scene.objects.link(obj_new)
     
     return obj_new
-
-
-# retopo operator
-class Retopo(bpy.types.Operator):
-    bl_idname = 'mesh.gp_retopo'
-    bl_label = "Retopo"
-    bl_description = "Convert Grease Pencil drawings to a mesh"
-    bl_options = {'REGISTER', 'UNDO'}
-    
-    precision = bpy.props.IntProperty(name="Precision",
-        description="Lower values result in more removed doubles and "\
-            "smoother less precise results",
-        default=15,
-        min=2,
-        soft_max = 100)
-    
-    @classmethod
-    def poll(cls, context):
-        return(initialise(poll=True))
-    
-    def execute(self, context):
-        scene, gp = initialise()
-        if not gp:
-            self.report('WARNING', "No grease pencil data found")
-            return {'CANCELLED'}
-        obj_new = calculate(gp, self.precision)
-        
-        bpy.ops.object.select_all(action='DESELECT')
-        scene.objects.active = obj_new
-        obj_new.select = True
-        
-        # nasty, recalc normals
-        bpy.ops.object.mode_set(mode='EDIT', toggle=False)
-        bpy.ops.mesh.normals_make_consistent(inside=False)
-        bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
-        
-        return {'FINISHED'}
-
-
-# draw function for integration in panels
-def panel_func(self, context):
-    self.layout.operator("mesh.gp_retopo")
-
-
-# define classes and panels for registration
-classes = [Retopo]
-panels = [bpy.types.VIEW3D_PT_tools_objectmode,
-    bpy.types.VIEW3D_PT_tools_meshedit,
-    bpy.types.VIEW3D_PT_tools_curveedit,
-    bpy.types.VIEW3D_PT_tools_surfaceedit,
-    bpy.types.VIEW3D_PT_tools_armatureedit,
-    bpy.types.VIEW3D_PT_tools_mballedit,
-    bpy.types.VIEW3D_PT_tools_latticeedit,
-    bpy.types.VIEW3D_PT_tools_posemode]
-
-
-# registering and menu integration
-def register():
-    for c in classes:
-        bpy.utils.register_class(c)
-    for panel in panels:
-        panel.append(panel_func)
-
-
-# unregistering and removing menus
-def unregister():
-    for c in classes:
-        bpy.utils.unregister_class(c)
-    for panel in panels:
-        panel.remove(panel_func)
-
-
-if __name__ == "__main__":
-    register()



More information about the Bf-extensions-cvs mailing list