Skip to content

Commit 0b2b389

Browse files
Update (#6)
* restructure to support additional file formats * update for dim3 template * rename simloader to bseq * minor fix * add notes * use blender driver system to control frames * small update with frame driver * disbale the function when not in object mode * small fix * rewrite edit * add global settings for refresh * small bug fix * minor change * add doc * remove old images * update version * update doc * fix doc * language fixes * remove warning, because the driver system was fixed after all Co-authored-by: Stefan Jeske <[email protected]>
1 parent f02ee8a commit 0b2b389

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+597
-13
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
__pycache__/
22
.DS_Store
3-
.vs_code/
3+
.vscode/
44
*.zip
55

66
# the following ignores are used to ignore the local softlink files
77
# the extern folder won't be affected by this
88
rich
99
meshio
1010
future
11-
fileseq
11+
fileseq
12+
13+
docs/_build/*

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,21 @@ DISCLAIMER: Some of the screenshots may not be up to date with the most recent v
8787

8888
After installing addon, you can find it in the toolbar, which is accessible here or toggled by pressing the `n` key.
8989

90-
![start](images/0.png)
90+
![drag](images/drag.png)
9191

9292
Then you can find it here.
9393

94-
![homepage](images/1.png)
94+
![homepage](images/location.png)
9595

9696
### 2. Load the animation sequence you want
9797

9898
You can select the directory in which your data is located through the GUI by clicking the rightmost icon. It will open the default blender file explorer. Then you can go to the directory you want, for example, like image showed below. **You only need navigate to the directory and click "Accept". Files are shown but not selectable in this dialogue.**
9999

100-
![selecticon](images/2.png)
100+
![directory](images/directory.png)
101101

102102
Then the addon will automatically try to detect the sequences in this directory, so that you simply select the sequence you want. If the desired sequence is not shown, you can switch to enter a manual pattern, where a single `@` character is used to denote a running frame index.
103103

104-
![after_selecting](images/3.png)
104+
![sequence](images/sequence.png)
105105

106106
#### 2.1 Absolute vs. Relative Paths
107107

@@ -111,19 +111,19 @@ When toggled on, the blender file must be saved before loading the sequence. The
111111

112112
If toggled off (default), it will use absolute path to load the sequence. For this, the `.blend` file does not have to be saved in advance.
113113

114-
![relative_path](images/4.png)
114+
![relative_path](images/path.png)
115115

116116
#### 2.2 Sequence List View
117117

118118
After the sequence being imported, it will be available in the `Imported Sequences` panel, with more settings being available in `Sequence Settings` panel once a sequence has been selected.
119119

120-
![settings](images/5.png)
120+
![settings](images/list.png)
121121

122122
By default, all supported file formats are simply imported as geometry (a collection of vertices, lines, triangles and quads). As such, you should be able to directly play/render the animation if it contains geometry.
123123

124124
Note: When rendering the animation, please turn on the `Lock Interface`. This will prevent artifacts from occurring, especially if the user continues to operate the Blender interface during the render process.
125125

126-
![lock interface](images/6.png)
126+
![lock interface](images/lock.png)
127127

128128
##### 2.2.1 Enable/ Disable
129129

@@ -152,7 +152,7 @@ Notes:
152152
2. After applying `Point Cloud` or `Instances` geometry nodes, you need to assign the material inside the geometry nodes. So to save your work, you can simply assign the material here, then apply the `Point Cloud` or `Instances` geometry nodes.
153153
3. To access the attributes for shading, use the `Attribute` node in the Shader Editor and simply specify the attribute string. The imported attributes can be seen in the spreadsheet browser of the Geometry Nodes tab and are also listed in the addon UI.
154154

155-
![material](images/7.png)
155+
![material](images/geometry_nodes.png)
156156

157157
#### 2.3.2 Path Information
158158

__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "Sequence Loader",
33
"description": "Loader for meshio supported mesh files/ simulation sequences",
44
"author": "Interactive Computer Graphics",
5-
"version": (0, 1, 1),
5+
"version": (0, 1, 2),
66
"blender": (3, 1, 0),
77
"warning": "",
88
"support": "COMMUNITY",

bseq/messenger.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33

44
def selected_callback():
5-
if not bpy.context.view_layer.objects.active:
6-
return
5+
6+
# seems like that this is not necessary
7+
# if not bpy.context.view_layer.objects.active:
8+
# return
9+
710
name = bpy.context.active_object.name
811
idx = bpy.data.objects.find(name)
912
if idx >= 0:

bseq/panels.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,15 @@ def draw(self, context):
196196
split = layout.split()
197197
col1 = split.column()
198198
col2 = split.column()
199+
200+
# check if edit_obj exist
201+
# if not exist any more, then delete the object manually
202+
# see here https://blender.stackexchange.com/a/164835 for more details
203+
# I personally think this implementation is not a good design,
204+
# but can't think of any better ways now
205+
if importer_prop.edit_obj and context.scene.objects.get(importer_prop.edit_obj.name) == None:
206+
bpy.data.objects.remove(importer_prop.edit_obj)
207+
199208
col1.prop_search(importer_prop, 'edit_obj', bpy.data, 'objects', text="")
200209
col2.operator("sequence.edit")
201210

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/about.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Description
2+
3+
This is an addon for Blender 3.1+ (it might work with 2.8+ but has not been tested) 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](./format.md).
4+
5+
All data is loaded *just-in-time* when the Blender frame changes, in order to avoid excessive memory consumption. By default, the addon is able to load vertices, lines, triangles and quads. It is also able to automatically extract triangle and quad surface meshes from tetrahedral and hexahedral volume meshes. Scalar and vector attributes on vertices are also imported for visualization purposes.
6+
7+
## Basic usage
8+
9+
This video shows the basic usage of this addon, i.e. how to load and render a simple sequence of particle data
10+
11+
![usage](../images/usage.gif)
12+
13+
## Affected Blender Settings
14+
15+
This addon will change the value of `Preferences`->`Save & Load` ->`Default To` ->`Relative Paths` to `false`. Default value is `true`. For information can be found [here](https://docs.blender.org/manual/en/latest/editors/preferences/save_load.html#blend-files).
16+
17+
This addon will also modify the `sys.path` variable of Blender python environment, by inserting the path of the addon itself. This makes it possible to use the bundled libraries.
18+
19+
## Dependencies
20+
21+
| name | link | license | description |
22+
| ------------- | ------------------------------------------------------- | ------- | --------------------------- |
23+
| meshio | [link](https://github.com/nschloe/meshio) | MIT | Loading mesh data |
24+
| fileseq | [link](https://github.com/justinfx/fileseq) | MIT | Detection of file sequences |
25+
| rich | [link](https://github.com/Textualize/rich) | MIT | dependency of meshio |
26+
| python-future | [link](https://github.com/PythonCharmers/python-future) | MIT | dependency of fileseq |
27+
28+
## License
29+
30+
MIT License
31+
32+
Copyright (c) 2022 Interactive Computer Graphics
33+
34+
Permission is hereby granted, free of charge, to any person obtaining a copy
35+
of this software and associated documentation files (the "Software"), to deal
36+
in the Software without restriction, including without limitation the rights
37+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
38+
copies of the Software, and to permit persons to whom the Software is
39+
furnished to do so, subject to the following conditions:
40+
41+
The above copyright notice and this permission notice shall be included in all
42+
copies or substantial portions of the Software.
43+
44+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
47+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
48+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
49+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
50+
SOFTWARE.

docs/build.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Build and install the addon
2+
3+
## Build from source
4+
5+
1. Clone the project to download both project and dependencies
6+
7+
```shell
8+
git clone https://github.com/InteractiveComputerGraphics/blender-sequence-loader.git --recurse-submodules
9+
```
10+
11+
2. Build the installable .zip file by simply running the following command. This should produce a file called `blender_sequence_loader_{date}.zip`, where `{date}` is replaced with todays date. No other dependency other than standard python3 libraries are needed to build the addon.
12+
13+
```python
14+
python3 build_addon.py
15+
```
16+
17+
18+
## Download from release page
19+
20+
Or you can simply download the latest `.zip` file from the [releases](https://github.com/InteractiveComputerGraphics/blender-sequence-loader/releases) page.
21+
22+
## Install the zip file
23+
24+
You can check the official Blender documentation [here](https://docs.blender.org/manual/en/latest/editors/preferences/addons.html#installing-add-ons) for installing and enabling addons.
25+
26+
## For developers
27+
28+
If you want to develop this addon, using soft link (on Linux/macOS) / [Symlinks](https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/) (on Windows) can be very helpful.
29+
30+
### *-nix Users
31+
32+
Once you have cloned the project, go to the root directory of this addon, you can create symlink as follows
33+
```bash
34+
ln -s extern/meshio/src/meshio meshio
35+
ln -s extern/rich/rich/ rich
36+
ln -s extern/fileseq/src/fileseq fileseq
37+
ln -s extern/python-future/src/future/ future
38+
```
39+
40+
Then create a soft link to link from the [blender addon directory](https://docs.blender.org/manual/en/latest/advanced/blender_directory_layout.html)[^1] to the directory where you download and unzip the files. For example this could look like this on MacOS,
41+
42+
```bash
43+
ln -s ~/Downloads/blender-sequence-loader ~/Library/Application Support/Blender/3.1/scripts/addons/blender-sequence-loader-dev
44+
```
45+
46+
[^1]: By default, `{USER}/scripts/addons`, `{USER}`: Location of configuration files (typically in the user’s home directory).
47+
48+
### Windows Users
49+
50+
You can use [mklink](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mklink) to do the same things as *-nix users. [^2]
51+
52+
[^2]: You will need either administrator permission, or [developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development).

docs/conf.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
# -- Project information -----------------------------------------------------
7+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8+
9+
project = 'blender-sequence-loader'
10+
copyright = '2022, InteractiveComputerGraphics'
11+
author = 'InteractiveComputerGraphics'
12+
release = '0.1.2'
13+
14+
# -- General configuration ---------------------------------------------------
15+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
16+
17+
extensions = ['myst_parser','sphinx_rtd_theme']
18+
19+
templates_path = ['_templates']
20+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
21+
22+
23+
24+
# -- Options for HTML output -------------------------------------------------
25+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
26+
27+
html_theme = "sphinx_rtd_theme"
28+
html_static_path = ['_static']
29+
source_suffix = {
30+
'.rst': 'restructuredtext',
31+
'.txt': 'markdown',
32+
'.md': 'markdown',
33+
}
34+
35+
36+
myst_heading_anchors = 2

docs/format.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# File Formats
2+
3+
The current file formats supported by [meshio](https://github.com/nschloe/meshio) [^1] are
4+
5+
> [Abaqus](http://abaqus.software.polimi.it/v6.14/index.html) (`.inp`),
6+
> ANSYS msh (`.msh`),
7+
> [AVS-UCD](https://lanl.github.io/LaGriT/pages/docs/read_avs.html) (`.avs`),
8+
> [CGNS](https://cgns.github.io/) (`.cgns`),
9+
> [DOLFIN XML](https://manpages.ubuntu.com/manpages/jammy/en/man1/dolfin-convert.1.html) (`.xml`),
10+
> [Exodus](https://nschloe.github.io/meshio/exodus.pdf) (`.e`, `.exo`),
11+
> [FLAC3D](https://www.itascacg.com/software/flac3d) (`.f3grid`),
12+
> [H5M](https://www.mcs.anl.gov/~fathom/moab-docs/h5mmain.html) (`.h5m`),
13+
> [Kratos/MDPA](https://github.com/KratosMultiphysics/Kratos/wiki/Input-data) (`.mdpa`),
14+
> [Medit](https://people.sc.fsu.edu/~jburkardt/data/medit/medit.html) (`.mesh`, `.meshb`),
15+
> [MED/Salome](https://docs.salome-platform.org/latest/dev/MEDCoupling/developer/med-file.html) (`.med`),
16+
> [Nastran](https://help.autodesk.com/view/NSTRN/2019/ENU/?guid=GUID-42B54ACB-FBE3-47CA-B8FE-475E7AD91A00) (bulk data, `.bdf`, `.fem`, `.nas`),
17+
> [Netgen](https://github.com/ngsolve/netgen) (`.vol`, `.vol.gz`),
18+
> [Neuroglancer precomputed format](https://github.com/google/neuroglancer/tree/master/src/neuroglancer/datasource/precomputed#mesh-representation-of-segmented-object-surfaces),
19+
> [Gmsh](https://gmsh.info/doc/texinfo/gmsh.html#File-formats) (format versions 2.2, 4.0, and 4.1, `.msh`),
20+
> [OBJ](https://en.wikipedia.org/wiki/Wavefront_.obj_file) (`.obj`),
21+
> [OFF](https://segeval.cs.princeton.edu/public/off_format.html) (`.off`),
22+
> [PERMAS](https://www.intes.de) (`.post`, `.post.gz`, `.dato`, `.dato.gz`),
23+
> [PLY](<https://en.wikipedia.org/wiki/PLY_(file_format)>) (`.ply`),
24+
> [STL](<https://en.wikipedia.org/wiki/STL_(file_format)>) (`.stl`),
25+
> [Tecplot .dat](http://paulbourke.net/dataformats/tp/),
26+
> [TetGen .node/.ele](https://wias-berlin.de/software/tetgen/fformats.html),
27+
> [SVG](https://www.w3.org/TR/SVG/) (2D output only) (`.svg`),
28+
> [SU2](https://su2code.github.io/docs_v7/Mesh-File/) (`.su2`),
29+
> [UGRID](https://www.simcenter.msstate.edu/software/documentation/ug_io/3d_grid_file_type_ugrid.html) (`.ugrid`),
30+
> [VTK](https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf) (`.vtk`),
31+
> [VTU](https://vtk.org/Uncyclo/VTK_XML_Formats) (`.vtu`),
32+
> [WKT](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) ([TIN](https://en.wikipedia.org/wiki/Triangulated_irregular_network)) (`.wkt`),
33+
> [XDMF](https://xdmf.org/index.php/XDMF_Model_and_Format) (`.xdmf`, `.xmf`).
34+
35+
The additionally supported file formats are
36+
37+
> [bgeo](https://github.com/wdas/partio)(`.bgeo`) [^2]
38+
> [mzd](https://github.com/InteractiveComputerGraphics/MayaMeshTools/tree/main/extern/mzd)(`.mzd`)
39+
40+
[^1]: Not all of the formats have been tested for this addon and some issues may still occur.
41+
42+
[^2]: The addon only supports particle-only `.bgeo` files
43+
44+
## Add support for customized file formats
45+
46+
You can add support for your own customized file formats. For example, if you want to support `.example` file formats.
47+
48+
To do that,
49+
1. Create a `example.py` file in the folder additional_file_formats
50+
2. Implement a function `def readexample_to_meshio(filepath):`, which reads the file from `filepath`, then construct a [meshio.Mesh](https://github.com/nschloe/meshio/wiki/meshio-Mesh()-data-structure) object.
51+
3. Add `meshio.register_format("example", [".example"], readexample_to_meshio, {".example": None})` in the global space
52+
4. Add `from . import example` in `additional_file_formats/__init__.py`
53+
54+
You can check [additional_file_formats/bgeo.py](https://github.com/InteractiveComputerGraphics/blender-sequence-loader/blob/main/additional_file_formats/bgeo.py) as an example.

docs/frame.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Frame control
2+
=============
3+
4+
You can use Blenders `driver system <https://docs.blender.org/manual/en/latest/animation/drivers/index.html>`_ to control the frame of the sequence.
5+
6+
Default settings
7+
*****************
8+
9+
Each sequence has its own property ``Current Frame`` to control its frame. By default, the value equals to the `blender current frame <https://docs.blender.org/manual/en/latest/editors/timeline.html#frame-controls>`_.
10+
11+
.. image:: ../images/current_frame.png
12+
:align: center
13+
14+
Change the value
15+
*****************
16+
17+
Right click on the ``Current Frame`` property, then click ``Edit Driver``. You can check `here <https://docs.blender.org/manual/en/latest/animation/drivers/drivers_panel.html>`_ for more details about how to edit the driver.
18+
19+
.. image:: ../images/edit_driver.png
20+
:align: center

docs/global.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Global Settings
2+
3+
There are two global settings
4+
5+
1. Print information: default `true`
6+
1. Auto Refresh: default `false`
7+
8+
## Print information
9+
10+
When this button is toggled, it will print information about the sequence imported by this addon, such as name of the object, into a separate file.
11+
12+
The file has the naming pattern `bseq_{time}`, where `{time}` is the time when rendering is started.
13+
14+
The file will be located in the [blender render output directory](https://docs.blender.org/manual/en/latest/editors/preferences/file_paths.html#render). [^1]
15+
16+
![print](../images/print.png)
17+
18+
[^1]: By default the value is `/tmp`, and this directory does not exit on windows system. So when the directory does not exist, it won't print information into file.
19+
20+
## Auto Refresh
21+
22+
When this button is toggled, it will [refresh](./list.md#refresh) **all the sequences whenever a frame change occurs**.
23+
24+
This option can be useful when some of the sequences are imported while the data is still being generated and not yet complete. Refreshing all the sequences can detect the frames that were added after being initially imported.
25+
26+
![auto refresh](../images/auto_refresh.png)

0 commit comments

Comments
 (0)