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 # setFn = OpenMaya.MFnSet(mObject_initShdGrp)
setFn.addMember(objPolyShape)
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/eea5784b-e6e8-4b35-bf8a-14e73687720d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2NVFQskLmnLAy1mojnxvz3EqWmZaPoo%2BCR2ii8Zb8sfw%40mail.gmail.com.
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.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/eea5784b-e6e8-4b35-bf8a-14e73687720d%40googlegroups.com.
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2NVFQskLmnLAy1mojnxvz3EqWmZaPoo%2BCR2ii8Zb8sfw%40mail.gmail.com.--
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 python_inside_maya+unsub...@googlegroups.com.
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
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/eea5784b-e6e8-4b35-bf8a-14e73687720d%40googlegroups.com.
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2NVFQskLmnLAy1mojnxvz3EqWmZaPoo%2BCR2ii8Zb8sfw%40mail.gmail.com.
--
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 python_inside_m...@googlegroups.com.
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.
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/98b6daa9-cf57-4e5a-8422-124cc751f3bf%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/eea5784b-e6e8-4b35-bf8a-14e73687720d%40googlegroups.com.
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2NVFQskLmnLAy1mojnxvz3EqWmZaPoo%2BCR2ii8Zb8sfw%40mail.gmail.com.
--
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 python_inside_maya+unsub...@googlegroups.com.
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.
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 python_inside_maya+unsub...@googlegroups.com.