[Bf-extensions-cvs] [b7b4e2f] master: Bsurfaces: Update panel Rename, Cleanup
lijenstina
noreply at git.blender.org
Fri Apr 14 05:02:12 CEST 2017
Commit: b7b4e2fbe72a69a7f24b1d7dcb4baf0975606f8a
Author: lijenstina
Date: Fri Apr 14 05:01:08 2017 +0200
Branches: master
https://developer.blender.org/rBAb7b4e2fbe72a69a7f24b1d7dcb4baf0975606f8a
Bsurfaces: Update panel Rename, Cleanup
Bumped version to 1.5.1
As a part of the task T50726:
Update the Panel rename code to more generic one
PEP8 cleanup:
Tuple imports and use them for class types
Consistent Scene props definitions
Update url link
Note:
Moved the Scene Properties into a PropertyGroup
Access them with bpy.context.scene.bsurfaces
There are still some possibly unused variables
In the future, during a refactor that could
be adressed (as they are not all function calls)
Fixed some crashes that i got during testing:
line 1402:
The Remove Doubles treshold calc in one case
caused divide by zero - fallback to 0.0001
line 458:
Index out of range error
line 2955:
zero Vector angles
If there are some better solutions, these are the
places to look
===================================================================
M mesh_bsurfaces.py
===================================================================
diff --git a/mesh_bsurfaces.py b/mesh_bsurfaces.py
index 21c6e50..8094385 100644
--- a/mesh_bsurfaces.py
+++ b/mesh_bsurfaces.py
@@ -20,27 +20,45 @@
bl_info = {
"name": "Bsurfaces GPL Edition",
"author": "Eclectiel",
- "version": (1, 5),
+ "version": (1, 5, 1),
"blender": (2, 76, 0),
"location": "View3D > EditMode > ToolShelf",
- "description": "Modeling and retopology tool.",
- "wiki_url": "http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Bsurfaces_1.5",
+ "description": "Modeling and retopology tool",
+ "wiki_url": "https://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Bsurfaces_1.5",
"category": "Mesh",
}
import bpy
import bmesh
-import math
-import mathutils
-import operator
-
-from math import *
-
-
-
-class VIEW3D_PT_tools_SURFSK_mesh(bpy.types.Panel):
+import operator
+from mathutils import Vector
+from mathutils.geometry import (
+ intersect_line_line,
+ intersect_point_line,
+ )
+from math import (
+ degrees,
+ pi,
+ sqrt,
+ )
+from bpy.props import (
+ BoolProperty,
+ FloatProperty,
+ IntProperty,
+ StringProperty,
+ PointerProperty,
+ )
+from bpy.types import (
+ Operator,
+ Panel,
+ PropertyGroup,
+ AddonPreferences,
+ )
+
+
+class VIEW3D_PT_tools_SURFSK_mesh(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_category = 'Tools'
@@ -51,12 +69,9 @@ class VIEW3D_PT_tools_SURFSK_mesh(bpy.types.Panel):
def poll(cls, context):
return context.active_object
-
def draw(self, context):
layout = self.layout
-
- scn = context.scene
- ob = context.object
+ scn = context.scene.bsurfaces
col = layout.column(align=True)
row = layout.row()
@@ -70,8 +85,7 @@ class VIEW3D_PT_tools_SURFSK_mesh(bpy.types.Panel):
col.prop(scn, "SURFSK_keep_strokes")
-
-class VIEW3D_PT_tools_SURFSK_curve(bpy.types.Panel):
+class VIEW3D_PT_tools_SURFSK_curve(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_context = "curve_edit"
@@ -82,13 +96,9 @@ class VIEW3D_PT_tools_SURFSK_curve(bpy.types.Panel):
def poll(cls, context):
return context.active_object
-
def draw(self, context):
layout = self.layout
- scn = context.scene
- ob = context.object
-
col = layout.column(align=True)
row = layout.row()
row.separator()
@@ -97,16 +107,14 @@ class VIEW3D_PT_tools_SURFSK_curve(bpy.types.Panel):
col.operator("curve.surfsk_reorder_splines", text="Reorder Splines")
-
-
-#### Returns the type of strokes used.
+# Returns the type of strokes used
def get_strokes_type(main_object):
strokes_type = ""
strokes_num = 0
# Check if they are grease pencil
try:
- #### Get the active grease pencil layer.
+ # Get the active grease pencil layer
strokes_num = len(main_object.grease_pencil.layers.active.active_frame.strokes)
if strokes_num > 0:
@@ -114,8 +122,7 @@ def get_strokes_type(main_object):
except:
pass
-
- # Check if they are curves, if there aren't grease pencil strokes.
+ # Check if they are curves, if there aren't grease pencil strokes
if strokes_type == "":
if len(bpy.context.selected_objects) == 2:
for ob in bpy.context.selected_objects:
@@ -123,7 +130,7 @@ def get_strokes_type(main_object):
strokes_type = "EXTERNAL_CURVE"
strokes_num = len(ob.data.splines)
- # Check if there is any non-bezier spline.
+ # Check if there is any non-bezier spline
for i in range(len(ob.data.splines)):
if ob.data.splines[i].type != "BEZIER":
strokes_type = "CURVE_WITH_NON_BEZIER_SPLINES"
@@ -134,8 +141,7 @@ def get_strokes_type(main_object):
elif len(bpy.context.selected_objects) > 2:
strokes_type = "MORE_THAN_ONE_EXTERNAL"
-
- # Check if there is a single stroke without any selection in the object.
+ # Check if there is a single stroke without any selection in the object
if strokes_num == 1 and main_object.data.total_vert_sel == 0:
if strokes_type == "EXTERNAL_CURVE":
strokes_type = "SINGLE_CURVE_STROKE_NO_SELECTION"
@@ -145,69 +151,66 @@ def get_strokes_type(main_object):
if strokes_num == 0 and main_object.data.total_vert_sel > 0:
strokes_type = "SELECTION_ALONE"
-
if strokes_type == "":
strokes_type = "NO_STROKES"
-
-
return strokes_type
-
-
-# Surface generator operator.
-class GPENCIL_OT_SURFSK_add_surface(bpy.types.Operator):
+# Surface generator operator
+class GPENCIL_OT_SURFSK_add_surface(Operator):
bl_idname = "gpencil.surfsk_add_surface"
bl_label = "Bsurfaces add surface"
bl_description = "Generates surfaces from grease pencil strokes, bezier curves or loose edges"
bl_options = {'REGISTER', 'UNDO'}
-
- edges_U = bpy.props.IntProperty(name = "Cross",
- description = "Number of face-loops crossing the strokes",
- default = 1,
- min = 1,
- max = 200)
-
- edges_V = bpy.props.IntProperty(name = "Follow",
- description = "Number of face-loops following the strokes",
- default = 1,
- min = 1,
- max = 200)
-
- cyclic_cross = bpy.props.BoolProperty(name = "Cyclic Cross",
- description = "Make cyclic the face-loops crossing the strokes",
- default = False)
-
- cyclic_follow = bpy.props.BoolProperty(name = "Cyclic Follow",
- description = "Make cyclic the face-loops following the strokes",
- default = False)
-
- loops_on_strokes = bpy.props.BoolProperty(name = "Loops on strokes",
- description = "Make the loops match the paths of the strokes",
- default = False)
-
- automatic_join = bpy.props.BoolProperty(name = "Automatic join",
- description = "Join automatically vertices of either surfaces generated by crosshatching, or from the borders of closed shapes",
- default = False)
-
- join_stretch_factor = bpy.props.FloatProperty(name = "Stretch",
- description = "Amount of stretching or shrinking allowed for edges when joining vertices automatically",
- default = 1,
- min = 0,
- max = 3,
- subtype = 'FACTOR')
-
-
-
+ edges_U = IntProperty(
+ name="Cross",
+ description="Number of face-loops crossing the strokes",
+ default=1,
+ min=1,
+ max=200
+ )
+ edges_V = IntProperty(
+ name="Follow",
+ description="Number of face-loops following the strokes",
+ default=1,
+ min=1,
+ max=200
+ )
+ cyclic_cross = BoolProperty(
+ name="Cyclic Cross",
+ description="Make cyclic the face-loops crossing the strokes",
+ default=False
+ )
+ cyclic_follow = BoolProperty(
+ name="Cyclic Follow",
+ description="Make cyclic the face-loops following the strokes",
+ default=False
+ )
+ loops_on_strokes = BoolProperty(
+ name="Loops on strokes",
+ description="Make the loops match the paths of the strokes",
+ default=False
+ )
+ automatic_join = BoolProperty(
+ name="Automatic join",
+ description="Join automatically vertices of either surfaces generated "
+ "by crosshatching, or from the borders of closed shapes",
+ default=False
+ )
+ join_stretch_factor = FloatProperty(
+ name="Stretch",
+ description="Amount of stretching or shrinking allowed for "
+ "edges when joining vertices automatically",
+ default=1,
+ min=0,
+ max=3,
+ subtype='FACTOR'
+ )
def draw(self, context):
layout = self.layout
-
- scn = context.scene
- ob = context.object
-
col = layout.column(align=True)
row = layout.row()
@@ -225,14 +228,19 @@ class GPENCIL_OT_SURFSK_add_surface(bpy.types.Operator):
row.separator()
if not self.selection_U_exists:
- if not ((self.selection_V_exists and not self.selection_V_is_closed) or (self.selection_V2_exists and not self.selection_V2_is_closed)):
+ if not (
+ (self.selection_V_exists and not self.selection_V_is_closed) or
+ (self.selection_V2_exists and not self.selection_V2_is_closed)
+ ):
col.prop(self, "cyclic_cross")
if not self.selection_V_exists:
- if not ((self.selection_U_exists and not self.selection_U_is_closed) or (self.selection_U2_exists and not self.selection_U2_is_closed)):
+ if not (
+ (self.selection_U_exists and not self.selection_U_is_closed) or
+ (self.selection_U2_exists and not self.selection_U2_is_closed)
+ ):
col.prop(self, "cyclic_follow")
-
col.prop(self, "loops_on_strokes")
col.prop(self, "automatic_join")
@@ -243,10 +251,9 @@ class GPENCIL_OT_SURFSK_add_surface(bpy.types.Operator
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list