Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

extracting curves from polyObjects with python

extracting curves from polyObjects with python

danispag
Enthusiast Enthusiast
1,579 Views
2 Replies
Message 1 of 3

extracting curves from polyObjects with python

danispag
Enthusiast
Enthusiast

Hi I'm trying to extract curves from a cube. The code below works fine. I'm fairly new to python and I was wondering if there is a better/cleaner solution to approach this.

 

Thanks

 

--- Image Attached ---


tempObj = cmds.polyCube()
edges = tempObj[0] + ".e[*]"
cmds.select(edges)

cmds.duplicateCurve(tempObj[0] + ".e[0]", rn=0, ch=1, local=0)
cmds.duplicateCurve(tempObj[0] + ".e[1]", rn=0, ch=1, local=0)
cmds.duplicateCurve(tempObj[0] + ".e[2]", rn=0, ch=1, local=0)
cmds.duplicateCurve(tempObj[0] + ".e[3]", rn=0, ch=1, local=0)
cmds.duplicateCurve(tempObj[0] + ".e[4]", rn=0, ch=1, local=0)
cmds.duplicateCurve(tempObj[0] + ".e[5]", rn=0, ch=1, local=0)
cmds.duplicateCurve(tempObj[0] + ".e[6]", rn=0, ch=1, local=0)
cmds.duplicateCurve(tempObj[0] + ".e[7]", rn=0, ch=1, local=0)
cmds.duplicateCurve(tempObj[0] + ".e[8]", rn=0, ch=1, local=0)
cmds.duplicateCurve(tempObj[0] + ".e[9]", rn=0, ch=1, local=0)
cmds.duplicateCurve(tempObj[0] + ".e[10]", rn=0, ch=1, local=0)
cmds.duplicateCurve(tempObj[0] + ".e[11]", rn=0, ch=1, local=0)

cmds.delete(tempObj)

cmds.select('duplicatedCurveShape2', 'duplicatedCurveShape3', 'duplicatedCurveShape4', 'duplicatedCurveShape5', 'duplicatedCurveShape6', 'duplicatedCurveShape7', 'duplicatedCurveShape8', 'duplicatedCurveShape9', 'duplicatedCurveShape10', 'duplicatedCurveShape11', 'duplicatedCurveShape12', 'duplicatedCurve1')

 

cmds.parent(relative=True, shape=True)

0 Likes
Accepted solutions (1)
1,580 Views
2 Replies
Replies (2)
Message 2 of 3

rajasekaransurjen
Collaborator
Collaborator
Accepted solution

Hi,

You can create a cube using the following...

cmds.curve( p =[(-0.5, 0.5, -0.5), (-0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (0.5, 0.5, -0.5), (-0.5, 0.5, -0.5), (-0.5, -0.5, -0.5), (0.5, -0.5, -0.5), (0.5, 0.5, -0.5), (0.5, 0.5, 0.5), (0.5, -0.5, 0.5), (0.5, -0.5, -0.5), (-0.5, -0.5, -0.5), (-0.5, -0.5, 0.5), (0.5, -0.5, 0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, 0.5), (-0.5, -0.5, 0.5)],per = False, d=1, k=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])
0 Likes
Message 3 of 3

danispag
Enthusiast
Enthusiast

Thanks 🙂