Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blender 4.0.0 API Changed breaks addon #41 #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

bl_info = {
"name": "Modifier List",
"author": "Antti Tikka",
"version": (1, 8, 0),
"author": "Antti Tikka, Draise",
"version": (1, 7, 6),
"blender": (2, 92, 0),
"location": "Properties Editor & View3D > Sidebar & View3D > Alt + Spacebar",
"description": "Alternative UI layout for modifiers with handy features "
"+ a Sidebar tab and a popup.",
"warning": "Development version",
"warning": "",
"doc_url": "https://github.com/Symstract/modifier_list",
"category": "3D View"
}
Expand Down
11 changes: 8 additions & 3 deletions modules/operators/modifier_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ def execute(self, context):
init_active_mod_index = ob.ml_modifier_active_index

# Make adding modifiers possible when an object is pinned
override = context.copy()
override['object'] = ob

### Draise - Removed for compatibility with 4.0.0

#override = context.copy()
#override['object'] = ob

### Draise - Added the "with" for compatibility with 4.0.0
try:
bpy.ops.object.modifier_add(override, type=self.modifier_type)
with context.temp_override(id=ob):
bpy.ops.object.modifier_add(type=self.modifier_type)
except TypeError:
for mod in ALL_MODIFIERS_NAMES_ICONS_TYPES:
if mod[2] == self.modifier_type:
Expand Down
11 changes: 8 additions & 3 deletions modules/operators/modifier_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,21 @@ def invoke(self, context, event):

def apply_modifier(self, context, ml_active_object, init_mode_is_editmode):
# Make applying modifiers possible when an object is pinned
override = context.copy()
override['object'] = ml_active_object

### Draise - removed for Blender 4.0.0 compatibility

#override = context.copy()
#override['object'] = ml_active_object

active_mod_index = ml_active_object.ml_modifier_active_index
mod = ml_active_object.modifiers[active_mod_index]
mod_type = mod.type
mod_name = mod.name

try:
if self.apply_as == 'DATA':
bpy.ops.object.modifier_apply(override, modifier=mod_name)
with context.temp_override(id=ml_active_object): ### Draise - added "with" for Blender 4.0.0 compatibility
bpy.ops.object.modifier_apply(modifier=mod_name)
elif self.apply_as == 'SHAPE':
bpy.ops.object.modifier_apply_as_shapekey(
override, modifier=mod_name,
Expand Down
10 changes: 7 additions & 3 deletions modules/operators/modifier_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ def execute(self, context):
mod = ob.modifiers[ob.ml_modifier_active_index]

# Make copying modifiers possible when an object is pinned
override = context.copy()
override['object'] = ob

### Draise - removed for Blender 4.0.0 compatibility

bpy.ops.object.modifier_copy(override, modifier=mod.name)
#override = context.copy()
#override['object'] = ob

with context.temp_override(id=ob): ### Draise - added "with" for Blender 4.0.0 compatibility
bpy.ops.object.modifier_copy(modifier=mod.name)

return {'FINISHED'}
12 changes: 8 additions & 4 deletions modules/operators/modifier_move_down.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ def execute(self, context):
ml_active_ob = get_ml_active_object()

# Make using operators possible when an object is pinned
override = context.copy()
override['object'] = ml_active_ob

### Draise - removed for Blender 4.0.0 compatibility

#override = context.copy()
#override['object'] = ml_active_ob

active_mod_index = ml_active_ob.ml_modifier_active_index
active_mod_name = ml_active_ob.modifiers[active_mod_index].name
Expand All @@ -54,8 +57,9 @@ def execute(self, context):
index=mods_max_index)
ml_active_ob.ml_modifier_active_index = mods_max_index
else:
bpy.ops.object.modifier_move_down(override, modifier=active_mod_name)
ml_active_ob.ml_modifier_active_index = np.clip(active_mod_index + 1, 0, mods_max_index)
with context.temp_override(id=ml_active_ob): ### Draise - added "with" for Blender 4.0.0 compatibility
bpy.ops.object.modifier_move_down(modifier=active_mod_name)
ml_active_ob.ml_modifier_active_index = np.clip(active_mod_index + 1, 0, mods_max_index)

return {'FINISHED'}

Expand Down
12 changes: 8 additions & 4 deletions modules/operators/modifier_move_up.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ def execute(self, context):
ml_active_ob = get_ml_active_object()

# Make using operators possible when an object is pinned
override = context.copy()
override['object'] = ml_active_ob

### Draise - removed for Blender 4.0.0 compatibility

#override = context.copy()
#override['object'] = ml_active_ob

active_mod_index = ml_active_ob.ml_modifier_active_index
active_mod_name = ml_active_ob.modifiers[active_mod_index].name
Expand All @@ -51,8 +54,9 @@ def execute(self, context):
bpy.ops.object.modifier_move_to_index(modifier=active_mod_name, index=0)
ml_active_ob.ml_modifier_active_index = 0
else:
bpy.ops.object.modifier_move_up(override, modifier=active_mod_name)
ml_active_ob.ml_modifier_active_index = np.clip(active_mod_index - 1, 0, 999)
with context.temp_override(id=ml_active_ob): ### Draise - added "with" for Blender 4.0.0 compatibility
bpy.ops.object.modifier_move_up(modifier=active_mod_name)
ml_active_ob.ml_modifier_active_index = np.clip(active_mod_index - 1, 0, 999)

return {'FINISHED'}

Expand Down
11 changes: 8 additions & 3 deletions modules/operators/modifier_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,21 @@ def execute(self, context):
ml_active_ob = get_ml_active_object()

# Make using operators possible when an object is pinned
override = context.copy()
override['object'] = ml_active_ob

### Draise - removed for Blender 4.0.0 compatibility

#override = context.copy()
#override['object'] = ml_active_ob

active_mod_index = ml_active_ob.ml_modifier_active_index
active_mod = ml_active_ob.modifiers[active_mod_index]

if self.shift or prefs.always_delete_gizmo:
self.remove_gizmo_and_vertex_group(context, ml_active_ob, active_mod)

bpy.ops.object.modifier_remove(override, modifier=active_mod.name)
### Draise - added "with" for Blender 4.0.0 compatibility
with context.temp_override(id=ml_active_ob):
bpy.ops.object.modifier_remove(modifier=active_mod.name)
ml_active_ob.ml_modifier_active_index = np.clip(active_mod_index - 1, 0, 999)

return {'FINISHED'}
Expand Down