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

Reply via email to