0

I'm trying to get the SurfaceCV indices from a NurbsSurface.

When I use the MItSurfaceCV class I get too few indices.

My Code till now, with a NurbsSphere selected:

sel = om.MSelectionList()
om.MGlobal.getActiveSelectionList(sel, 0)

dg = om.MDagPath()
sel.getDagPath(0, dg)

cvIter = om.MItSurfaceCV(dg)

inds = []
while not cvIter.isDone():

    num1 = om.intPtr()
    num2 = om.intPtr()

    cvIter.getIndex(num1, num2)

    inds.append([num1.value(), num2.value()])

    cvIter.next()

My Output:

[0, 0]
[1, 0]
[2, 0]
[3, 0]
[4, 0]
[5, 0]
[6, 0]

But it should be:

[0,0]
[0,1]
...
[0,7]
[1,0]
[1,1]
...
[1,7]
[2,0]
...
[6,7]

Thanks to anyone looking into it.

FzudemAA
  • 3
  • 4

1 Answers1

0

This seems to work ok when selecting a nurb's cvs:

import maya.OpenMaya as om

sel = om.MSelectionList()
om.MGlobal.getActiveSelectionList(sel, 0)

dg = om.MDagPath()
mComponent = om.MObject()  # Create MObject to contain selected components.
sel.getDagPath(0, dg, mComponent)  # Construct dag path and components.

cvIter = om.MItSurfaceCV(dg, mComponent)  # Include components in constructor.

inds = []

def appendIndexes():
    num1 = om.intPtr()
    num2 = om.intPtr()

    cvIter.getIndex(num1, num2)

    inds.append([num1.value(), num2.value()])

while not cvIter.isDone():
    while not cvIter.isRowDone():
        num1 = om.intPtr()
        num2 = om.intPtr()

        cvIter.getIndex(num1, num2)
        inds.append([num1.value(), num2.value()])

        cvIter.next()
    cvIter.nextRow()

print len(inds)

But for some reason it's iterating over extra out of range indexes when you have the object selected. I'm not too sure why..

Here's an example of it being used. I'm not sure what else I'm missing, but hope that nudges you in the right direction.

Green Cell
  • 4,677
  • 2
  • 18
  • 49
  • Hey, yeah you're right. I also got that overhead of indices. No idea what's going on there. I've also tried `MFnNurbsSurface.numCVsinU` and it's counterpart but there's also an overhead. – FzudemAA Jun 06 '19 at 14:00
  • Interesting enough that it seems to work ok once the nurbs degree is set as linear. – Green Cell Jun 07 '19 at 02:05