[Bf-extensions-cvs] [27a32b3] master: Don't access bpy.context when context is passed
Campbell Barton
noreply at git.blender.org
Tue Dec 8 02:52:01 CET 2015
Commit: 27a32b3ed5f8ae2ae332ff403d2fb68d876840fe
Author: Campbell Barton
Date: Tue Dec 8 12:33:52 2015 +1100
Branches: master
https://developer.blender.org/rBA27a32b3ed5f8ae2ae332ff403d2fb68d876840fe
Don't access bpy.context when context is passed
also quiet 'description' warnings.
===================================================================
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
===================================================================
diff --git a/add_curve_extra_objects/add_curve_aceous_galore.py b/add_curve_extra_objects/add_curve_aceous_galore.py
index dbe45bb..fc6ff05 100644
--- a/add_curve_extra_objects/add_curve_aceous_galore.py
+++ b/add_curve_extra_objects/add_curve_aceous_galore.py
@@ -34,9 +34,17 @@ bl_info = {
##------------------------------------------------------------
#### import modules
import bpy
-from bpy.props import *
-from mathutils import *
-from math import *
+from bpy.props import (
+ BoolProperty,
+ EnumProperty,
+ FloatProperty,
+ IntProperty,
+ )
+from mathutils import (
+ Matrix,
+ Vector,
+ )
+from math import sin, cos, pi
import mathutils.noise as Noise
###------------------------------------------------------------
#### Some functions to use with others:
@@ -641,13 +649,13 @@ def vertsToPoints(Verts, splineType):
return vertArray
# create new CurveObject from vertarray and splineType
-def createCurve(vertArray, self, align_matrix):
+def createCurve(context, vertArray, self, align_matrix):
# options to vars
splineType = self.outputType # output splineType 'POLY' 'NURBS' 'BEZIER'
name = self.GalloreType # GalloreType as name
# create curve
- scene = bpy.context.scene
+ scene = context.scene
newCurve = bpy.data.curves.new(name, type = 'CURVE') # curvedatablock
newSpline = newCurve.splines.new(type = splineType) # spline
@@ -757,7 +765,7 @@ def main(context, self, align_matrix):
vertArray = vertsToPoints(verts, splineType)
# create object
- createCurve(vertArray, self, align_matrix)
+ createCurve(context, vertArray, self, align_matrix)
return
@@ -1090,8 +1098,8 @@ class Curveaceous_galore(bpy.types.Operator):
##### EXECUTE #####
def execute(self, context):
# turn off undo
- undo = bpy.context.user_preferences.edit.use_global_undo
- bpy.context.user_preferences.edit.use_global_undo = False
+ undo = context.user_preferences.edit.use_global_undo
+ context.user_preferences.edit.use_global_undo = False
# deal with 2D - 3D curve differences
if self.GalloreType in ['Helix', 'Cycloid']:
@@ -1109,7 +1117,7 @@ class Curveaceous_galore(bpy.types.Operator):
main(context, self, self.align_matrix or Matrix())
# restore pre operator undo state
- bpy.context.user_preferences.edit.use_global_undo = undo
+ context.user_preferences.edit.use_global_undo = undo
return {'FINISHED'}
diff --git a/add_curve_extra_objects/add_curve_spirals.py b/add_curve_extra_objects/add_curve_spirals.py
index 11d86eb..a07ef41 100644
--- a/add_curve_extra_objects/add_curve_spirals.py
+++ b/add_curve_extra_objects/add_curve_spirals.py
@@ -14,7 +14,11 @@
}
'''
import bpy, time
-from bpy.props import *
+from bpy.props import (
+ BoolProperty,
+ FloatProperty,
+ IntProperty,
+ )
from math import sin, cos, pi, exp
from bpy_extras.object_utils import AddObjectHelper, object_data_add
@@ -170,8 +174,7 @@ def draw_curve(props, context):
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(bpy.context, curve_data)
- new_obj = object_data_add(context, curve_data)
+ new_obj = object_data_add(context, curve_data)
class spirals(bpy.types.Operator):
bl_idname = "curve.spirals"
diff --git a/add_curve_extra_objects/add_curve_torus_knots.py b/add_curve_extra_objects/add_curve_torus_knots.py
index 47524c0..7423be0 100644
--- a/add_curve_extra_objects/add_curve_torus_knots.py
+++ b/add_curve_extra_objects/add_curve_torus_knots.py
@@ -331,211 +331,216 @@ class torus_knot_plus(bpy.types.Operator, AddObjectHelper):
#### GENERAL options
options_plus = BoolProperty(
- name="Extra Options",
- default=False,
- description="Show more options (the plus part).")
-
+ name="Extra Options",
+ default=False,
+ description="Show more options (the plus part)",
+ )
absolute_location = BoolProperty(
- name= "Absolute Location",
- default=False,
- description="Set absolute location instead of relative to 3D cursor.")
+ name= "Absolute Location",
+ default=False,
+ description="Set absolute location instead of relative to 3D cursor",
+ )
#### COLOR options
use_colors = BoolProperty(
- name="Use Colors",
- default=False,
- description="Show torus links in colors.")
-
+ name="Use Colors",
+ default=False,
+ description="Show torus links in colors",
+ )
colorSet = EnumProperty(
- name="Color Set",
- items= (('1', 'RGBish', 'RGBsish ordered colors'),
- ('2', 'Rainbow', 'Rainbow ordered colors')))
-
+ name="Color Set",
+ items= (('1', 'RGBish', 'RGBsish ordered colors'),
+ ('2', 'Rainbow', 'Rainbow ordered colors')),
+ )
random_colors = BoolProperty(
- name="Randomize Colors",
- default=False,
- description="Randomize link colors.")
-
+ name="Randomize Colors",
+ default=False,
+ description="Randomize link colors",
+ )
saturation = FloatProperty(
- name="Saturation",
- default=0.75,
- min=0.0, max=1.0,
- description="Color saturation.")
+ name="Saturation",
+ default=0.75,
+ min=0.0, max=1.0,
+ description="Color saturation",
+ )
#### SURFACE Options
geo_surface = BoolProperty(
- name="Surface",
- default=True,
- description="Create surface.")
-
+ name="Surface",
+ default=True,
+ description="Create surface",
+ )
geo_bDepth = FloatProperty(
- name="Bevel Depth",
- default=0.04,
- min=0, soft_min=0,
- description="Bevel Depth.")
-
+ name="Bevel Depth",
+ default=0.04,
+ min=0, soft_min=0,
+ description="Bevel Depth",
+ )
geo_bRes = IntProperty(
- name="Bevel Resolution",
- default=2,
- min=0, soft_min=0,
- max=5, soft_max=5,
- description="Bevel Resolution.")
-
+ name="Bevel Resolution",
+ default=2,
+ min=0, soft_min=0,
+ max=5, soft_max=5,
+ description="Bevel Resolution"
+ )
geo_extrude = FloatProperty(
- name="Extrude",
- default=0.0,
- min=0, soft_min=0,
- description="Amount of curve extrusion.")
-
+ name="Extrude",
+ default=0.0,
+ min=0, soft_min=0,
+ description="Amount of curve extrusion"
+ )
geo_offset = FloatProperty(
- name="Offset",
- default=0.0,
- min=0, soft_min=0,
- description="Offset the surface relative to the curve.")
+ name="Offset",
+ default=0.0,
+ min=0, soft_min=0,
+ description="Offset the surface relative to the curve"
+ )
#### TORUS KNOT Options
torus_p = IntProperty(
- name="p",
- default=2,
- min=1, soft_min=1,
- description="Number of REVOLUTIONs around the torus hole before closing the knot.")
-
+ name="p",
+ default=2,
+ min=1, soft_min=1,
+ description="Number of REVOLUTIONs around the torus hole before closing the knot"
+ )
torus_q = IntProperty(
- name="q",
- default=3,
- min=1, soft_min=1,
- description="Number of SPINs through the torus hole before closing the knot.")
-
+ name="q",
+ default=3,
+ min=1, soft_min=1,
+ description="Number of SPINs through the torus hole before closing the knot"
+ )
flip_p = BoolProperty(
- name="Flip p",
- default=False,
- description="Flip REVOLUTION direction.")
-
+ name="Flip p",
+ default=False,
+ description="Flip REVOLUTION direction"
+ )
flip_q = BoolProperty(
- name="Flip q",
- default=False,
- description="Flip SPIN direction.")
-
+ name="Flip q",
+ default=False,
+ description="Flip SPIN direction"
+ )
multiple_links = BoolProperty(
- name="Multiple Links",
- default=True,
- description="Generate ALL links or just ONE link when q and q are not co-primes.")
-
+ name="Multiple Links",
+ default=True,
+ description="Generate ALL links or just ONE link when q and q are not co-primes"
+ )
torus_u = IntProperty(
- name="p multiplier",
- default=1,
- min=1, soft_min=1,
- description="p multiplier.")
-
+ name="p multiplier",
+ default=1,
+ min=1, soft_min=1,
+ description="p multiplier"
+ )
torus_v = IntProperty(
- name="q multiplier",
- default=1,
- min=1, soft_min=1,
- description="q multiplier.")
-
+ name="q multiplier",
+ default=1,
+ min=1, soft_min=1,
+ description="q multiplier"
+ )
torus_rP = FloatProperty(
- name="Revolution Phase",
- default=0.0,
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list