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]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0Yrf67XYHvLpmPixBA6Ld6YSwwd4bvyYa3XvPM4zm_LQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
