modify existing abc via python

1,044 views
Skip to first unread message

Jeff Budsberg

unread,
Apr 5, 2016, 1:53:57 PM4/5/16
to alembic-discussion
hi all,
Can anyone point me to a python example where they modify an existing abc file?  I've worked through reading existing files and writing a completely new file, but it's unclear how to hand an IArchive over to OArchive.

In brief, I'd like to add an arbGeomParam to an existing abc file via python.

thanks!
-jeff

Lucas Miller

unread,
Apr 5, 2016, 7:35:26 PM4/5/16
to alembic-d...@googlegroups.com
A python module called cask may be able to help you with that.

You can't hand off an IArchive to OArchive because Alembic is meant to
be write once read many, so we currently don't allow modification of
an existing file.

Lucas

Ryan Galloway

unread,
Apr 5, 2016, 7:42:13 PM4/5/16
to alembic-d...@googlegroups.com

Hi Jeff,

Alembic comes with a Python utility called "cask" that currently lives under python/examples/cask in the Alembic repo. You may want to check it out.


Alembic files are immutable so you can't modify one per se, but cask makes it easy to read an IArchive, modify the data in place and write it back out to a new abc file. Let us know if you have any questions.

Ryan



--
You received this message because you are subscribed to the Google Groups "alembic-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to alembic-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeff Budsberg

unread,
Apr 5, 2016, 9:35:29 PM4/5/16
to alembic-discussion
thanks all!  i'll give it a try and report back if I run into anything.
-jeff
To unsubscribe from this group and stop receiving emails from it, send an email to alembic-discussion+unsub...@googlegroups.com.

Jeff Budsberg

unread,
Apr 26, 2016, 8:13:38 PM4/26/16
to alembic-discussion
I've been experimenting with cask and it's working great in my tests.  One question.. how do I author instances (ie: a shared mesh, but unique transforms)?  

This is where I'm stuck:

a = cask.Archive(f_in)
mesh = a.top.children['xform1/some_mesh']

xf2 = a.top.children["xform2"] = cask.Xform()
xf2.add_child(mesh)

xf3 = a.top.children["xform3"] = cask.Xform()
xf3.add_child(mesh)

a.write_to_file(f_out)

The resulting hierarchy looks like this (mesh was re-parented from xform1 to xform3):

ABC
--xform1
--xform2
--xform3
----mesh

When I actually want something like this:
ABC
--xform1
----mesh
--xform2
----mesh
--xform3
----mesh

Thanks in advance!
-Jeff

Ryan Galloway

unread,
Apr 26, 2016, 9:08:45 PM4/26/16
to alembic-d...@googlegroups.com

Hi Jeff,

Thanks for the feedback. Unfortunately, cask does not support instancing very well. It's on our to-do list but new feature dev time is always a balancing act. Thankfully it's OSS so maybe someone will volunteer some time :)

So with limited instance support, the add_child method is effectively a move operation. It's moving the object from one parent to another. 

That said, my cask dev branch[1] comes with a copy function so you can at least copy the object, e.g.

>>> xf2.add_child(cask.copy(mesh))

Of course this may come with a bit of a performance hit if it's a very large mesh or you have many instances.

Hope that helps,

Ryan




Thanks in advance!
-Jeff

To unsubscribe from this group and stop receiving emails from it, send an email to alembic-discuss...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "alembic-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to alembic-discuss...@googlegroups.com.

Jeff Budsberg

unread,
Apr 27, 2016, 5:16:05 PM4/27/16
to alembic-discussion
hi Ryan,
I appreciate the info.  You are correct in that copy would help, but only in small object counts.

Ultimately, I'm unable to find any way to generate a file with instancing and a varying attribute on each xform.

* In Houdini, the Alembic ROP ignores any attributes on your packed primitives (it does save out instances correctly, just no attributes on the xforms). 
* In cask, if I read in a file with instancing, add an attribute, then write it back out, I lose the instancing.

Do you have suggestions for other things to try?

thanks!
Thanks in advance!
-Jeff

To unsubscribe from this group and stop receiving emails from it, send an email to alembic-discussion+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "alembic-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to alembic-discussion+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages