Skip to content

Commit

Permalink
Merge pull request #29 from maxivz/bugfixes
Browse files Browse the repository at this point in the history
Update for blender 4.2
  • Loading branch information
maxivz authored Aug 11, 2024
2 parents 294cd8b + 449b603 commit 519416b
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 55 deletions.
13 changes: 7 additions & 6 deletions op/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ def execute(self, context):
for space in area.spaces:
if space.type == 'VIEW_3D':
# Make active tool is set to select
override = bpy.context.copy()
override["space_data"] = area.spaces[0]
override["area"] = area
bpy.ops.wm.tool_set_by_id(
override, name="builtin.select_box")
context_override = bpy.context.copy()
context_override["space_data"] = area.spaces[0]
context_override["area"] = area

with context.temp_override(**context_override):
bpy.ops.wm.tool_set_by_id( name="builtin.select_box")

if space.show_gizmo_object_translate:
space.show_gizmo_object_translate = False
Expand Down Expand Up @@ -541,7 +542,7 @@ def execute(self, context):
lp = lp[0]

for obj in selection:
if obj is not lp:
if obj != lp:
obj.name = lp.name[:-len(lp_suffix)] + hp_suffix

return{'FINISHED'}
Expand Down
6 changes: 3 additions & 3 deletions op/quick_lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class QuickLattice(bpy.types.Operator):
modkey = 0

def setup_lattice(self, context, selection):
if selection is not []:
if selection != []:
if context.mode == 'OBJECT':
verts = selection.data.vertices
vert_positions = [
Expand Down Expand Up @@ -68,7 +68,7 @@ def setup_lattice(self, context, selection):

# Remove old vertex group if it existed
vg = selection.vertex_groups.get("lattice_group")
if vg is not None:
if vg != None:
selection.vertex_groups.remove(vg)

vg = selection.vertex_groups.new(name="lattice_group")
Expand Down Expand Up @@ -143,7 +143,7 @@ def apply_lattice(self, context, lattice):

# Delete vertex group
vg = obj.vertex_groups.get("lattice_group")
if vg is not None:
if vg != None:
obj.vertex_groups.remove(vg)

# Delete lattice
Expand Down
12 changes: 6 additions & 6 deletions op/quick_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ def draw_ui(self, context, event):
font_id = 0
blf.color(font_id, 1, 1, 1, 1)
blf.position(font_id, width / 2 - 100, 140, 0)
blf.size(font_id, 30, 60)
blf.size(font_id, 25)
blf.draw(font_id, "Depth: ")

blf.color(font_id, 0, 0.8, 1, 1)
blf.position(font_id, width / 2, 140, 0)
blf.size(font_id, 30, 60)
blf.size(font_id, 25)
blf.draw(font_id, str(self.depth)[0:4])

blf.color(font_id, 1, 1, 1, 1)
Expand All @@ -52,12 +52,12 @@ def draw_ui(self, context, event):

blf.color(font_id, 0, .8, 1, 1)
blf.position(font_id, width / 2 + 40, 100, 0)
blf.size(font_id, 30, 60)
blf.size(font_id, 25)
blf.draw(font_id, str(self.resolution))


def setup_pipe(self, context, selection):
if selection is not []:
if selection != []:
#Select object:
itools.set_mode('OBJECT')
base_obj = itools.get_selected('OBJECT')
Expand Down Expand Up @@ -166,14 +166,14 @@ def execute(self, context):
def modal(self, context, event):
if event.type == 'MOUSEMOVE': # Apply
if event.ctrl:
if self.modkey is not 1:
if self.modkey != 1:
self.modkey = 1
self.initial_pos_x = event.mouse_x
self.initial_resolution = self.resolution
self.change_resolution = True

else:
if self.modkey is not 0:
if self.modkey != 0:
self.modkey = 0
self.initial_pos_x = event.mouse_x
self.initial_depth = self.depth
Expand Down
14 changes: 7 additions & 7 deletions op/radial_symmetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ def draw_ui(self, context, event):
font_id = 0
blf.color(font_id, 1, 1, 1, 1)
blf.position(font_id, width / 2 - 100, 140, 0)
blf.size(font_id, 30, 60)
blf.size(font_id, 25)
blf.draw(font_id, "Count: ")

blf.color(font_id, 0, 0.8, 1, 1)
blf.position(font_id, width / 2, 140, 0)
blf.size(font_id, 30, 60)
blf.size(font_id, 25)
blf.draw(font_id, str(self.sym_count))

blf.color(font_id, 1, 1, 1, 1)
Expand All @@ -74,7 +74,7 @@ def draw_ui(self, context, event):

blf.color(font_id, 0, .8, 1, 1)
blf.position(font_id, width / 2, 100, 0)
blf.size(font_id, 30, 60)
blf.size(font_id, 25)
blf.draw(font_id, str(self.ui_axis)[2])

blf.color(font_id, 1, 1, 1, 1)
Expand All @@ -83,11 +83,11 @@ def draw_ui(self, context, event):

blf.color(font_id, 0, .8, 1, 1)
blf.position(font_id, width / 2 + 60, 60, 0)
blf.size(font_id, 30, 60)
blf.size(font_id, 25)
blf.draw(font_id, str(not bpy.data.objects[self.offset_obj].hide_viewport))

def setup_symmetry(self, context, selection):
if selection is not []:
if selection != []:
sel_pivot = selection.location
new_obj = bpy.data.objects.new('new_obj', None)
bpy.ops.object.empty_add(type='ARROWS', location=sel_pivot)
Expand Down Expand Up @@ -242,14 +242,14 @@ def execute(self, context):
def modal(self, context, event):
if event.type == 'MOUSEMOVE': # Apply
if event.ctrl:
if self.modkey is not 1:
if self.modkey != 1:
self.modkey = 1
self.initial_pos_x = event.mouse_x
self.initial_sym_count = self.sym_count
self.change_axis = True

else:
if self.modkey is not 0:
if self.modkey != 0:
self.modkey = 0
self.initial_pos_x = event.mouse_x
self.initial_sym_axis = self.sym_axis
Expand Down
14 changes: 7 additions & 7 deletions op/rebase_cylinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ def draw_ui(self, context, event):
font_id = 0
blf.color(font_id, 1, 1, 1, 1)
blf.position(font_id, width / 2 - 100, 140, 0)
blf.size(font_id, 30, 60)
blf.size(font_id, 25)
blf.draw(font_id, "Count: ")

blf.color(font_id, 0, 0.8, 1, 1)
blf.position(font_id, width / 2, 140, 0)
blf.size(font_id, 30, 60)
blf.size(font_id, 25)
blf.draw(font_id, str(self.sides_count))

blf.color(font_id, 1, 1, 1, 1)
Expand All @@ -55,7 +55,7 @@ def draw_ui(self, context, event):

blf.color(font_id, 0, .8, 1, 1)
blf.position(font_id, width / 2, 100, 0)
blf.size(font_id, 30, 60)
blf.size(font_id, 25)
blf.draw(font_id, str(self.ui_axis)[2])

blf.color(font_id, 1, 1, 1, 1)
Expand All @@ -64,11 +64,11 @@ def draw_ui(self, context, event):

blf.color(font_id, 0, .8, 1, 1)
blf.position(font_id, width / 2 + 60, 60, 0)
blf.size(font_id, 30, 60)
blf.size(font_id, 25)
blf.draw(font_id, str(self.merge_distance)[0:6])

def setup_rebase(self, context, selection):
if selection is not []:
if selection != []:
# Separate Selected Edge
bpy.ops.mesh.separate(type='SELECTED')
new_selection = bpy.context.selected_objects
Expand Down Expand Up @@ -237,14 +237,14 @@ def execute(self, context):
def modal(self, context, event):
if event.type == 'MOUSEMOVE': # Apply
if event.ctrl:
if self.modkey is not 1:
if self.modkey != 1:
self.modkey = 1
self.initial_pos_x = event.mouse_x
self.initial_sides_count = self.sides_count
self.change_axis = True

else:
if self.modkey is not 0:
if self.modkey != 0:
self.modkey = 0
self.initial_pos_x = event.mouse_x
self.initial_rebase_axis = self.rebase_axis
Expand Down
2 changes: 1 addition & 1 deletion op/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def select_loop_directional(edge, directional=True, direction=0):
print("LOOP WILL JUMP ROW")
new_selection = selection
iterate = False
if len([face for face in new_selection[0].link_faces if len(list(face.verts)) is not 4]) is not 0:
if len([face for face in new_selection[0].link_faces if len(list(face.verts)) != 4]) != 0:
# End selection on ngons or triangles
print("END LOOP")
iterate = False
Expand Down
45 changes: 25 additions & 20 deletions op/smart_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@ def mouse_2d_to_3d(context, event):
location = region_2d_to_location_3d(context.region, context.space_data.region_3d, (x, y), (0, 0, 0))
return Vector(location)


class CSMove(bpy.types.Operator):
bl_idname = "mesh.cs_move"
bl_label = "CS Move"
bl_description = "Context Sensitive Move Tool"
bl_options = {'REGISTER', 'UNDO'}

def smart_move(self):
def smart_move(self,context):
area = bpy.context.area
for space in area.spaces:
if space.type != 'VIEW_3D':
continue
# Make sure active tool is set to select
override = bpy.context.copy()
override["space_data"] = area.spaces[0]
override["area"] = area
bpy.ops.wm.tool_set_by_id(override, name="builtin.select_box")
context_override = bpy.context.copy()
context_override["space_data"] = area.spaces[0]
context_override["area"] = area

with context.temp_override(**context_override):
bpy.ops.wm.tool_set_by_id(name="builtin.select_box")

if space.show_gizmo_object_translate:
bpy.ops.transform.translate('INVOKE_DEFAULT')
Expand All @@ -34,7 +35,7 @@ def smart_move(self):
space.show_gizmo_object_scale = False

def execute(self, context):
self.smart_move()
self.smart_move(context)
return{'FINISHED'}


Expand All @@ -44,17 +45,19 @@ class CSRotate(bpy.types.Operator):
bl_description = "Context Sensitive Rotate Tool"
bl_options = {'REGISTER', 'UNDO'}

def smart_rotate(self):
def smart_rotate(self, context):

area = bpy.context.area
for space in area.spaces:
if space.type != 'VIEW_3D':
continue
# Make sure active tool is set to select
override = bpy.context.copy()
override["space_data"] = area.spaces[0]
override["area"] = area
bpy.ops.wm.tool_set_by_id(override, name="builtin.select_box")
context_override = bpy.context.copy()
context_override["space_data"] = area.spaces[0]
context_override["area"] = area

with context.temp_override(**context_override):
bpy.ops.wm.tool_set_by_id(name="builtin.select_box")

if space.show_gizmo_object_rotate:
bpy.ops.transform.rotate('INVOKE_DEFAULT')
Expand All @@ -64,28 +67,30 @@ def smart_rotate(self):
space.show_gizmo_object_scale = False

def execute(self, context):
self.smart_rotate()
self.smart_rotate(context)
return{'FINISHED'}


#TODO: Optimize CSMove, Rotate and Scale into a single class with inheritance
class CSScale(bpy.types.Operator):
bl_idname = "mesh.cs_scale"
bl_label = "CS Scale"
bl_description = "Context Sensitive Scale Tool"
bl_options = {'REGISTER', 'UNDO'}

def smart_scale(self):
def smart_scale(self, context):
areas = bpy.context.workspace.screens[0].areas

area = bpy.context.area
for space in area.spaces:
if space.type != 'VIEW_3D':
continue
# Make sure active tool is set to select
override = bpy.context.copy()
override["space_data"] = area.spaces[0]
override["area"] = area
bpy.ops.wm.tool_set_by_id(override, name="builtin.select_box")
context_override = bpy.context.copy()
context_override["space_data"] = area.spaces[0]
context_override["area"] = area

with context.temp_override(**context_override):
bpy.ops.wm.tool_set_by_id(name="builtin.select_box")

if space.show_gizmo_object_scale:
bpy.ops.transform.resize('INVOKE_DEFAULT')
Expand All @@ -95,7 +100,7 @@ def smart_scale(self):
space.show_gizmo_object_scale = True

def execute(self, context):
self.smart_scale()
self.smart_scale(context)
return{'FINISHED'}


Expand Down
2 changes: 1 addition & 1 deletion utils/itools.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def select(target, mode='', item=True, replace=False, deselect=False, add_to_his
if deselect:
selection_value = False

if type(target) is not list:
if type(target) != list:
target = [target]

if mode == 'OBJECT':
Expand Down
2 changes: 1 addition & 1 deletion utils/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def is_border(selection):
# every edge must be adjacent with two other edges, if its a closed
# border the number of adjacent edges should be at least 2 X number edges
adjacent_edges = [neightbour for edge in selection for verts in edge.verts
for neightbour in verts.link_edges if neightbour in selection and neightbour is not edge]
for neightbour in verts.link_edges if neightbour in selection and neightbour != edge]
return (all(is_border_edge(edge) for edge in selection) and len(adjacent_edges) >= len(selection) * 2)


Expand Down
6 changes: 3 additions & 3 deletions utils/user_prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ def get_enable_legacy_tools():

# Check for integrations:
f2_active = addon_installed("F2")
loop_tools_active = addon_installed("mesh_looptools")
loop_tools_active = addon_installed("LoopTools")
qblocker_active = addon_installed("QBlocker")
bezierutilities_active = addon_installed("blenderbezierutils")
textools_active = addon_installed("TexTools")
set_flow_active = addon_installed("EdgeFlow-master")
set_flow_active = addon_installed("EdgeFlow")


class MenuPlaceholder(bpy.types.Operator):
Expand Down Expand Up @@ -428,7 +428,7 @@ def draw_general(self, context):
row = box.row(align=True)
row.prop(self, "enable_legacy_tools", toggle=False)

if float(bpy.app.version_string[:3]) >= 2.82:
if bpy.app.version >= (2,82,0):
row = box.row(align=True)
row.prop(self, "enable_legacy_origin", toggle=False)

Expand Down

0 comments on commit 519416b

Please sign in to comment.