[Bf-extensions-cvs] [a8b7976] master: Cleanup: reference context directly
Campbell Barton
noreply at git.blender.org
Wed Jul 27 10:13:19 CEST 2016
Commit: a8b7976076744aa64244cfcd167178b2d849636f
Author: Campbell Barton
Date: Wed Jul 27 18:14:16 2016 +1000
Branches: master
https://developer.blender.org/rBACa8b7976076744aa64244cfcd167178b2d849636f
Cleanup: reference context directly
===================================================================
M mesh_carver.py
===================================================================
diff --git a/mesh_carver.py b/mesh_carver.py
index 619a774..6c7cd09 100644
--- a/mesh_carver.py
+++ b/mesh_carver.py
@@ -674,10 +674,10 @@ def draw_callback_px(self, context):
region = context.region
# Width screen
- overlap = bpy.context.user_preferences.system.use_region_overlap
+ overlap = context.user_preferences.system.use_region_overlap
t_panel_width = 0
if overlap:
- for region in bpy.context.area.regions:
+ for region in context.area.regions:
if region.type == 'TOOLS':
t_panel_width = region.width
@@ -999,7 +999,7 @@ def draw_callback_px(self, context):
bgl.glColor4f(0.512, 0.919, 0.04, 1.0)
bgl.glLineWidth(2)
-# if bpy.context.space_data.region_3d.is_perspective == False:
+# if context.space_data.region_3d.is_perspective == False:
if 1:
bgl.glEnable(bgl.GL_POINT_SMOOTH)
@@ -1140,8 +1140,8 @@ def draw_callback_px(self, context):
if self.ObjectMode or self.ProfileMode:
if self.ShowCursor:
- region = bpy.context.region
- rv3d = bpy.context.space_data.region_3d
+ region = context.region
+ rv3d = context.space_data.region_3d
view_width = context.region.width
if self.ObjectMode:
@@ -1296,7 +1296,7 @@ def CreateCutSquare(self, context):
depthLocation = region_2d_to_vector_3d(region, rv3d, coord)
self.ViewVector = depthLocation
if self.snapCursor:
- PlanePoint = bpy.context.scene.cursor_location
+ PlanePoint = context.scene.cursor_location
else:
if self.OpsObj is not None:
PlanePoint = self.OpsObj.location
@@ -1308,7 +1308,7 @@ def CreateCutSquare(self, context):
d = -PlanePoint.x * PlaneNormalised.x - PlanePoint.y * PlaneNormalised.y - PlanePoint.z * PlaneNormalised.z
# Link object to scene
- bpy.context.scene.objects.link(ob)
+ context.scene.objects.link(ob)
# New bmesh
t_bm = bmesh.new()
@@ -1371,7 +1371,7 @@ def CreateCutLine(self, context):
depthLocation = region_2d_to_vector_3d(region, rv3d, coord)
self.ViewVector = depthLocation
if self.snapCursor:
- PlanePoint = bpy.context.scene.cursor_location
+ PlanePoint = context.scene.cursor_location
else:
PlanePoint = mathutils.Vector((0.0, 0.0, 0.0))
@@ -1379,7 +1379,7 @@ def CreateCutLine(self, context):
PlaneNormalised = PlaneNormal.normalized()
d = -PlanePoint.x * PlaneNormalised.x - PlanePoint.y * PlaneNormalised.y - PlanePoint.z * PlaneNormalised.z
- bpy.context.scene.objects.link(ob)
+ context.scene.objects.link(ob)
t_bm = bmesh.new()
t_bm.from_mesh(me)
@@ -1477,7 +1477,7 @@ def CreateCutCircle(self, context):
depthLocation = region_2d_to_vector_3d(region, rv3d, coord)
self.ViewVector = depthLocation
if self.snapCursor:
- PlanePoint = bpy.context.scene.cursor_location
+ PlanePoint = context.scene.cursor_location
else:
PlanePoint = mathutils.Vector((0.0, 0.0, 0.0))
@@ -1485,7 +1485,7 @@ def CreateCutCircle(self, context):
PlaneNormalised = PlaneNormal.normalized()
d = -PlanePoint.x * PlaneNormalised.x - PlanePoint.y * PlaneNormalised.y - PlanePoint.z * PlaneNormalised.z
- bpy.context.scene.objects.link(ob)
+ context.scene.objects.link(ob)
t_bm = bmesh.new()
t_bm.from_mesh(me)
@@ -1535,16 +1535,15 @@ def objDiagonal(obj):
# Bevel Update
-def update_bevel():
- selection = bpy.context.selected_objects.copy()
- active = bpy.context.active_object
+def update_bevel(context):
+ selection = context.selected_objects.copy()
+ active = context.active_object
- C = bpy.context
if len(selection) > 0:
for obj in selection:
bpy.ops.object.select_all(action='DESELECT')
obj.select = True
- bpy.context.scene.objects.active = obj
+ context.scene.objects.active = obj
# Test object name
if obj.data.name.startswith("S_") or obj.data.name.startswith("S "):
@@ -1558,7 +1557,7 @@ def update_bevel():
if mod.type == 'BEVEL':
act_bevel = True
if act_bevel:
- bpy.context.scene.objects.active = bpy.data.objects[obj.name]
+ context.scene.objects.active = bpy.data.objects[obj.name]
active = obj
bpy.ops.object.mode_set(mode='EDIT')
@@ -1597,32 +1596,33 @@ def update_bevel():
if Already == False:
bpy.ops.object.modifier_add(type='BEVEL')
- bpy.context.object.modifiers["Bevel"].limit_method = 'WEIGHT'
- bpy.context.object.modifiers["Bevel"].width = 0.01
- bpy.context.object.modifiers["Bevel"].profile = 0.699099
- bpy.context.object.modifiers["Bevel"].use_clamp_overlap = False
- bpy.context.object.modifiers["Bevel"].segments = 3
- bpy.context.object.modifiers["Bevel"].loop_slide = False
+ mod = context.object.modifiers[-1]
+ mod.limit_method = 'WEIGHT'
+ mod.width = 0.01
+ mod.profile = 0.699099
+ mod.use_clamp_overlap = False
+ mod.segments = 3
+ mod.loop_slide = False
bpy.ops.object.shade_smooth()
- bpy.context.object.data.use_auto_smooth = True
- bpy.context.object.data.auto_smooth_angle = 1.0472
+ context.object.data.use_auto_smooth = True
+ context.object.data.auto_smooth_angle = 1.0472
bpy.ops.object.select_all(action='DESELECT')
for obj in selection:
obj.select = True
- bpy.context.scene.objects.active = active
+ context.scene.objects.active = active
# Create bevel
-def CreateBevel(CurrentObject):
+def CreateBevel(context, CurrentObject):
# Save active object
- SavActive = bpy.context.active_object
+ SavActive = context.active_object
# Active "CurrentObject"
- bpy.context.scene.objects.active = CurrentObject
+ context.scene.objects.active = CurrentObject
bpy.ops.object.mode_set(mode='EDIT')
@@ -1655,20 +1655,21 @@ def CreateBevel(CurrentObject):
if Already == False:
bpy.ops.object.modifier_add(type='BEVEL')
- bpy.context.object.modifiers["Bevel"].limit_method = 'WEIGHT'
- bpy.context.object.modifiers["Bevel"].width = 0.01
- bpy.context.object.modifiers["Bevel"].profile = 0.699099
- bpy.context.object.modifiers["Bevel"].use_clamp_overlap = False
- bpy.context.object.modifiers["Bevel"].segments = 3
- bpy.context.object.modifiers["Bevel"].loop_slide = False
+ mod = context.object.modifiers[-1]
+ mod.limit_method = 'WEIGHT'
+ mod.width = 0.01
+ mod.profile = 0.699099
+ mod.use_clamp_overlap = False
+ mod.segments = 3
+ mod.loop_slide = False
bpy.ops.object.shade_smooth()
- bpy.context.object.data.use_auto_smooth = True
- bpy.context.object.data.auto_smooth_angle = 1.0471975
+ context.object.data.use_auto_smooth = True
+ context.object.data.auto_smooth_angle = 1.0471975
# Remet l'objet actif par défaut
- bpy.context.scene.objects.active = SavActive
+ context.scene.objects.active = SavActive
# Picking (template)
@@ -2072,17 +2073,15 @@ def Rebool(context, self):
SelObj_Name = []
BoolObj = []
- C = bpy.context
+ LastObj = context.active_object
- LastObj = C.active_object
-
- Brush = C.selected_objects[0]
+ Brush = context.selected_objects[0]
Brush.draw_type = "WIRE"
- obj = C.selected_objects[1]
+ obj = context.selected_objects[1]
bpy.ops.object.select_all(action='TOGGLE')
- bpy.context.scene.objects.active = obj
+ context.scene.objects.active = obj
obj.draw_type = "SOLID"
obj.select = True
bpy.ops.object.duplicate_move(
@@ -2109,7 +2108,7 @@ def Rebool(context, self):
"release_confirm": False,
},
)
- LastObjectCreated = bpy.context.active_object
+ LastObjectCreated = context.active_object
m = LastObjectCreated.modifiers.new("CT_INTERSECT", "BOOLEAN")
m.operation = "INTERSECT"
@@ -2144,7 +2143,7 @@ def Rebool(context, self):
if mb.type == 'BEVEL':
mb.show_viewport = True
- bpy.context.scene.objects.active = obj
+ context.scene.objects.active = obj
obj.select = True
if self.DontApply == False:
try:
@@ -2280,8 +2279,8 @@ class Carver(bpy.types.Operator):
if self.alt:
# Save selected objects
- self.SavSel = bpy.context.selected_objects.copy()
- if len(bpy.context.selected_objects) > 0:
+ self.SavSel = context.selected_objects.copy()
+ if len(context.selected_objects) > 0:
bpy.ops.object.select_all(action='TOGGLE')
if self.ObjectMode:
@@ -2295,8 +2294,8 @@ class Carver(bpy.types.Operator):
# Save selected objects
if self.ObjectMode:
if len(self.ObjectBrush.children) > 0:
- self.SavSel = bpy.context.selected_objects.copy()
- if len(bpy.context.selected_objects) > 0:
+ self.SavSel = context.selected_objects.copy()
+ if len(context.selected_objects) > 0:
bpy.ops.object.select_all(action='TOGGLE')
if self.ObjectMode:
@@ -2324,11 +2323,11 @@ class Carver(bpy.types.Operator):
self.CreateGeometry()
bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
# Cursor Snap
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list