Skip to content

Fix a bug in the viewport when deleting objects #29

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

Merged
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
![GitHub release (latest by date)](https://img.shields.io/github/v/release/InteractiveComputerGraphics/blender-sequence-loader)
[![Documentation Status](https://readthedocs.org/projects/blender-sequence-loader/badge/?version=latest)](https://blender-sequence-loader.readthedocs.io/en/latest/?badge=latest)

This is an addon for Blender 3.4+ (might work with 2.8+ but is not extensively tested on less recent versions) that enables loading of file sequences. The addon comes bundled together with [meshio](https://github.com/nschloe/meshio) which enables the loading of geometric data from a multitude of file formats. As stated there, the supported formats are listed in the following. Note that not all of the formats have been tested and some issues may still occur.
This is an addon for Blender 4.0+ (might work with 2.8+ but is not extensively tested on less recent versions) that enables loading of file sequences. The addon comes bundled together with [meshio](https://github.com/nschloe/meshio) which enables the loading of geometric data from a multitude of file formats. As stated there, the supported formats are listed in the following. Note that not all of the formats have been tested and some issues may still occur.

> [Abaqus](http://abaqus.software.polimi.it/v6.14/index.html) (`.inp`),
> ANSYS msh (`.msh`),
Expand Down
4 changes: 2 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "Sequence Loader",
"description": "Loader for meshio supported mesh files/ simulation sequences",
"author": "Interactive Computer Graphics",
"version": (0, 2, 0),
"blender": (3, 6, 0),
"version": (0, 3, 0),
"blender": (4, 0, 0),
"warning": "",
"support": "COMMUNITY",
"category": "Import-Export",
Expand Down
6 changes: 5 additions & 1 deletion bseq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
@persistent
def BSEQ_initialize(scene):
if update_obj not in bpy.app.handlers.frame_change_post:
bpy.app.handlers.frame_change_post.append(update_obj)
if auto_refresh_active not in bpy.app.handlers.frame_change_post:
bpy.app.handlers.frame_change_post.append(auto_refresh_active)
if auto_refresh_all not in bpy.app.handlers.frame_change_post:
bpy.app.handlers.frame_change_post.append(auto_refresh_all)
bpy.app.handlers.frame_change_post.append(update_obj)
if clean_unused_bseq_data not in bpy.app.handlers.save_pre:
bpy.app.handlers.save_pre.append(clean_unused_bseq_data)
subscribe_to_selected()
if print_information not in bpy.app.handlers.render_init:
bpy.app.handlers.render_init.append(print_information)
Expand Down
12 changes: 11 additions & 1 deletion bseq/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,14 @@ def auto_refresh_active(scene, depsgraph=None):
continue
if obj.mode != "OBJECT":
continue
refresh_obj(obj, scene)
refresh_obj(obj, scene)

# This becomes necessary, because when deleting objects from the viewport, they dont actually get removed from the
# sequences list, because this is not a global delete. This handler only removes sequences that are not referenced
# in any scene or collection. This handler is added to save_pre, so that unused data blocks dont get saved
def clean_unused_bseq_data(savefile):
for obj in bpy.data.objects:
if obj.BSEQ.init and len(obj.users_collection)==0 and len(obj.users_scene)==0:

# This will throw an error if it is actually still used somewhere
bpy.data.objects.remove(obj)
2 changes: 1 addition & 1 deletion bseq/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def filter_items(self, context, data, property):
# not sure if I understand correctly about this
# see reference from https://docs.blender.org/api/current/bpy.types.UIList.html#advanced-uilist-example-filtering-and-reordering
for o in objs:
if o.BSEQ.init:
if o.BSEQ.init and len(o.users_collection)>0 and len(o.users_scene)>0:
flt_flags.append(self.bitflag_filter_item)
else:
flt_flags.append(0)
Expand Down