---
The blendfile module within BAT supports reading data from structs, such
as the Count property on an array modifier. However, blendfile only
supports modifying structs with type "char". This patch adds support for
writing structs of more types in blendfile blocks. Now, writing is
supported for ushort, short, uint, int, float, and ulong types.
The use case that inspired this patch was an instance where a file had
several array modifiers that prevented the file from being opened in
Blender on machines without large amounts of RAM. A solution using the
blendfile module may look like:
```
from blender_asset_tracer import blendfile
from pathlib import Path
b = blendfile.open_cached(Path('flag.blend'), mode='rb+')
for block in b.blocks:
if 'ArrayModifierData' in block.__str__():
try:
print('previous:', block.get(b'count'))
block.set(b'count', 1)
print('current:', block.get(b'count'))
except KeyError:
continue
b.close()
```
This would fail with the exception
`blender_asset_tracer.blendfile.exceptions.NoWriterImplemented: Setting
type Struct(b'int') is not supported for ArrayModifierData.count`. With
this patch, the above code succeeds and the count struct can be set to
a lower number that allows the file to be opened.
This solution implements missing functionality without adding any new
interfaces. A few details are:
* When deciding what type to write to the struct, the value is inferred
from what is given by the caller. If the caller gives a Python int, the
exact type is inferred from the DNA type ID. If they give a float, a
float is written. Otherwise, the existing logic is used to determine
whether to write a string or byte sequence.
* A \_write method was added to dna\_io.py that takes a Python struct
object and a value to write a byte sequence to the file object. This
method is used by public methods appropriately named to indicate what
type they will write.
* The check for whether the caller is trying to write an unsupported
type is left in place, but it has been changed to include types which
are now supported.
* Tests have been added that provide a mock file object, call the new
methods, and confirm that the correct bytes were written.
Reviewed By: sybren
Differential Revision: https://developer.blender.org/D14374
4.1 KiB
4.1 KiB
Blender Asset Tracer changelog
This file logs the changes that are actually interesting to users (new features, changed functionality, fixed bugs).
Version 1.12 (2022-03-25)
- Removed "late imports", to help isolate Blender add-ons bundling BAT from each other.
- Support writing
intandfloattypes. - Decided to not support the Shaman API of Flamenco 3.x in BAT. The support for that protocol will be implemented in the Flamenco 3.x add-on for Blender, and not in BAT itself. A new future version of BAT will remove support for the Shaman API altogether.
Version 1.11 (2022-02-18)
- Support UDIM images.
Version 1.10 (2022-02-03)
- Avoid doubly-compressing ZStandard (Blender 3) compressed files.
Version 1.9 (2021-11-19)
- Add
bat versioncommand to print just the version number and exit.
Version 1.8 (2021-11-09)
- Compatibility with read-only source files. When packing, file permissions are no longer copied. This means that BAT can modify paths in packed files, even when the source files were read-only.
Version 1.7 (2021-11-05)
- Add optional support for ZStandard compression, which is used to compress blend files by Blender 3.0+.
The
zstandardmodule is binary, and without it installed BAT will still be able to work in a pure-Python environment. It just won't be able to open compressed files from Blender 3.0 or newer.
Version 1.6 (2021-07-27)
- Support linked collections used as input in a Geometry Nodes modifier.
- Support collections, objects, images, and textures used as default values in nodes.
Version 1.5.1 (2021-07-22)
- Add log warning if SegmentationFault caused by dereferencing invalid pointer is silenced when strict_pointer_mode is turned off.
Version 1.5 (2021-07-22)
- Drop support for Python 3.5 and 3.6, and add support for 3.8 and 3.9.
Version 1.4.1 (2021-07-22)
- Reverted unintended bump of required Python version.
Version 1.4 (2021-07-22)
-
Add a Strict Pointer Mode setting, which determines what happens when a pointer to an unknown datablock is dereferenced. When enabled, a
SegmentationFaultexception stops the program execution. This has always been the behaviour of BAT, but it now has a name and can be disabled.On the commandline Strict Pointer Mode is now disabled by default; it can be enabled with the
-Sparameter (seebat --help).When BAT is used as library, Strict Pointer Mode is enabled by default, and can be disabled via
blender_asset_tracer.blendfile.set_strict_pointer_mode(False).
Version 1.3.1 (2021-02-04)
- Remove assertion error when a library blend file linked from a Geometry Nodes modifier does not exist.
Version 1.3 (2021-02-02)
- When creating a BAT pack, symlinks are no longer followed. This allows BAT-packing a directory structure with symlinked files (such as a Shaman checkout).
- When creating a BAT pack, mapped network drives are no longer changed from a drive letter to UNC notation. For example, when mapping a share
\\SERVER\Shareto drive letterS:\, BAT will now keep referencingS:\instead of rewriting paths to\\SERVER\Share. - Better handling of drive letters, and of paths that cross drive boundaries.
- Better testing of Windows-specific cases when running the tests on Windows, and of POSIX-specific cases on other platforms.
- Add support for Geometry Nodes modifier.
Version 1.2 (2019-10-09)
- Migrated from Pipenv to Poetry for managing Python package dependencies.
- Windows compatibility fix when using mapped network storage.
- Windows compatibility fix when using different assets with the same path but on different drives.
- Allow setting the Shaman JWT authentication token in the
SHAMAN_JWT_TOKENenvironment variable. - Blender 2.81 compatibility fix (T69976).
- Fix for external smoke caches not being packed.
- Versions 1.2.1 and 1.2.2 are functionally identical to 1.2
Version 1.1.1 (2019-04-18)
- Blender 2.79 / Python 3.5 compatibility fix.
Version 1.1 (2019-03-25)
- Add support for Shaman (https://www.flamenco.io/docs/user_manual/shaman/)
- Add support for Alembic files referenced in linked-in libraries.
Version 1.0 (2019-03-01)
- Base version after which changes will be recorded here.