Exporting facesets out of Maya

2,905 views
Skip to first unread message

rajiv.pe...@thefoundry.co.uk

unread,
Apr 11, 2014, 5:16:04 AM4/11/14
to alembic-d...@googlegroups.com
Hi,
Has anybody been able to export face sets out of Maya? I can't seem to do that, these are the steps I'm taking:

1. Select the faces i want to create a set out of
2. Create->Set
3. Export All Alembic.


I've even tried adding "-wfs" flag to AbcExport in maya (the latter's help page mentions that the flag writes face sets) - still nothing.

I would very much appreciate any thought on this.
Cheers,
R

Hans Baldzuhn

unread,
Apr 11, 2014, 7:01:06 AM4/11/14
to alembic-d...@googlegroups.com
face sets are not taking from any kind of maya set.

Basically it loops through the shading assignment on the object an gets the assigned face. This is what they call "face set".
So you will have data written if your mesh has face-assigned shaders.

When you reimport your alembic, if the shaders are still inside your scene, shaders are reapplied to the faces.

Best
Hans

Michael Root

unread,
Apr 17, 2014, 9:09:33 PM4/17/14
to alembic-d...@googlegroups.com

If my understanding is correct, AbcExport names the faceset the same as the name of the Maya shadingEngine node to which those faces is assigned:

        std::string faceSetName(connSgObjName.asChar());

Since shadingEngine nodes are not DAG nodes, they have no path. This means that they share a single namespace that's common to all objects in that namespace.  It also means that Maya will be pretty commonly renaming them for you when importing objects with materials when those materials already exist in the scene.

We use faceset locations pretty heavily in Katana, both for texture assignment, and for other things like setting visibility, prman attributes, etc.  Unstable faceset names will be a problem.

Has anyone encountered this problem and worked around it?

Would having AbcExport look for an attribute on the shadingEngine node (eg. "ABC_facesetName") be appropriate?

I'm trying to avoid solving it with elaborate gymnastics on the Katana side (which we can do, and for the moment, are doing), as it really isn't a Katana problem.

Cheers,
-Mike
--
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.

99a...@gmail.com

unread,
Apr 25, 2014, 10:59:35 AM4/25/14
to alembic-d...@googlegroups.com
Hey, I think I know what you are after.

Digging through their sourcecode I found that adding intArray attributes named FACESET_... containing the faceIDs to the shape will be exported as facesets in the abc file. MEL is awful when it comes to face selections so I used the API. There is another bug in the prman procedural that writes garbage in the rib. If you are using that, let me know.

This might only work on subdivs, so make sure you have the boolean 'SubDivisionMesh' attribute on the shape as well. Facesets are automatically named FACESET_0, _1, _2 ...

import maya.cmds as cmds
import maya.OpenMaya as om
# if multiple shaders are assigned to different sets of faces,
# create FACESET_ int array attributes for them (FACESET is recognized by alembic import/procedural)
# python/MEL sucks at face selections, so using the API

shp = 'yourPolyshape'

selList = om.MSelectionList()
selList.add(shp)
path = om.MDagPath()
selList.getDagPath(0, path)

fnMesh = om.MFnMesh(path)
shaders = om.MObjectArray()
faces = om.MIntArray()
fnMesh.getConnectedShaders(0, shaders, faces)
if shaders.length() > 1:
    faceIDs = [[] for x in xrange(shaders.length())]
    for i in range(faces.length()):
        faceIDs[faces[i]].append(i)
    for i in range(shaders.length()):
        attr = 'FACESET_' + str(i)
        if not cmds.attributeQuery(attr, node=shp, ex=True):
            cmds.addAttr(shp, dt='Int32Array', ln=attr)
        attr = shp + "." + attr
        cmds.setAttr(attr, faceIDs[i], type='Int32Array')

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

Michael Root

unread,
Apr 25, 2014, 2:04:59 PM4/25/14
to alembic-d...@googlegroups.com

Thanks, that is the functionality I'm after....but it doesn't work in Maya 2014 or 2015 and doesn't appear in the Alembic source code anywhere I can see.  Are you sure you're not looking at a locally modified copy?

Sure, if I add '-attrPrefix FACESET_' to the export, I get them as arbitrary data, but it would be nicer to have them be 'real' facesets that don't require munging on import.

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

Lucas Miller

unread,
Apr 25, 2014, 2:23:30 PM4/25/14
to alembic-d...@googlegroups.com
Reviewing the NEWS.txt the attr FACESET_ support was changed to Maya facesets in Alembic 1.1.2 (2012-10-17)

Lucas

Michael Root

unread,
Apr 25, 2014, 2:23:51 PM4/25/14
to alembic-d...@googlegroups.com

Correction!  Alembic used to have this behavoir.  Looks like it was changed in 1.1.2: http://goo.gl/77L9gw

Alembic maintainers: can we have this feature back?

-Mike

On 04/25/2014 07:59 AM, 99a...@gmail.com wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to alembic-discuss...@googlegroups.com.

Lucas Miller

unread,
Apr 25, 2014, 2:32:55 PM4/25/14
to alembic-d...@googlegroups.com
A question for any Autodesk lurkers:

What is the stablest way to represent facesets in Maya?

A custom int array as was previously done isn't ideal, but apparently the way it is represented now has some unfortunate side effects as the facesets may be renamed during common Maya workflows.

Lucas

99a...@gmail.com

unread,
Apr 25, 2014, 2:49:43 PM4/25/14
to alembic-d...@googlegroups.com
Ah, you are right, we are based on older code, so FACESET still works.
For me this works fine, it does just what it should and is easy enough to handle. Same as primvars really.
I have not looked at the current implementation so I cannot really say which one is better.
To unsubscribe from this group and stop receiving emails from it, send an email to alembic-discussion+unsubscribe@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.
For more options, visit https://groups.google.com/d/optout.

Rajiv Perseedoss

unread,
Apr 28, 2014, 5:29:30 AM4/28/14
to alembic-d...@googlegroups.com
Hi all,
Thanks for the replies.

I'm with Michael, the "FACESET attribute method" writes out arbitrary data but it would be better and lot simpler for to get actual "Faceset" objects out.

According to NEWS.TXT, the maya alembic exporting code indeed changed from the attribute method to "Facesets now get imported as Maya facesets instead of an integer array attribute" in 1.1.2, so that implies that the Maya exporter needs to be atleast 1.1.2 for it to export out Facesets.Maya 2014 SP1 release notes mentions "MAYA-25124: Maya now uses Alembic version 1.1.5" and I'm on Maya 2014 SP2. It all seems to point down to the issue being with the AbcExporter then?

R



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

Michael Root

unread,
Apr 28, 2014, 12:09:18 PM4/28/14
to alembic-d...@googlegroups.com

I can see reasonable arguments for doing it either way.  If you happen to be at a studio that doesn't have the R&D resources to maintain your own faceset tools, using Maya's per-face material assignments might make sense.  But, if you happen to be at a bigger place, wrestling with Maya's material assignments is more of a handicap than a help, so using int array attributes makes more sense.

Why not use the attributes if present, and fall back to material assignments if not?

-Mike
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.
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.
For more options, visit https://groups.google.com/d/optout.

Rajiv Perseedoss

unread,
Apr 28, 2014, 12:15:24 PM4/28/14
to alembic-d...@googlegroups.com
Using Alembic's "faceset" object implies that I need not worry where it comes from or which modelling package exported the archive out - as long as i got an alembic archive with faceset objects in it, i can safely assume they are facesets and load them in a uniform way. This is not the case with the arbitrary int attribute method.

What i am worried about, more than anything, is how come faceset objects are not being written out even though maya 2014 uses alembic 1.1.5.

R

Michael Root

unread,
Apr 28, 2014, 12:29:58 PM4/28/14
to alembic-d...@googlegroups.com

On 04/28/2014 09:15 AM, Rajiv Perseedoss wrote:
Using Alembic's "faceset" object implies that I need not worry where it comes from or which modelling package exported the archive out - as long as i got an alembic archive with faceset objects in it, i can safely assume they are facesets and load them in a uniform way. This is not the case with the arbitrary int attribute method.

It would be the case if AbcExport looks for those attributes and writes them as explicit Alembic facesets (as it did pre-1.1.2).



What i am worried about, more than anything, is how come faceset objects are not being written out even though maya 2014 uses alembic 1.1.5.

They are.  IF you have a subd object with multiple materials assigned to it, AND you specify the -exportFaceSets option to AbcExport.  Conveniently, Autodesk neglected to provide a GUI checkbox for this in the export options in Maya 2014.  It is there in 2015.

-Mike

Rajiv Perseedoss

unread,
Apr 29, 2014, 10:33:09 AM4/29/14
to alembic-d...@googlegroups.com
Hi Michael,
1. Hopefully they do bring that back in future alembic versions then.
2. It doesnt work for me - i am using the -wfs flag but in vain.

However, I tried doing this (setting materials on faces) in Modo, exported that to Alembic and my abcecho reveals some lovely facesets - such a breeze in less than 10 seconds.
I'm not gonna struggle with Maya anymore, Modo ftw.

Thanks all for your help,
R


99a...@gmail.com

unread,
Apr 29, 2014, 4:18:25 PM4/29/14
to alembic-d...@googlegroups.com
Hi Rajiv,

looking at Mikes post, are you sure you are exporting a subdiv and not a poly? Facesets only work with subdivs, so you need to have a boolean attribute called "SubDivisionMesh" on the polygon shape in Maya. With AbcEcho you can see if the schema is AbcGeom_polyMesh or AbcGeom_SubD. Works for me. Alembic 1.5 compiled against Maya 2013.5.

maybe not all is lost for Maya :)

In view of that, even though I brought it up, I would not opt bringing the FACESET attribute back, its much more hassle to add the 'primvars' as in my code sample than just using the flag.

Best
Alf



R


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.

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.

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.

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.

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.

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.

Michael Root

unread,
Apr 29, 2014, 4:47:43 PM4/29/14
to alembic-d...@googlegroups.com
On 04/29/2014 01:18 PM, 99a...@gmail.com wrote:
> In view of that, even though I brought it up, I would not opt bringing the
> FACESET attribute back, its much more hassle to add the 'primvars' as in my
> code sample than just using the flag.

Yes, but what about when Maya automatically renames all your facesets out from
under you?

-Mike


Rajiv Perseedoss

unread,
Apr 30, 2014, 5:12:51 AM4/30/14
to alembic-d...@googlegroups.com
Hi 99Alfie,
You were spot on. I got it working by adding the attr "SubDivisionMesh"=1 on my object (it doenst need to be a subdiv, i added this on my poly mesh and that exports the face sets fine with the my cube being still an AbcGeom_PolyMesh_v1) and then adding -wfs flag to the AbcExport command.

Thanks all, even though the renaming happens, atleast i am getting some facesets out of Maya!

R


99a...@gmail.com

unread,
Apr 30, 2014, 2:59:24 PM4/30/14
to alembic-d...@googlegroups.com
Hi Mike,

I see your point, tools may not always use assigned maya materials for facesets. Also, for backcompatibility's sake it should be put back while possibly keeping the flag as it is now.

The question with that is probably how the importer is supposed to treat them as you probably do not want to have two "types" of faceset. With the FACESET approach, the importer would just add the same int array to the shape, with the new one it recreates the shaders, so how do you treat a "mix" of both?

From a production viewpoint it is probably better the way it was before. In the least cases you want to care about the shader assignment when it comes to geometry caching, the shader is just incidental and there are normally other tools that take care of shader assignment etc. While it is a good idea to have it the way it is now, the main priority is to have the faceIDs in the abc file as a faceset, the material assignment is of secondary or even minor importance here. So if there is no way to combine the two, I would rather opt to fall back to the original FACESETs.

Best
Alf

Michael Root

unread,
May 14, 2014, 2:05:22 PM5/14/14
to alembic-d...@googlegroups.com

It's been a couple of weeks, and this thread seems to have petered out.  Here's my suggested solution:

1. AbcExport's -writeFaceSets flag continues to work as-is: Find facesets based on material assignments.  If specified:
        a) AbcExport looks for a string attribute, "AbcFacesetName" on the shadingEngine (aka shadingGroup) node and, if present, names the faceset that. 
        b) If no attribute is present, it uses the shadingEngine node name (the current behavior).

3. AbcImport:
        a) If it has to create a new shadingGroup to represent an IFaceset, also create the AbcFacesetName attribute and set it.
        b) If the shadingGroup node already exists and does not have the AbcFacesetName attribute, create that attribute and set it.
        c) If the shadingGroup node already exists and does have the AbcFacesetName attribute, set it.

This preserves existing behavior, allows interested parties to have stable faceset names if they need/want them, and keeps all the Maya weirdness where it belongs--in Maya.

I'd be happy to submit a patch that implements this if it would be helpful.

Thoughts?

-Mike



On 04/28/2014 09:09 AM, Michael Root wrote:

Lucas Miller

unread,
May 14, 2014, 2:10:05 PM5/14/14
to alembic-d...@googlegroups.com
This seems like a reasonable solution.

A patch would be greatly appreciated.

Lucas


Michael Root

unread,
May 14, 2014, 3:29:32 PM5/14/14
to alembic-d...@googlegroups.com

Patch attached.

Only potential gotcha I can see is that if people want to rename a faceset by renaming the corresponding shadingGroup node, they'll have to check to see if there's an AbcFacesetName attribute on it and either change that also or delete the attribute.  Not sure how common this is, or how it could be avoided without moving the mess into some other dark corner.

Cheers,
-Mike
maya_facesets.patch

Daniel Rolinek

unread,
Aug 19, 2014, 1:40:22 PM8/19/14
to alembic-d...@googlegroups.com
So there's an additional issue regarding shading groups and facesets. 

If a shading group is assigned by face to any object,  then every object to which it is assigned gets a faceset.  When the shading group assignment is object-based,  that faceset is often ill-defined.  The worst offender in our exports is maya's initialShadingGroup.   This causes crashes in downstream third-party applications.

We're planning on submitting a patch that would distinguish between assignment types.  We're also thinking of adding an option so that only shading groups which have the name attribute set are exported.  Any thoughts as to the form of that? 

These seem like simple changes but are disruptive if the goal is a trip from maya to alembic and back again. 

Dan
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