Modify uv map of shapes in Alembic file

696 views
Skip to first unread message

Jojan PM

unread,
Aug 31, 2016, 7:43:44 AM8/31/16
to alembic-discussion
How to modify the uv map of each shape in an Alembic scene of an asset? Is it possible using Alembic Python API, without opening the scene file in any software like Maya/Houdini? If any answer, can you show a sample code too?

Thanks
Joj

Jojan PM

unread,
Aug 31, 2016, 8:23:01 AM8/31/16
to alembic-discussion
Missed few points:
Basically I need to edit the uv map of shapes contained in an alembic file of a model. The uv info is stored as the results of getUVs() and getAssignedUVs() 
by PyMel in Maya, and now I need to inject this modified uv info into the asset saved in .abc format. Note that I don't want to open any software like Maya for this
- The modification should happen by any code.

Jojan PM

unread,
Sep 1, 2016, 10:33:07 AM9/1/16
to alembic-discussion
Basically I am trying code like this:


input_file = 'C:/Users/J/Desktop/Works/cube.abc'
output_file = 'C:/Users/J/Desktop/Works/cube_2.abc'

a = cask.Archive(input_file)
meshObj = cask.find(a.top, "pCubeShape1")[0]

uvsamp = OV2fGeomParamSample(uvs, kFacevaryingScope)
nsamp = ON3fGeomParamSample(normals, kFacevaryingScope)
sample = OPolyMeshSchemaSample(verts, indices, counts, uvsamp, nsamp)
meshObj.set_sample(sample)

# write new archive to disk
a.write_to_file(output_file)


Used cask.py and imitated testCask.py and meshData.py modules got from here:  https://github.com/alembic/cask

But getting this error on the last line, i.e. when saving the file:

Error setting sample on pCubeShape1: <alembic.AbcGeom.OPolyMeshSchemaSample object at 0x000000001C367F48>
'OObject' object has no attribute 'getSchema'

Any help?
Also need to know how to read the existing values for verts, indices, counts and nsamp from meshObj and then assign it to the same mesh, since I have to edit only uv here  :-)  Or else any way to modify only the uv specifically?

Jojan PM

unread,
Sep 4, 2016, 5:49:12 AM9/4/16
to alembic-discussion
Tried these to modify uv by and then saved into different file, but nothing is shown when imported the new alembic file in maya 2016. Any help?

input_1 = 'C:/Users/J/Desktop/Works/cube.abc'
input_2 = 'C:/Users/J/Desktop/Works/cube_2.abc'
output_file = 'C:/Users/J/Desktop/Works/cube_3.abc'

a = cask.Archive(input_1)
b = cask.Archive(input_2)
meshObj = b.top.children["pCube1/pCubeShape1"]
uv_props = meshObj.properties['.geom/uv'].properties

# Method 1:
a.top.children["pCube1/pCubeShape1"].properties['.geom/uv/.indices'].set_value(uv_props['.indices'], index=0)
a.top.children["pCube1/pCubeShape1"].properties['.geom/uv/.vals'].set_value(uv_props['.vals'], index=0)
a.write_to_file(output_file)
--  Getting this error when running it:
# Error: UnknownPropertyType: file D:\Program Files\Autodesk\Maya2016\Python\lib\site-packages\cask.py line 319: Unknown property class for .indices #

# Method 2:
a.top.children["pCube1/pCubeShape1"].properties['.geom'].properties['uv'] = meshObj.properties['.geom/uv']
a.write_to_file(output_file)
# NO error in this case but showing nothing while imported in maya.

Please help.
Thanks!

Jojan PM

unread,
Sep 7, 2016, 7:37:01 AM9/7/16
to alembic-discussion
It worked when ran the same code in maya 2016 in Linux in office. I was trying it in maya 2016 in windows 7 at home. Don't know why it doesn't work at home. Anyway leave it.

Ryan Galloway

unread,
Sep 7, 2016, 12:13:39 PM9/7/16
to alembic-d...@googlegroups.com

Hi Jojan,

Thanks for the report, and apologies for not responding sooner. I'll try to find some time to dig into this and will report back if I find anything. In the meantime, glad you found something that's working for you.

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-discussion+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rita.ga...@gmail.com

unread,
Apr 8, 2018, 11:00:06 PM4/8/18
to alembic-discussion
Was there a solution to this issue? I am also experiencing when using cask in Alembic version 1.7.2

Thanks!

Joj

unread,
Apr 9, 2018, 2:27:20 PM4/9/18
to alembic-d...@googlegroups.com
Sorry, I changed the company and now working in different things. I think the code in my last post was the final solution.

Jojan


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 a topic in the Google Groups "alembic-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/alembic-discussion/ddwX7lwpwec/unsubscribe.
To unsubscribe from this group and all its topics, send an email to alembic-discuss...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages