[Bf-extensions-cvs] [9178b6b] master: curve extra objects: clean up imports, add surface objects

meta-androcto noreply at git.blender.org
Fri Aug 5 10:38:59 CEST 2016


Commit: 9178b6b22389333d19c12bd4d8b253fa9e3aa661
Author: meta-androcto
Date:   Fri Aug 5 18:38:21 2016 +1000
Branches: master
https://developer.blender.org/rBA9178b6b22389333d19c12bd4d8b253fa9e3aa661

curve extra objects: clean up imports, add surface objects

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

M	add_curve_extra_objects/__init__.py
M	add_curve_extra_objects/add_curve_aceous_galore.py
M	add_curve_extra_objects/add_curve_spirals.py
M	add_curve_extra_objects/add_curve_torus_knots.py
A	add_curve_extra_objects/add_surface_plane_cone.py

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

diff --git a/add_curve_extra_objects/__init__.py b/add_curve_extra_objects/__init__.py
index 945a8ac..ec45c1c 100644
--- a/add_curve_extra_objects/__init__.py
+++ b/add_curve_extra_objects/__init__.py
@@ -28,22 +28,26 @@ bl_info = {
     "warning": "",
     "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
                 "Scripts/Curve/Curve_Objects",
-    "category": "Add Curve"}
+    "category": "Add Curve"
+    }
 
 if "bpy" in locals():
-    import imp
-    imp.reload(add_curve_aceous_galore)
-    imp.reload(add_curve_spirals)
-    imp.reload(add_curve_torus_knots)
+    import importlib
+    importlib.reload(add_curve_aceous_galore)
+    importlib.reload(add_curve_spirals)
+    importlib.reload(add_curve_torus_knots)
+    importlib.reload(add_surface_plane_cone)
 
 else:
     from . import add_curve_aceous_galore
     from . import add_curve_spirals
     from . import add_curve_torus_knots
+    from . import add_surface_plane_cone
 
 import bpy
+from bpy.types import Menu
 
-class INFO_MT_curve_extras_add(bpy.types.Menu):
+class INFO_MT_curve_extras_add(Menu):
     # Define the "Extras" menu
     bl_idname = "curve_extra_objects_add"
     bl_label = "Extra Objects"
@@ -57,8 +61,10 @@ class INFO_MT_curve_extras_add(bpy.types.Menu):
             text="Spirals")
         layout.operator("curve.torus_knot_plus",
             text="Torus Knot Plus")
-# Define "Extras" menu
+
+# Define "Extras" menus
 def menu_func(self, context):
+    self.layout.separator()
     self.layout.operator("mesh.curveaceous_galore",
             text="Curve Profiles")
     self.layout.operator("curve.torus_knot_plus",
@@ -66,17 +72,30 @@ def menu_func(self, context):
     self.layout.operator("curve.spirals",
             text="Spirals")
 
+def menu_surface(self, context):
+    layout = self.layout
+    self.layout.separator()
+    self.layout.operator("object.add_surface_wedge", text="Wedge", icon="MOD_CURVE")
+    self.layout.operator("object.add_surface_cone", text="Cone", icon="MOD_CURVE")
+    self.layout.operator("object.add_surface_star", text="Star", icon="MOD_CURVE")
+    self.layout.operator("object.add_surface_plane", text="Plane", icon="MOD_CURVE")
+    self.layout.operator("curve.smooth_x_times", text="Special Smooth", icon="MOD_CURVE")
+
 def register():
     bpy.utils.register_module(__name__)
 
     # Add "Extras" menu to the "Add Curve" menu
     bpy.types.INFO_MT_curve_add.append(menu_func)
+    # Add "Extras" menu to the "Add Surface" menu
+    bpy.types.INFO_MT_surface_add.append(menu_surface)
 
 def unregister():
     bpy.utils.unregister_module(__name__)
 
     # Remove "Extras" menu from the "Add Curve" menu.
     bpy.types.INFO_MT_curve_add.remove(menu_func)
+    # Remove "Extras" menu from the "Add Surface" menu.
+    bpy.types.INFO_MT_surface_add.remove(menu_surface)
 
 if __name__ == "__main__":
     register()
diff --git a/add_curve_extra_objects/add_curve_aceous_galore.py b/add_curve_extra_objects/add_curve_aceous_galore.py
index 13fda4b..41bf458 100644
--- a/add_curve_extra_objects/add_curve_aceous_galore.py
+++ b/add_curve_extra_objects/add_curve_aceous_galore.py
@@ -44,8 +44,13 @@ from mathutils import (
         Matrix,
         Vector,
         )
-from math import sin, cos, pi
+from math import (
+        sin,
+        cos,
+        pi
+        )
 import mathutils.noise as Noise
+from bpy.types import Operator
 ###------------------------------------------------------------
 #### Some functions to use with others:
 ###------------------------------------------------------------
@@ -767,7 +772,7 @@ def main(context, self, align_matrix):
 
     return
 
-class Curveaceous_galore(bpy.types.Operator):
+class Curveaceous_galore(Operator):
     """Add many types of curves"""
     bl_idname = "mesh.curveaceous_galore"
     bl_label = "Curve Profiles"
diff --git a/add_curve_extra_objects/add_curve_spirals.py b/add_curve_extra_objects/add_curve_spirals.py
index a07ef41..29a8687 100644
--- a/add_curve_extra_objects/add_curve_spirals.py
+++ b/add_curve_extra_objects/add_curve_spirals.py
@@ -19,18 +19,25 @@ from bpy.props import (
         FloatProperty,
         IntProperty,
         )
-from math import sin, cos, pi, exp
+from math import (
+        sin,
+        cos, 
+        pi, 
+        exp
+        )
 from bpy_extras.object_utils import AddObjectHelper, object_data_add
+from bpy.types import Operator
 
 #make normal spiral
 #-----------------------------------------------------------------------------
-def make_spiral(props, context):                  #archemedian and logarithmic can be plottet in zylindrical coordinates
-    #if props.spiral_type != 1 and props.spiral_type != 2:
-    #    return None
+def make_spiral(props, context):
+#archemedian and logarithmic can be plottet in zylindrical coordinates
+#if props.spiral_type != 1 and props.spiral_type != 2:
+#    return None
 
-    #INPUT: turns->degree->max_phi, steps, direction
-    #Initialise Polar Coordinate Enviroment
-    #-------------------------------
+#INPUT: turns->degree->max_phi, steps, direction
+#Initialise Polar Coordinate Enviroment
+#-------------------------------
     props.degree = 360*props.turns                #If you want to make the slider for degree
     steps = props.steps * props.turns             #props.steps[per turn] -> steps[for the whole spiral]
     props.z_scale = props.dif_z * props.turns
@@ -47,25 +54,26 @@ def make_spiral(props, context):                  #archemedian and logarithmic c
     
     cur_phi = 0
     cur_z   = 0
-    #-------------------------------
+#-------------------------------
 
-    #Archemedean: dif_radius, radius
+#Archemedean: dif_radius, radius
     cur_rad = props.radius
-    step_rad = props.dif_radius/(steps * 360/props.degree)        #radius increase per angle for archemedean spiral| (steps * 360/props.degree)...Steps needed for 360 deg
-    #Logarithmic: radius, B_force, ang_div, dif_z
+    step_rad = props.dif_radius/(steps * 360/props.degree)   
+#radius increase per angle for archemedean spiral| (steps * 360/props.degree)...Steps needed for 360 deg
+#Logarithmic: radius, B_force, ang_div, dif_z
     
-    #print("max_phi:",max_phi,"step_phi:",step_phi,"step_rad:",step_rad,"step_z:",step_z)
+#print("max_phi:",max_phi,"step_phi:",step_phi,"step_rad:",step_rad,"step_z:",step_z)
     while abs(cur_phi) <= abs(max_phi):
         cur_phi += step_phi
         cur_z   += step_z
         
-        #-------------------------------
+#-------------------------------
         if props.spiral_type == 1:
             cur_rad += step_rad
         if props.spiral_type == 2:
-            #r = a*e^{|theta| * b}
+#r = a*e^{|theta| * b}
             cur_rad = props.radius * pow(props.B_force, abs(cur_phi)) 
-        #-------------------------------
+#-------------------------------
     
         px = cur_rad * cos(cur_phi)
         py = cur_rad * sin(cur_phi)
@@ -92,13 +100,13 @@ def make_spiral_spheric(props, context):
     verts = []
     verts.extend([0,0,-props.radius,1])           #First vertex at south pole
 
-    #cur_rad = props.radius = CONST
+#cur_rad = props.radius = CONST
 
     cur_phi = 0
     cur_theta = -pi/2                             #Beginning at south pole
 
     while abs(cur_phi) <= abs(max_phi):
-        #Coordinate Transformation sphere->rect
+#Coordinate Transformation sphere->rect
         px = props.radius * cos(cur_theta) * cos(cur_phi)
         py = props.radius * cos(cur_theta) * sin(cur_phi)
         pz = props.radius * sin(cur_theta)
@@ -113,7 +121,7 @@ def make_spiral_spheric(props, context):
 #-----------------------------------------------------------------------------
 
 def make_spiral_torus(props, context):
-    #INPUT: turns, steps, inner_radius, curves_number, mul_height, dif_inner_radius, cycles
+#INPUT: turns, steps, inner_radius, curves_number, mul_height, dif_inner_radius, cycles
     max_phi  = 2*pi*props.turns * props.cycles    #max angle in radian
     step_phi = 2*pi/props.steps                   #Step of angle in radians between two vertices
     if props.spiral_direction == 1:               #flip direction
@@ -134,7 +142,7 @@ def make_spiral_torus(props, context):
     n_cycle = 0
     
     while abs(cur_phi) <= abs(max_phi):
-        #Torus Coordinates -> Rect
+#Torus Coordinates -> Rect
         px = ( cur_rad + cur_inner_rad * cos(cur_phi) ) * cos(props.curves_number * cur_theta)
         py = ( cur_rad + cur_inner_rad * cos(cur_phi) ) * sin(props.curves_number * cur_theta)
         pz = cur_inner_rad * sin(cur_phi) + cur_z
@@ -172,14 +180,16 @@ def draw_curve(props, context):
     elif props.curve_type == 1:
         spline = curve_data.splines.new(type='NURBS')
     
-    spline.points.add( len(verts)*0.25-1 )                          #Add only one quarter of points as elements in verts, because verts looks like: "x,y,z,?,x,y,z,?,x,..."
+    spline.points.add( len(verts)*0.25-1 )
+#Add only one quarter of points as elements in verts, because verts looks like: "x,y,z,?,x,y,z,?,x,..."
     spline.points.foreach_set('co', verts)
     new_obj = object_data_add(context, curve_data)
 
-class spirals(bpy.types.Operator):
+class spirals(Operator):
     bl_idname = "curve.spirals"
     bl_label = "Spirals"
-    bl_options = {'REGISTER','UNDO', 'PRESET'}            #UNDO needed for operator redo and therefore also to let the addobjecthelp appear!!!
+    bl_options = {'REGISTER','UNDO', 'PRESET'}            
+#UNDO needed for operator redo and therefore also to let the addobjecthelp appear!!!
     bl_description = "adds different types of spirals"
 
     spiral_type = IntProperty(default=1, min=1, max=4, description="1:archemedian, 2:logarithmic, 3:spheric, 4:torus")
@@ -191,12 +201,14 @@ class spirals(bpy.types.Operator):
 
     
     radius = FloatProperty(default=1.00, min=0.00, max=100.00, description="radius for first turn")
-    dif_z = FloatProperty(default=0, min=-10.00, max=100.00, description="increase in z axis per turn")            #needed for 1 and 2 spiral_type
-    #ARCHMEDEAN variables
-    dif_radius = FloatProperty(default=0.00, min=-50.00, max=50.00, description="radius increment in each turn")        #step between turns(one turn equals 360 deg)
-    #LO

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list