Hi Sam,
How are you getting the list of vertices in the first place? If you are
selecting points, see my 3rd example.
1. You can also use list comprehension to shorten this a bit more.
vertexList = [330, 136, 58]
postList = [cmds.pointPosition('pSphere1.vtx[%s]'%x) for x in vertexList]
cmds.curve(n='curve1', d=1, p=postList)
2. And I personally prefer .format() instead of %s string formatting. To me
it is a bit easier to read.
vertexList = [330, 136, 58]
postList = [cmds.pointPosition('pSphere1.vtx[{0}]'.format(x)) for x in
vertexList]
cmds.curve(n='curve1', d=1, p=postList)
3. If you are *selecting* your points to get them, you can do something
like this:
selPoints = cmds.ls(sl=True, flatten=True) *# flatten returns each vertex
separately, instead of in ranges like pSphere1.vtx[127:130]*
postList = [cmds.pointPosition(x) for x in selPoints]
cmds.curve(n='curve1', d=1, p=postList)
On Wed, Mar 4, 2015 at 2:57 AM, Kurian O.S <[email protected]> wrote:
> What about this ?
>
> vertexList = [330, 136, 58]
> postList = []
> for eachVer in vertexList:
> postList.append(cmds.pointPosition('pSphere1.vtx[%s]' % eachVer))
> cmds.curve(n='curve1', d=1, p=postList)
>
> On Tue, Mar 3, 2015 at 5:50 PM, <[email protected]> wrote:
>
>> Yo,
>>
>> if you want to create a curve from a set of points that already exist. eg
>> you want to create a curve from points on a mesh. Is this the cleanest way
>> to do it?:
>>
>> Pnt1=cmds.pointPosition('geo.vtx[330]')
>> Pnt2=cmds.pointPosition('geo.vtx[136]')
>> Pnt3=cmds.pointPosition('geo.vtx[58]')
>>
>> cmds.curve(n='curve1', d=1, p=[Pnt1,Pnt2,Pnt3])
>>
>> or is it possible to just enter the 'geo.vtx[330]' items into the curve
>> command somehow? - basically im trying to shrink my script because i have
>> a hell load of curves in my scene now.
>>
>>
>> thanks alot,
>> Sam
>>
>> --
>> 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/91ebea63-0f77-4879-a3ed-4101ed6f2fb1%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> --:: Kurian ::--
>
> --
> 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/CANEMyhPHKqoctgiMSp2FKFG%3DiiP%2BN-50ydxgT4YG_1MZXrPTDA%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CANEMyhPHKqoctgiMSp2FKFG%3DiiP%2BN-50ydxgT4YG_1MZXrPTDA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
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/CAHUba0LDMb5v4mFSgHSTKusyspaO7EnS-RN06178osJQC6CaSw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.