I am trying to 'extract and convert' all the edges of the polygon (based on 
selection) into curves, then parent the curves as one. This is like a 
curve-based wireframe model.

While Maya has a functionality that allows all edges to be converted into 
curves, but the functionality - "Polygon Edges to Curves", it works but not 
very ideal in my case as I would want all the created curves to be combined 
into one.

import maya.cmds as cmds
import pymel.core as pm

edges = cmds.filterExpand(cmds.polyListComponentConversion(te=1),sm=32,ex=1)
cur_list = []
for edge in edges:
    vtx = cmds.ls(cmds.polyListComponentConversion(edge,fe=1,tv=1),fl=1)
    p1 = cmds.pointPosition(vtx[0])
    p2 = cmds.pointPosition(vtx[1])
    created_curve = cmds.curve(d=1,p=(p1,p2))
    cur_list.append(created_curve)

# Select all the newly created curves
for cur in cur_list:
    cmds.select(cur, add=True)

# Get list of objects
shape_list = pm.ls(pm.listRelatives(c=True))
grp_list = pm.ls(pm.group(em=True, n='curve#'))
list_all = []
for obj in grp_list:
    list_all.extend(shape_list)
    list_all.extend(grp_list)

# Parent (shape) objects to one Curve
pm.select(list_all)
pm.parent(r=True, s=True)


While this code of mine does work, but if I tried to use it on a higher 
subdivision polygon, for example, create a normal pSphere and sets both its 
"Subdivisions Axis" and "Subdivisions Height" to 100, and execute the code 
I wrote.
What happens here is that:

   - Maya seems to be hanging
   - Took a very long while to be process (seems to be more than 1 hour 
   plus before that current maya session of mine crashes.)
   
What can be done to minimize this long processing time? I am assuming that 
part of this 'long' time is due to the commands that I am using it to 
derive the vertex and creating them?

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/71af008c-fbce-46a8-b150-887888e300bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to