【问题标题】:MItSurfaceCV, how to get Indices?MITSurfaceCV,如何获取索引?
【发布时间】:2019-06-04 18:07:03
【问题描述】:

我正在尝试从 NurbsSurface 获取 SurfaceCV 索引。

当我使用 MItSurfaceCV 类时,我得到的索引太少了。

到目前为止,我的代码已选择 NurbsSphere:

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()

我的输出:

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

但应该是:

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

感谢任何研究它的人。

【问题讨论】:

    标签: python maya pymel maya-api


    【解决方案1】:

    在选择 nurb 的 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)
    

    但由于某种原因,当您选择对象时,它会遍历额外的超出范围的索引。我不太清楚为什么..

    Here's an example of it being used。我不确定我还缺少什么,但希望能将您推向正确的方向。

    【讨论】:

    • 嘿,是的,你是对的。我也得到了索引的开销。不知道那里发生了什么。我也试过MFnNurbsSurface.numCVsinU,它是对应的,但也有开销。
    • 很有趣,一旦 nurbs 度数设置为线性,它似乎可以正常工作。
    猜你喜欢
    • 2014-06-06
    • 1970-01-01
    • 1970-01-01
    • 2018-11-18
    • 2021-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-08
    相关资源
    最近更新 更多