Write Houdini attributes and groups via Pyton API

852 views
Skip to first unread message

Paul Winex

unread,
Nov 12, 2015, 2:58:11 PM11/12/15
to alembic-discussion
I try to export Maya geometry using default maya python alembic package (Maya 2016). How should I write the attributes and groups that Houdini can to see them?

This is a simple exporter polygons. I need to add write custom attributes to abc
https://gist.github.com/paulwinex/421cf838c0d2def9a55f

Thanks!

Lucas Miller

unread,
Nov 12, 2015, 3:12:14 PM11/12/15
to alembic-d...@googlegroups.com
You can either put it in user attributes, if it's pipeline specific attrs:
http://docs.alembic.io/python/examples.html#write-non-standard-data-for-a-polymesh

Or add them as arbitrary geometry parameters: (oschema.getArbGeomParams())

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

Paul Winex

unread,
Nov 12, 2015, 4:06:11 PM11/12/15
to alembic-discussion

I was tried this. Houdini cant see my data. https://gist.github.com/paulwinex/511974828d492e18b0c6  line 124


Can you get me any example witn oschema.getArbGeomParams()? Just simple example that write custom attribute (point ar prim) for houdini.

Lucas Miller

unread,
Nov 12, 2015, 4:33:39 PM11/12/15
to alembic-d...@googlegroups.com
I can get you part way:

arb = mesh.getArbGeomParams()
mass = alembic.AbcGeom.ODoubleGeomParam(arb, "mass", False,
alembic.AbcGeom.GeometryScope.kVertexScope, 1)

I couldn't find a simple way to set samples on it though.

There are some more complicated hints in here though:

https://github.com/alembic/alembic/tree/master/python/PyAlembic/Tests

Paul Winex

unread,
Nov 12, 2015, 4:46:58 PM11/12/15
to alembic-discussion
Error evaluate file in Houdini with your example (((
I try to read file saved in Houdini to explore the structure. I use this code. http://derangedartisan.blogspot.ru/2014/04/testing-uv-export.html
But maya is crach on line 6.
Also i found
getArbGeomParams in file testPolyMesh.py in tis examples https://github.com/alembic/alembic/tree/master/python/PyAlembic/Tests
But only two lines:
    arbattrs = mesh.getArbGeomParams()
    assert not arbattrs
"arbattrs" do not use more

пятница, 13 ноября 2015 г., 1:33:39 UTC+4 пользователь Lucas написал:

Lucas Miller

unread,
Nov 12, 2015, 5:12:55 PM11/12/15
to alembic-d...@googlegroups.com
Yes, I didn't actually set any data on it, just showed you how the
GeomParam could be created and given a per point scope.

Paul Winex

unread,
Nov 13, 2015, 1:43:20 AM11/13/15
to alembic-discussion
I found this example
https://github.com/autodesk-adn/Maya-devkit/blob/master/win/devkit/plug-ins/AbcBullet/AttributesWriter.cpp#L371

http://docs.alembic.io/python/alembic/abcg.html#alembic.AbcGeom.ODoubleGeomParam
Where is subscription about arguments?
I cant found any python example how to pass data to ODoubleGeomParam



пятница, 13 ноября 2015 г., 2:12:55 UTC+4 пользователь Lucas написал:

Paul Winex

unread,
Nov 13, 2015, 2:43:35 AM11/13/15
to alembic-discussion
I found another example with GeomParam

http://lists.blender.org/pipermail/bf-blender-cvs/2015-March/075137.html

Some interesting lines

m_param_colors = OC3fGeomParam(geom_props, "colors", false, kVertexScope, 1, 0);
...
std
::vector<V3f> colors_buffer;
...
OV3fGeomParam
::Sample colors = paths_create_sample_colors(*m_pathcache, *m_totpath, totkeys, colors_buffer);
...
m_param_colors
.set(colors);
...
m_param_colors
.set(OC3fGeomParam::Sample(C3fArraySample(path_sample.colors), kVertexScope));



i cant fount C3fArraySample class in python

Paul Winex

unread,
Nov 13, 2015, 5:59:59 AM11/13/15
to alembic-discussion
I have this code to build array data

mesh_samp = OPolyMeshSchemaSample(

        p_points, p_faceIndices, p_faceCounts

       )

mesh.set(mesh_samp)


arb
= mesh.getArbGeomParams()
mass
= ODoubleGeomParam(arb, "mass", False, GeometryScope.kVertexScope, 1)
array
= Float64TPTraits.arrayType( len(p_points) )
for i in range( len(p_points) ):
    array
[i] = 1.23
mass_samp
= ODoubleGeomParamSample()
mass_
samp.setVals( array )


how i can applay this data (array) to mesh_samp?


Paul Winex

unread,
Nov 13, 2015, 6:11:28 AM11/13/15
to alembic-discussion
Its WORK!

arb = mesh.getArbGeomParams()
mass
= ODoubleGeomParam(arb, "mass", False, GeometryScope.kVertexScope, 1)
# create array
array
= Float64TPTraits.arrayType( len(p_points) )
for i in range( len(p_points) ):
array
[i] = 1.23

samp
= ODoubleGeomParamSample()
samp
.setVals( array )
mass
.set(samp)

I have point attribute mass in houdini!

Now i need to write PRIMITIVE attribute


Paul Winex

unread,
Nov 13, 2015, 7:10:47 AM11/13/15
to alembic-discussion
https://gist.github.com/paulwinex/8b53ed7543910974c10d

This example with export point, vertex and prim attributes. Now i will try to export vector data.

Paul Winex

unread,
Nov 13, 2015, 7:22:02 AM11/13/15
to alembic-discussion
# point attrib vector
color
= OV3fGeomParam(arb, "Cd", False, GeometryScope.kVertexScope, 1)
array
= P3fTPTraits.arrayType( len(p_points) )
for i in range( len(p_points) ):

   array
[i] = V3f(1.0, 0.0, 0.0)
samp
= OV3fGeomParamSample()
samp
.setVals( array )
color
.set(samp)

Part for vector attribute


Now i need to export groups. Any ideas? Tt seems that alembic does not support point group.

Paul Winex

unread,
Nov 14, 2015, 12:55:31 PM11/14/15
to alembic-discussion
Alembic support poly groups only. This code create group with faseSets

# example array
arr
= Int32TPTraits.arrayType(4)
for i in range(4):
    arr
[i] = i
# create face set
samp
= OFaceSetSchemaSample()
samp
.setFaces(arr)
# write to mesh
faceSet
= mesh.createFaceSet('my_group_1')
faceSetSchema
= faceSet.getSchema()
faceSetSchema
.set(samp)


Paul Winex

unread,
Nov 14, 2015, 1:39:47 PM11/14/15
to alembic-discussion

Paul Winex

unread,
Nov 14, 2015, 2:46:10 PM11/14/15
to alembic-discussion
Next step - UV, Normals and animation...

Paul Winex

unread,
Nov 15, 2015, 4:42:33 AM11/15/15
to alembic-discussion
UVs, Normals and animation

https://gist.github.com/paulwinex/aae3751e168a3ddb31e3

I think is enough to start develop main application. Thanks )))
Reply all
Reply to author
Forward
0 new messages