Jump to content

Export Import alembic camera with Python


kiryha

Recommended Posts

Hi, guys

I need to exchange camera animation between scenes and I guess that Alembic is a good option for this. I can import the alembic camera:
 

OBJ = hou.node('/obj/')
CAM = OBJ.createNode('alembicarchive', 'CAM')
CAM.parm('fileName').set('C:/temp/cam.abc')
CAM.parm('buildHierarchy').pressButton()



Now I need to figure out how can I export the camera from my scene...

abc_export_01.PNG.885b793add3be713b931a0d4715d4d01.PNG

I can export camera with Alembic ROP but maybe there is a more elegant solution?

sceneRoot = hou.node('/obj/')

# Get camera object
camera = hou.node('obj/{}'.format(cameraName))

# Get Camera parent nodes
listCameraNodes = '{}'.format(camera.name())
for i in camera.inputAncestors():
    listCameraNodes += ' {}'.format(i.name())


# Create ROP network
ROP = sceneRoot.createNode('ropnet')
ABC = ROP.createNode('alembic')
ABC.parm('trange').set(1)
ABC.parm('filename').set('C:/temp/camera_001.abc')
ABC.parm('objects').set(listCameraNodes)
ABC.parm('execute').pressButton()
ROP.destroy()

cameraExportImportABC_001.hiplc

Edited by kiryha
Link to comment
Share on other sites

To import a camera through alembic, a good solution is not to use the Build Hierarchy every time, but read the parameters directly from it using the module.

>>> import _alembic_hom_extensions as abc


http://www.sidefx.com/docs/houdini/hom/abc_extensions.html

From it you can pull out all the transformations and some data on the camera.

For export, it is better to have a HDA in which you could indicate the path to the camera where all its parameters would be read, after that the camera would be baked and then exported to Alembic.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...