Jump to content

How to get the user-defined attribute value of Alembic file in Houdini


Recommended Posts

How to get the user-defined attribute value of Alembic file in Houdini?

Hi all,
I am new to Houdini, and I'm sorry if this question is too simple.

I use the following function to add user attributes on node:

def addAttrs():
    nodeName = '|objects:pCylinder1|objects:pCylinderShape1'
    
    # compound attribute
    cmpAttrName = 'crease__objects_cyCreaseSet0'        
    cmds.addAttr(nodeName, ln=cmpAttrName, sn=cmpAttrName,    at='compound',     readable=True, writable=True, storable=True, keyable=True, numberOfChildren=6)
    
    # child attribues
    attrName = cmpAttrName+'name'
    cmds.addAttr(nodeName, ln=attrName,    sn=attrName,  dt='string',       readable=True, writable=True, storable=True, keyable=True, parent=cmpAttrName)           
    attrName = cmpAttrName+'owner'
    cmds.addAttr(nodeName, ln=attrName,   sn=attrName,   dt='string',       readable=True, writable=True, storable=True, keyable=True, parent=cmpAttrName)
    attrName = cmpAttrName+'level'       
    cmds.addAttr(nodeName, ln=attrName,   sn=attrName,   at='float',        readable=True, writable=True, storable=True, keyable=True, parent=cmpAttrName)
    attrName = cmpAttrName+'edgecnt'      
    cmds.addAttr(nodeName, ln=attrName, sn=attrName,     at='long',         readable=True, writable=True, storable=True, keyable=True, parent=cmpAttrName)
    attrName = cmpAttrName+'edges'    
    cmds.addAttr(nodeName, ln=attrName,   sn=attrName,   dt='Int32Array',   readable=True, writable=True, storable=True, keyable=True, parent=cmpAttrName)
    attrName = cmpAttrName+'vertex'       
    cmds.addAttr(nodeName, ln=attrName,  sn=attrName,    dt='Int32Array',   readable=True, writable=True, storable=True, keyable=True, parent=cmpAttrName)     

 
    

And I export the alembic file from Maya with the following command:
cmds.AbcExport(jobArg=' -frameRange 1 2  -userAttrPrefix "crease__"    -file "test.ma.crease__.abc"')


I use abcecho command to confirm that the user-defined attributes are exported into abc file:

Object name=/objects:pCylinder1
  CompoundProperty name=.xform;schema=AbcGeom_Xform_v3
Object name=/objects:pCylinder1/objects:pCylinderShape1
  CompoundProperty name=.geom;schema=AbcGeom_PolyMesh_v1
    ScalarProperty name=.selfBnds;interpretation=box;datatype=float64_t[6];arraysize=6;numsamps=1
    ArrayProperty name=P;interpretation=point;datatype=float32_t[3];arraysize=42;numsamps=1
    ArrayProperty name=.faceIndices;interpretation=;datatype=int32_t;arraysize=200;numsamps=1
    ArrayProperty name=.faceCounts;interpretation=;datatype=int32_t;arraysize=60;numsamps=1
    CompoundProperty name=.arbGeomParams;schema=
    CompoundProperty name=.userProperties;schema=
      ScalarProperty name=crease__objects_cyCreaseSet0name;interpretation=;datatype=string;arraysize=1;numsamps=1
      ScalarProperty name=crease__objects_cyCreaseSet0owner;interpretation=;datatype=string;arraysize=1;numsamps=1
      ScalarProperty name=crease__objects_cyCreaseSet0level;interpretation=;datatype=float32_t;arraysize=1;numsamps=1
      ScalarProperty name=crease__objects_cyCreaseSet0edgecnt;interpretation=;datatype=int32_t;arraysize=1;numsamps=1
      ArrayProperty name=crease__objects_cyCreaseSet0edges;interpretation=;datatype=int32_t;arraysize=20;numsamps=1
      ArrayProperty name=crease__objects_cyCreaseSet0vertex;interpretation=;datatype=int32_t;arraysize=40;numsamps=1
      ScalarProperty name=crease__objects_cyCreaseSet1name;interpretation=;datatype=string;arraysize=1;numsamps=1
      ScalarProperty name=crease__objects_cyCreaseSet1owner;interpretation=;datatype=string;arraysize=1;numsamps=1
      ScalarProperty name=crease__objects_cyCreaseSet1level;interpretation=;datatype=float32_t;arraysize=1;numsamps=1
      ScalarProperty name=crease__objects_cyCreaseSet1edgecnt;interpretation=;datatype=int32_t;arraysize=1;numsamps=1
      ArrayProperty name=crease__objects_cyCreaseSet1edges;interpretation=;datatype=int32_t;arraysize=3;numsamps=1
      ArrayProperty name=crease__objects_cyCreaseSet1vertex;interpretation=;datatype=int32_t;arraysize=6;numsamps=1
    ArrayProperty name=N;interpretation=normal;datatype=float32_t[3];arraysize=200;numsamps=1

I'm going to use these attributes to control the softness of the mesh edges in rendering. But I don't know how to get these user-defined attributes in Houdini.
I use Houdini 12~14, and it seems that Houdini doesn't show the user-defined attributes by default, but I'm not sure about this.

So, my question is:
Could you tell me how to get these user-defined attributes in Houdini?

Cheers
yao



P.S.

I can access the user attributes with the following scripts:

import _alembic_hom_extensions as abc
print '------------------'
a = abc.alembicUserProperty('/test.ma.crease__.abc', '/objects:pCylinder1/objects:pCylinderShape1', 'crease__objects_cyCreaseSet0name', 1)
print a

b = abc.alembicUserProperty('/test.ma.crease__.abc', '/objects:pCylinder1/objects:pCylinderShape1', 'crease__objects_cyCreaseSet0edges', 1)
print b

c = abc.alembicUserProperty('/test.ma.crease__.abc', '/objects:pCylinder1/objects:pCylinderShape1', 'crease__objects_cyCreaseSet0vertex', 1)
print c

But, my question is:

Could I connect the user-defined attribute(source attribute) to another node's attribute(destination attribute)? I prefer this way because if the source attribute is changed the destination attribute will be changed synchronously.

 

Edited by yaoyansi
Link to comment
Share on other sites

In Houdini you can use the Alembic node to import the object, this on its own creates a packed primitive with no attribute data.
Then use a Convert node to convert the packed object to polygons that contain all the attribute's created earlier.
 

I only tested it using Alembic files created by Houdini but should work just fine.

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...