Hi Judah,

re: instancing referenced shape nodes...

Here is a short explanation of what's happening, and a couple of
workarounds:

. if you instance a referenced mesh that has per face material assignments,
the instance will lose these material assigments when you reload the
reference IF the referenced object is in a Group, ie: not parented to World.
. you've already noticed that when you instance your mesh, Maya creates a
whole bunch of reference edits. On the face of it, these reference edits are
disconnecting the per-face material assignments to the mesh shape node (yes,
Autodesk is aware of the issue).
. what's actually happening is that the reference edits are disconnecting
the groupID nodes that must be connected to both a shape node and a shading
group for an assignment to happen....the upshot is that your scene fills up
with 'dangling' groupID nodes.
. you can re-assign the material to the instance but you're just creating
more reference edits, and not really addressing the problem.

As I mentioned earlier, the issue has to do with the way you organise the
DAG. If your referenced mesh is in World space when you instance it, then
you won't get the problem. However, if your mesh is Grouped when you
instance it then Maya will break the connections to the groupID nodes and
you'll lose your material assignments.

So you can either:
. leave your meshes in world space, or
. instance the mesh's parent node rather than the mesh object itself. So if
you had your mesh parented to a Group node, you would instance the Group
node.
. add your meshes to a Container (without Transform) - using Containers
means you can organise your meshes in a hierarchical structure - similar to
grouping them - yet allows Maya to instance each mesh without all the cr*p.

Hope that helps,

Owen



On 3 July 2010 08:17, Judah Baron <[email protected]> wrote:

> This question is slightly off topic, but still related.
>
> When a shape from a referenced file is instanced a bunch of groupid nodes
> are created relating to the shading network, and it is possible to assign
> new materials to this instance. I am wondering if there is a way to prevent
> the creation of these groupid nodes and all of the related edits. We have a
> usage case wherein we know that we will never need or want to modify the
> materials of one of these "library" shapes.  We have some cleanup code that
> removes all of these edits, but I would much rather find a more elegant
> solution.
>
>  thanks,
> -Judah
>
>
> On Fri, Jul 2, 2010 at 11:00 PM, John Creson <[email protected]> wrote:
>
>> If you pass in the full name to the shape node from the instance you
>> are wishing to find the shading group of, you will get the correct
>> shader returned.
>>
>> import maya.cmds as cmds
>>
>> shapeNode = 'pSphere2|pSphereShape1'
>> shadingGroup = cmds.listConnections(shapeNode + '.instObjGroups')[0]
>> print shadingGroup
>>
>>
>>
>> On Fri, Jul 2, 2010 at 3:56 PM, Ling <[email protected]> wrote:
>> > Hi guys:
>> >
>> >  Normally when dealing with a non-instanced shape node, it's easy to
>> > get its shading group assighnment like:
>> >
>> >  shadingGroup = cmds.listConnections(shapeNode + '.instObjGroups[0]')
>> > [0]
>> >
>> >
>> >
>> >  but when it comes to instanced the shapde nodes, one shape node
>> > might have several shader assignments.
>> >
>> >  if I do a list connection to the instanced shape node,  all the
>> > shading groups assigned to it will be listed, and don't know which one
>> > is assigned to a particular transform node's children shape node.
>> >
>> >  so how can I query which shader is assign to a given transform node?
>> >
>> >
>> >  many thanks
>> >
>> >
>> >  -ling
>> >
>> > --
>> > http://groups.google.com/group/python_inside_maya
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>>
>
>  --
> http://groups.google.com/group/python_inside_maya
>

-- 
http://groups.google.com/group/python_inside_maya

Reply via email to