-------- Original Message --------
Subject: [Maya-Python] Re: grabbing skin cluster. API
From: "bha...@irrigger.com" <i.r.r...@gmail.com>
Date: Thu, October 08, 2009 1:02 pm
To: python_inside_maya <python_in...@googlegroups.com>
import maya.OpenMaya as OpenMaya
import maya.cmds as cmds
import maya.OpenMayaAnim as OpenMayaAnim
"""--------------------------------------------------------------------"""
#still don't know exactly how to take the selection into account with
API.
sel = cmds.ls(sl=True)
#declare variables as types
node = om.MObject()
selectionList = om.MSelectionList()
selectionList.add(sel[0])
selectionList.getDependNode(0,node)
# oMesh is MObject to your mesh
try:
itDG = OpenMaya.MItDependencyGraph(node,
OpenMaya.MFn.kSkinClusterFilter,
OpenMaya.MItDependencyGraph.kUpstream)
while not itDG.isDone():
oCurrentItem = itDG.currentItem()
fnSkin = OpenMayaAnim.MFnSkinCluster(oCurrentItem)
# Don't need to loop any more since we got the skin cluster
break
except:
print "no Cluster"
# No skin cluster
pass
Now this always prints "no Cluster" even if I have a skinned mesh
selected. I'm thinking that how I am getting a hold of the mesh object
is the problem, but I'm still shaky on how to get that information.
i'm trying to get the Bounding box of a prexisting mesh. but i'm not
sure if i'm aproching it the right way. has anyone dont this before? i
see some samples of setting a BBox but none for setting.
i'm new to api so i could be doing the wrong thing here eaither way it
doesnt work. any help would be great. i need to call this so i can plug
height, width, depth into another function.
cheers
john
################
import maya.OpenMaya as OpenMaya
def boundingBox():
selection = OpenMaya.MSelectionList()
OpenMaya.MGlobal.getActiveSelectionList( selection )
dagPath = OpenMaya.MDagPath()
mObj = OpenMaya.MObject()
Bbox=OpenMaya.MBoundingBox(mObj)
print Bbox.width()
print Bbox.height()
boundingBox()
#####################