Error in extracting edge to curve from plane

Error in extracting edge to curve from plane

niuxihuanming
Participant Participant
166 Views
0 Replies
Message 1 of 1

Error in extracting edge to curve from plane

niuxihuanming
Participant
Participant

Hi, this is a script for converting edges into curves from the U/V direction of a polygon plane. Now, after being converted into curves, the edge curves will bend, and the points of each curve do not match the vertices of the polygon edges. How should we solve this problem?b19d3dedf5b4c3bb7025266634ba7ba.png

import maya.cmds as cmds

def xgtCurveTubeExtract():
    extractFrom = cmds.radioCollection('radioCol_source', query=True, sl=True)
    flipDirection = cmds.checkBox('flipDirection', query=True, value=True)
    hideTubes = cmds.checkBox('hideTubes', query=True, value=True)
    extractedList = []
    nurbShapeList = []
    selGeos = cmds.ls(selection=True)
    to_remove = []
    for i in selGeos:
        polyToSubD = cmds.polyToSubdiv(i, ap=0, ch=0, aut=0, maxPolyCount=30000, maxEdgesPerVert=32)
        subDtoNurb = cmds.subdToNurbs(polyToSubD, ch=0, aut=1, ot=0)
        nurbShapeList.append(cmds.listRelatives(subDtoNurb)[0])
        to_remove.append(polyToSubD)
        nurbsUDirList = []
        nurbsVDirList = []

    for i in nurbShapeList:
        if cmds.getAttr(i + '.fu') == 0:
            nurbsUDirList.append(i)
        else:
            nurbsVDirList.append(i)
        if flipDirection == False:
            if i in nurbsUDirList:
                dirValue = 'v'
            if i in nurbsVDirList:
                dirValue = 'u'
        elif i in nurbsUDirList:
            dirValue = 'u'
        else:
            if i in nurbsVDirList:
                dirValue = 'v'
  ########                              
        if extractFrom == 'geoTopo':
            if flipDirection == False:
                if i in nurbsVDirList:
                    geoSpan = cmds.getAttr(i + '.spansU')
                else:
                    geoSpan = cmds.getAttr(i + '.spansV')
                for span in range(geoSpan)[0::2]:
                    crvStr = i + '.' + dirValue + '[' + str(span) + ']'
                    extractedCrv = cmds.duplicateCurve(crvStr)
                    extractedList.append(extractedCrv[0])

            else:
                if i in nurbsVDirList:
                    geoSpan = cmds.getAttr(i + '.spansV')
                else:
                    geoSpan = cmds.getAttr(i + '.spansU')
                for span in range(geoSpan)[0::2]:
                    crvStr = i + '.' + dirValue + '[' + str(span) + ']'
                    extractedCrv = cmds.duplicateCurve(crvStr)
                    extractedList.append(extractedCrv[0])

    if hideTubes:
        cmds.hide(selGeos)
    for x in to_remove:
        cmds.select(x)
        cmds.delete(x)

    cmds.warning('Curves Extracted')
    cmds.select(extractedList)
####        
cmds.window( title='curve')
cmds.columnLayout()
##                

cmds.radioCollection('radioCol_source')
cmds.radioButton('geoTopo', label='Convert edges to curves')
cmds.checkBox('hideTubes', label='Hidden model', en=True)
cmds.checkBox('flipDirection', label='Flip direction', en=True) 
cmds.button(label='determine', c=(lambda *arg: xgtCurveTubeExtract()), w=100)

cmds.showWindow()  
0 Likes
167 Views
0 Replies
Replies (0)