Not entirely related to the question but just giving a heads up to ensure 
you won't be pulling out your hairs as you go.

If you're using Maya 2016 and MFnSet in API to list the current members of 
a shadingEngine (shading group) it will also list something like 
"shaderBallGeomShape1" if you looked at the shader in the new Hypershade's 
material viewer in the current session. The "shaderBallGeomShape1" is no 
valid object in the scene. Only the API seems to have this bug and return 
it as an object (maya commands itself doesn't).

Cheers,
Roy

On Monday, November 2, 2015 at 12:45:03 AM UTC+1, Justin Israel wrote:
>
>
>
> On Mon, Nov 2, 2015 at 12:32 PM Rudi Hammad <[email protected] 
> <javascript:>> wrote:
>
>> Thanks guys.
>> hey Marcus, of course I can use cmds.connectAttr() , but that is not my 
>> goal. I want to do it with API, but thanks
>> Justin, I didn´t know about a higher level in API. That definitetly is 
>> makes it easier. thank you. I still dont understand why it didn´t work, but 
>> that´s okey
>>
>
> If you look at what's happening in the Script Editor output, when you add 
> the shape to the shader group, you will see it is actually doing something 
> like this:
>
> instObjGroups[0] => dagSetMembers[0]
>
> When you use the higher level API for adding the member, you don't have to 
> worry about the array attributes. 
>  
>
>> cheers!
>>
>> El lunes, 2 de noviembre de 2015, 0:20:07 (UTC+1), Justin Israel escribió:
>>>
>>>
>>>
>>> On Mon, Nov 2, 2015 at 9:47 AM Marcus Ottosson <[email protected]> 
>>> wrote:
>>>
>>>> Or go even higher.
>>>>
>>>>    - 
>>>>    
>>>> http://help.autodesk.com/cloudhelp/2015/ENU/Maya-Tech-Docs/CommandsPython/connectAttr.html
>>>>
>>>>
>>> Or you can let these guys take you even higher:
>>> https://www.youtube.com/watch?v=J16lInLZRms
>>>  
>>>
>>
>>>>    
>>>> ​
>>>>
>>>> On 1 November 2015 at 20:43, Justin Israel <[email protected]> wrote:
>>>>
>>> Could you try using some of the higher level API calls, instead of 
>>>>> trying to do it more low level, by connecting up explicit plugs?
>>>>>
>>>>> setFn = OpenMaya.MFnSet(mObject_initShdGrp)
>>>>> setFn.addMember(objPolyShape)
>>>>>
>>>>> ​
>>>>> This will end up doing the right thing. I think your probably was that 
>>>>> the plugs are array types and they weren't being connected properly. But 
>>>>> if 
>>>>> you stick to the high level functions, it won't matter.
>>>>>
>>>>
>>>>>
>>>>> On Mon, Nov 2, 2015 at 2:56 AM Rudi Hammad <[email protected]> wrote:
>>>>>
>>>>>> hello
>>>>>> I am new to api and I am starting with something quite simple. Just 
>>>>>> making a cube.
>>>>>> Everything goes ok until I try to give it the default material. A 
>>>>>> problem with the connection between the 
>>>>>> 'polySurfaceShape1.instObjGroups' 
>>>>>> to 'initialShadingGroup.dagSetMembers' 
>>>>>>
>>>>>> here is the code:
>>>>>>
>>>>>>
>>>>>>
>>>>>> import maya.OpenMaya as OpenMaya
>>>>>>
>>>>>> """------ NODOS SUELTOS -----"""
>>>>>> #--[DG NODES]--#
>>>>>> # polyCube
>>>>>> mFnDependencyNode_pCubeHistory = OpenMaya.MFnDependencyNode()
>>>>>> objPolyCube = mFnDependencyNode_pCubeHistory.create("polyCube", 
>>>>>> "myPolyCubeName") #el tipo de nodo existente, designado en ayuda por 
>>>>>> typeId
>>>>>> #--[DAG NODES]--#
>>>>>> # transform
>>>>>> mFnDagNode_pCubeTransform = OpenMaya.MFnDagNode()
>>>>>> objPolyTrans = mFnDagNode_pCubeTransform.create("transform")
>>>>>> # cube shape
>>>>>> mFnDagNode_pCubeShape = OpenMaya.MFnDagNode()
>>>>>> objPolyShape = mFnDagNode_pCubeShape.create("mesh", objPolyTrans)
>>>>>> #--[retrive initialShadingGroup]--#
>>>>>> mSelectionList = OpenMaya.MSelectionList()
>>>>>> mSelectionList.add("initialShadingGroup")
>>>>>> mObject_initShdGrp= OpenMaya.MObject()
>>>>>> mSelectionList.getDependNode(0,mObject_initShdGrp) 
>>>>>> initShadingNode = mObject_initShdGrp.apiTypeStr() 
>>>>>> mFnDependencyNode_initialShadingGroup = OpenMaya.MFnDependencyNode()
>>>>>> mFnDependencyNode_initialShadingGroup.setObject(mObject_initShdGrp) 
>>>>>> name = mFnDependencyNode_initialShadingGroup.name() # Result: 
>>>>>> initialShadingGroup, so it ok so far
>>>>>>
>>>>>>
>>>>>>
>>>>>> """------ CONNECTIONS WITH MDGMODIFIER -----"""
>>>>>> mDgModifier = OpenMaya.MDGModifier()
>>>>>> # polyCube-->shape connections
>>>>>> srcPlug = mFnDependencyNode_pCubeHistory.findPlug("output")
>>>>>> destPlug = mFnDagNode_pCubeShape.findPlug("inMesh")
>>>>>> mDgModifier.connect(srcPlug, destPlug)
>>>>>> # shape-->shader connections
>>>>>> meshOutPutPlug = mFnDagNode_pCubeShape.findPlug("instObjGroups")
>>>>>> initShadingGroupInPutPlug = mFnDependencyNode_initialShadingGroup.
>>>>>> findPlug("dagSetMembers")
>>>>>> mDgModifier.connect(meshOutPutPlug, initShadingGroupInPutPlug)
>>>>>>
>>>>>> mDgModifier.doIt()
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> # Error: Connection not made: 'polySurfaceShape1.instObjGroups' -> 
>>>>>> 'initialShadingGroup.dagSetMembers'.  Source node will not allow the 
>>>>>> connection. # 
>>>>>> # Error: RuntimeError: file 
>>>>>> S:\Maya_2016_DI\build\Release\runTime\Python\Lib\site-packages\maya\OpenMaya.py
>>>>>>  
>>>>>> line 2889: (kFailure): Unexpected Internal Failure # 
>>>>>>
>>>>>> I don´t understand why the connection can´t be made
>>>>>> thanks
>>>>>>
>>>>>> -- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>>> Groups "Python Programming for Autodesk Maya" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>> send an email to [email protected].
>>>>>> To view this discussion on the web visit 
>>>>>> https://groups.google.com/d/msgid/python_inside_maya/eea5784b-e6e8-4b35-bf8a-14e73687720d%40googlegroups.com
>>>>>>  
>>>>>> <https://groups.google.com/d/msgid/python_inside_maya/eea5784b-e6e8-4b35-bf8a-14e73687720d%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google 
>>>>> Groups "Python Programming for Autodesk Maya" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>> an email to [email protected].
>>>>>
>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2NVFQskLmnLAy1mojnxvz3EqWmZaPoo%2BCR2ii8Zb8sfw%40mail.gmail.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2NVFQskLmnLAy1mojnxvz3EqWmZaPoo%2BCR2ii8Zb8sfw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>
>>>>
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>>
>>>> -- 
>>>> *Marcus Ottosson*
>>>> [email protected]
>>>>
>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Python Programming for Autodesk Maya" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBC%2ByKgKieTZ7Rez-%2Bwwazp2-h95mBT__e8oO0E4qU1UQ%40mail.gmail.com
>>>>  
>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBC%2ByKgKieTZ7Rez-%2Bwwazp2-h95mBT__e8oO0E4qU1UQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/98b6daa9-cf57-4e5a-8422-124cc751f3bf%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/98b6daa9-cf57-4e5a-8422-124cc751f3bf%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/1b5a0ad5-c6bd-4e4b-a194-e0b39c896db6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to