No "_sample_class" in cask.Points ?
Closed this issue · 3 comments
Hello and thanks for cask
.
I try to generate an abc file from scrach.
It’s supposed to represent a Root/particleShape
node of type Points
(with two points in my example).
import alembic
import cask
import imath
b = cask.Archive()
root = cask.Xform(name='Root')
root.parent = b.top
assert b.top.children['Root']
pts = cask.Points(name='particleShape')
pts.parent = root
assert root.children['particleShape']
assert b.top.children['Root/particleShape']
point_count = 2
id_array = imath.IntArray(point_count)
id_array[0] = 0
id_array[1] = 1
pos_array = imath.V3fArray(point_count)
pos_array[0] = imath.V3f(0.0, 0.0, 0.0)
pos_array[1] = imath.V3f(10.0, 0.0, 0.0)
# uncomment to fix
# cask.Points._sample_class = alembic.AbcGeom.OPointsSchemaSample
pts_sample = alembic.AbcGeom.OPointsSchemaSample()
pts_sample.setIds(id_array)
pts_sample.setPositions(pos_array)
pts.set_sample(pts_sample)
b.write_to_file("test.abc")
This code raise an assert :
Traceback (most recent call last):
File "/code.py", line 138, in <module>
pts.set_sample(pts_sample)
File "/cask.py", line 1434, in set_sample
"Can not set %s on %s object" % (sample.__class__.__name__, self.type())
AssertionError: Can not set OPointsSchemaSample on Points object
After some digging into cask code, I thing there is missing _sample_class
property , from Points
class : https://github.com/alembic/cask/blob/master/cask.py#L1684
Maybe it’s a bug, maybe there is good reason for this (don’t hesitate to justified in tho Points
class docstring).
Adding the property (uncomment the line) seems to work. I say seems as abcls
prints the same output between my fresh abc and my reference one.
What are you thought about this ?
Thanks in advance !
Hi Dorian,
Thanks for the report. I don't recall the history here, it's definitely possible it was not intentional. If it results in a valid abc file that is certainly a good sign. I'm not in a position to run tests at the moment (responding to this while camping in the Mojave area), but I would recommend running the cask unit tests with your change (and possibly the alembic tests, as well. If all the unit tests pass, then please submit a PR.
Ryan
Generated abc file is valid. I will run unit tests.
responding to this while camping in the Mojave area
Come on! Take your break!
Resolved by #16