Hi,
thanks for the details.
Actually, I misunderstood your question on your first post. So you can forget my previous answer. Sorry about that!
I thought you wanted to store multiple values in a single string property value.
About your original question, yes, that's that possible using IOHelpers.
Check the example in my other
post, the one at the end where I create a string property.
python code
# create the string values for each point
string_values= []
for i in range(point_count):
# each string has an increasing size
string_values.append('text_%s' % str(i).zfill(i + 1))
# this method assumes the property already exists
set_point_property_values(particle_container, 'my_string_prop', string_values)
Let me know if you need more help with this.
In fact, the ResourceProperty C++ API has different "init" method that takes an array of sizes along with an array of values, so that you can specify the size of each value instead of having to set the same size for all of them.
cpp code
//! \brief Init the items of the property with different numbers of values
//! \param[in] type the type of values stored in each item
//! \param[in] item_value_count array containing the number of values for each item
//! \param[in] item_count the number of items
void init(const Type& type, const unsigned int *item_value_count, const unsigned int& item_count);
But sadly, this method isn't available in the Clarisse Python API because SWIG (the tool that creates the Python bindings) doesn't support C++ method overloads (
SWIG: Ambiguity in Overloading). The problem is that both methods have the same name but different parameter types, and only the 1st one becomes available in Python because of SWIG's limitation.
I really recommend you to use the IOHelpers API, which does a lot of stuff under the hood that isn't always possible to do in Python (like resizing or replacing existing property values).
Let us know if you chose to do so and if you need help rewriting some of your scripts with IOHelpers.
-----
About the Alembic error:
jboissinot wrote:But, I'm getting the following error when exporting the Alembic file:
- Code: Select all
Alembic export: an error occured during the export process: OArrayProperty::set()
ERROR: EXCEPTION:
Illegal NULL character found in string data
This is an error in the Alembic library caused by the Clarise string property which is partially uninitialized when you don't fill the extra space.
I haven't managed to reproduce the same error, but I'm pretty sure the reason is that when you declare a ResourceProperty of type TYPE_CHAR, where each item has a size of N, if you don't fill all the N characters, then the remaining characters will contain random uninitialized values among which, maybe, the null character '0' which indicates the end of the string.
For example, if you set "hello" in a string of capacity 100, and don't fill the remaining characters, it could look like this in memory:
- Code: Select all
[ h , e, l, l, o, 3, z, g, T, 0, ... ]
Clarisse doesn't know the string actually ends after "hello", it knows it has 100 characters so it will export all of them.
Then Alembic expects a string of exactly 100 characters but finds an unexpected null character before the end, and throws an error.
That's why filling the values with spaces fixes the error.
-----
Cheers,