Skip to content

Commit

Permalink
fix: remove layer report error when no layer
Browse files Browse the repository at this point in the history
  • Loading branch information
atticus-lv committed Aug 3, 2024
1 parent 0a4f011 commit cca8cfc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion bl_operator/ops_gp_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def poll(cls, context):
def execute(self, context):
nt: bpy.types.NodeTree = context.space_data.edit_tree
gp_data: bpy.types.GreasePencil = nt.grease_pencil
if not gp_data: return {'CANCELLED'}
if not gp_data:
return {'CANCELLED'}
with BuildGreasePencilData(gp_data) as gp_data_builder:
if SelectedGPLayersRuntime.selected_layers():
for layer in SelectedGPLayersRuntime.selected_layers():
Expand Down
9 changes: 5 additions & 4 deletions model/model_gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,12 @@ def remove_active_layer(self) -> 'BuildGreasePencilData':

def remove_layer(self, layer_name_or_index: str | int) -> 'BuildGreasePencilData':
"""Remove the grease pencil annotation layer."""
if not (layer := self._get_layer(layer_name_or_index)): return self

index = self.gp_data.layers.find(layer.info)
self.gp_data.layers.remove(layer)
try:
if not (layer := self._get_layer(layer_name_or_index)): return self

index = self.gp_data.layers.find(layer.info)
self.gp_data.layers.remove(layer)

next_layer = self.gp_data.layers[index - 1]
if not self.edit_layer.is_in_2d(next_layer):
self.edit_layer.display_in_3d(next_layer)
Expand Down

0 comments on commit cca8cfc

Please sign in to comment.