I'm updating some of my plugins to function inside of maya 2011 and
I'm running into an issue where maya insta-crashes when running
through certain procedures. The one below is an example of such a
procedure. I have narrowed it down and found that all of the functions
in question use MScriptUtil. I've read over the docs, but don't see
any reason why this would be the case, but I know for certain that
maya crashes when running through this def. Would be most helpful if
someone with more insight could enlighten me as to what I'm missing.
takes an MDagPath for object and MObject for the comps (to a Nurbs
Surface). This should grab neighboring CVs and return a list of names
for each of the CVs.
def _getNeighborsNurbs(path, comps, count=1):
compList = []
pathName=path.fullPathName()
surface = openMaya.MFnNurbsSurface(path)
maxU = surface.numCVsInU()
maxV = surface.numCVsInV()
typeU = surface.formInU()
typeV = surface.formInV()
if typeU == 3:
maxU = maxU - surface.degreeU()
if typeV == 3:
maxV = maxV - surface.degreeV()
compItr = openMaya.MItSurfaceCV(path,comps)
while not compItr.isDone():
u = openMaya.MScriptUtil().asIntPtr()
v = openMaya.MScriptUtil().asIntPtr()
compItr.getIndex(u,v)
compList.append([(pathName + ".cv[%s][%s]")%
(openMaya.MScriptUtil().getInt(u),openMaya.MScriptUtil().getInt(v))])
compItr.next()
for index, object in enumerate(compList[:]):
newComps=object
prevComps=object
for i in xrange(count):
newIndices=[]
tmpPrevComps=[]
tmpPath=openMaya.MDagPath()
tmpComps=openMaya.MObject()
newSelection=openMaya.MSelectionList()
for comps in newComps:
newSelection.add(comps)
newSelection.getDagPath(0,tmpPath,tmpComps)
compItr = openMaya.MItSurfaceCV(tmpPath,tmpComps)
while not compItr.isDone():
tmpIndices = []
u = openMaya.MScriptUtil().asIntPtr()
v = openMaya.MScriptUtil().asIntPtr()
compItr.getIndex(u,v)
tmpIndices.append(openMaya.MScriptUtil().getInt(u))
tmpIndices.append(openMaya.MScriptUtil().getInt(v))
newIndices.append(tmpIndices)
compItr.next()
for objects in newIndices[:]:
if typeU != 1:
tmpIndex=[]
if objects[0] == 0:
tmpIndex.append(maxU-1)
tmpIndex.append(objects[1])
else:
tmpIndex.append(objects[0]-1)
tmpIndex.append(objects[1])
newIndices.append(tmpIndex)
tmpIndex=[]
if objects[0] == (maxU-1):
tmpIndex.append(0)
tmpIndex.append(objects[1])
else:
tmpIndex.append(objects[0]+1)
tmpIndex.append(objects[1])
newIndices.append(tmpIndex)
tmpIndex=[]
else:
tmpIndex = []
if objects[0] != 0:
tmpIndex.append(objects[0] - 1)
tmpIndex.append(objects[1])
else:
tmpIndex.append(objects[0])
tmpIndex.append(objects[1])
newIndices.append(tmpIndex)
tmpIndex = []
if objects[0] < (maxU - 1):
tmpIndex.append(objects[0] + 1)
tmpIndex.append(objects[1])
else:
tmpIndex.append(objects[0])
tmpIndex.append(objects[1])
newIndices.append(tmpIndex)
tmpIndex=[]
if typeV != 1:
tmpIndex = []
if objects[1] == 0:
tmpIndex.append(objects[0])
tmpIndex.append(maxV-1)
else:
tmpIndex.append(objects[0])
tmpIndex.append(objects[1] - 1)
newIndices.append(tmpIndex)
tmpIndex = []
if objects[1] == (maxV - 1):
tmpIndex.append(objects[0])
tmpIndex.append(0)
else:
tmpIndex.append(objects[0])
tmpIndex.append(objects[1] + 1)
newIndices.append(tmpIndex)
else:
tmpIndex = []
if objects[0] != 0:
tmpIndex.append(objects[0])
tmpIndex.append(objects[1] - 1)
else:
tmpIndex.append(objects[0])
tmpIndex.append(objects[1])
newIndices.append(tmpIndex)
tmpIndex = []
if objects[0] < (maxV - 1):
tmpIndex.append(objects[0])
tmpIndex.append(objects[1] + 1)
else:
tmpIndex.append(objects[0])
tmpIndex.append(objects[1])
newIndices.append(tmpIndex)
tmpIndices=[]
for indices in newIndices:
comp=(pathName + ".cv[%s][%s]"%
(indices[0],indices[1]))
tmpIndices.append(comp)
tmpPrevComps.append(comp)
prevComps=set(prevComps)
tmpIndices=list((set(tmpIndices).difference(prevComps)))
prevComps=list(prevComps)
for objects in tmpPrevComps:
prevComps.append(objects)
compList[index].append(tmpIndices)
newComps=tmpIndices
return compList
--
http://groups.google.com/group/python_inside_maya