[Bf-extensions-cvs] [c7f6ef3f] master: Bool Tool: format the code with Black
Mikhail Rachinskiy
noreply at git.blender.org
Mon Mar 11 14:19:46 CET 2019
Commit: c7f6ef3fef1315e97fd7326c08b7c7ad7b82762a
Author: Mikhail Rachinskiy
Date: Mon Mar 11 17:18:40 2019 +0400
Branches: master
https://developer.blender.org/rBAc7f6ef3fef1315e97fd7326c08b7c7ad7b82762a
Bool Tool: format the code with Black
===================================================================
M object_boolean_tools.py
===================================================================
diff --git a/object_boolean_tools.py b/object_boolean_tools.py
index 42e99eae..e5688085 100644
--- a/object_boolean_tools.py
+++ b/object_boolean_tools.py
@@ -26,19 +26,19 @@ bl_info = {
"location": "View3D > Sidebar",
"description": "Bool Tool Hotkey: Ctrl Shift B",
"category": "Object",
- }
+}
import bpy
from bpy.types import (
- AddonPreferences,
- Operator,
- Panel,
- Menu,
- )
+ AddonPreferences,
+ Operator,
+ Panel,
+ Menu,
+)
from bpy.props import (
- BoolProperty,
- StringProperty,
- )
+ BoolProperty,
+ StringProperty,
+)
# ------------------- Bool Tool FUNCTIONS -------------------------
@@ -47,7 +47,7 @@ from bpy.props import (
# Hide boolean objects
def update_BoolHide(self, context):
ao = context.view_layer.objects.active
- objs = [i.object for i in ao.modifiers if i.type == 'BOOLEAN']
+ objs = [i.object for i in ao.modifiers if i.type == "BOOLEAN"]
hide_state = context.scene.BoolHide
for o in objs:
@@ -92,8 +92,8 @@ def FindCanvas(obj):
for ob in bpy.context.view_layer.objects:
if isCanvas(ob):
for mod in ob.modifiers:
- if ("BTool_" in mod.name):
- if (obj.name in mod.name):
+ if "BTool_" in mod.name:
+ if obj.name in mod.name:
return ob
@@ -116,12 +116,14 @@ def ConvertToMesh(obj):
# Do the Union, Difference and Intersection Operations with a Brush
def Operation(context, _operation):
-
prefs = bpy.context.preferences.addons[__name__].preferences
useWire = prefs.use_wire
for selObj in bpy.context.selected_objects:
- if selObj != context.active_object and (selObj.type == "MESH" or selObj.type == "CURVE"):
+ if (
+ selObj != context.active_object and
+ (selObj.type == "MESH" or selObj.type == "CURVE")
+ ):
if selObj.type == "CURVE":
ConvertToMesh(selObj)
actObj = context.active_object
@@ -181,8 +183,8 @@ def Remove(context, thisObj_name, Prop):
# Remove it from the Canvas
for mod in actObj.modifiers:
- if ("BTool_" in mod.name):
- if (_thisObj_name in mod.name):
+ if "BTool_" in mod.name:
+ if _thisObj_name in mod.name:
actObj.modifiers.remove(mod)
if Prop == "THIS":
@@ -195,8 +197,8 @@ def Remove(context, thisObj_name, Prop):
Canvas = FindCanvas(actObj)
if Canvas:
for mod in Canvas.modifiers:
- if ("BTool_" in mod.name):
- if (actObj.name in mod.name):
+ if "BTool_" in mod.name:
+ if actObj.name in mod.name:
Canvas.modifiers.remove(mod)
cyclesVis = actObj.cycles_visibility
actObj.display_type = "TEXTURED"
@@ -210,7 +212,7 @@ def Remove(context, thisObj_name, Prop):
if Prop == "CANVAS":
for mod in actObj.modifiers:
- if ("BTool_" in mod.name):
+ if "BTool_" in mod.name:
RemoveThis(mod.object.name)
@@ -218,9 +220,9 @@ def Remove(context, thisObj_name, Prop):
def EnableBrush(context, objList, canvas):
for obj in objList:
for mod in canvas.modifiers:
- if ("BTool_" in mod.name and mod.object.name == obj):
+ if "BTool_" in mod.name and mod.object.name == obj:
- if (mod.show_viewport):
+ if mod.show_viewport:
mod.show_viewport = False
mod.show_render = False
else:
@@ -235,22 +237,22 @@ def EnableThisBrush(context, set):
if obj != bpy.context.active_object:
if isCanvas(obj):
for mod in obj.modifiers:
- if ("BTool_" in mod.name):
+ if "BTool_" in mod.name:
if mod.object == bpy.context.active_object:
canvas = obj
for mod in canvas.modifiers:
- if ("BTool_" in mod.name):
+ if "BTool_" in mod.name:
if mod.object == bpy.context.active_object:
if set == "None":
- if (mod.show_viewport):
+ if mod.show_viewport:
mod.show_viewport = False
mod.show_render = False
else:
mod.show_viewport = True
mod.show_render = True
else:
- if (set == "True"):
+ if set == "True":
mod.show_viewport = True
else:
mod.show_viewport = False
@@ -274,23 +276,23 @@ def ApplyAll(context, list):
for selObj in list:
if isCanvas(selObj) and selObj == context.active_object:
for mod in selObj.modifiers:
- if ("BTool_" in mod.name):
+ if "BTool_" in mod.name:
objDeleteList.append(mod.object)
try:
bpy.ops.object.modifier_apply(modifier=mod.name)
except: # if fails the means it is multiuser data
context.active_object.data = context.active_object.data.copy() # so just make data unique
bpy.ops.object.modifier_apply(modifier=mod.name)
- del selObj['BoolToolRoot']
+ del selObj["BoolToolRoot"]
for obj in context.scene.objects:
if isCanvas(obj):
for mod in obj.modifiers:
- if mod.type == 'BOOLEAN':
- if mod.object in objDeleteList: # do not delete brush that is used by another canvas
- objDeleteList.remove(mod.object) # remove it from deletion
+ # do not delete brush that is used by another canvas
+ if mod.type == "BOOLEAN" and mod.object in objDeleteList:
+ objDeleteList.remove(mod.object) # remove it from deletion
- bpy.ops.object.select_all(action='DESELECT')
+ bpy.ops.object.select_all(action="DESELECT")
for obj in objDeleteList:
obj.select_set(state=True)
bpy.ops.object.delete()
@@ -301,8 +303,7 @@ def ApplyThisBrush(context, brush):
for obj in context.scene.objects:
if isCanvas(obj):
for mod in obj.modifiers:
- if ("BTool_" + brush.name in mod.name):
-
+ if "BTool_" + brush.name in mod.name:
# Apply This Brush
context.view_layer.objects.active = obj
try:
@@ -310,20 +311,24 @@ def ApplyThisBrush(context, brush):
except: # if fails the means it is multiuser data
context.active_object.data = context.active_object.data.copy() # so just make data unique
bpy.ops.object.modifier_apply(modifier=mod.name)
- bpy.ops.object.select_all(action='TOGGLE')
- bpy.ops.object.select_all(action='DESELECT')
+ bpy.ops.object.select_all(action="TOGGLE")
+ bpy.ops.object.select_all(action="DESELECT")
# Garbage Collector
brush.select_set(state=True)
# bpy.ops.object.delete()
+
# ------------------ Bool Tool OPERATORS --------------------------------------
+
class BTool_DrawPolyBrush(Operator):
bl_idname = "btool.draw_polybrush"
bl_label = "Draw Poly Brush"
- bl_description = ("Draw Polygonal Mask, can be applied to Canvas > Brush or Directly\n"
- "Note: ESC to Cancel, Enter to Apply, Right Click to erase the Lines")
+ bl_description = (
+ "Draw Polygonal Mask, can be applied to Canvas > Brush or Directly\n"
+ "Note: ESC to Cancel, Enter to Apply, Right Click to erase the Lines"
+ )
count = 0
store_cont_draw = False
@@ -348,30 +353,30 @@ class BTool_DrawPolyBrush(Operator):
actObj = bpy.context.active_object
if self.count == 1:
actObj.select_set(state=True)
- bpy.ops.gpencil.draw('INVOKE_DEFAULT', mode="DRAW_POLY")
+ bpy.ops.gpencil.draw("INVOKE_DEFAULT", mode="DRAW_POLY")
- if event.type in {'RIGHTMOUSE'}:
+ if event.type in {"RIGHTMOUSE"}:
# use this to pass to the Grease Pencil eraser (see T52321)
pass
- if event.type in {'RET', 'NUMPAD_ENTER'}:
+ if event.type in {"RET", "NUMPAD_ENTER"}:
- bpy.ops.gpencil.convert(type='POLY')
+ bpy.ops.gpencil.convert(type="POLY")
self.set_cont_draw(context)
for obj in context.selected_objects:
if obj.type == "CURVE":
obj.name = "PolyDraw"
bpy.context.view_layer.objects.active = obj
- bpy.ops.object.select_all(action='DESELECT')
+ bpy.ops.object.select_all(action="DESELECT")
obj.select_set(state=True)
bpy.ops.object.convert(target="MESH")
- bpy.ops.object.mode_set(mode='EDIT')
- bpy.ops.mesh.select_all(action='SELECT')
+ bpy.ops.object.mode_set(mode="EDIT")
+ bpy.ops.mesh.select_all(action="SELECT")
bpy.ops.mesh.edge_face_add()
bpy.ops.mesh.flip_normals()
- bpy.ops.object.mode_set(mode='OBJECT')
- bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_MASS')
+ bpy.ops.object.mode_set(mode="OBJECT")
+ bpy.ops.object.origin_set(type="ORIGIN_CENTER_OF_MASS")
bpy.ops.object.modifier_add(type="SOLIDIFY")
for mod in obj.modifiers:
if mod.name == "Solidify":
@@ -380,7 +385,7 @@ class BTool_DrawPolyBrush(Operator):
mod.offset = 0
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list