Ya, that definitely wasn't what I had thought you were asking. It appeared
like your problem was just the selection/sorting. But I see now that it is
a completely different question.


On Mon, Nov 3, 2014 at 11:04 PM, likage <[email protected]> wrote:

> Probably I should rephrase..
> Maybe selection order isn't even the case and come to think of it, my
> images may also be somewhat misleading... I apologize in advance
>
> what I am trying to achieve, its something more like the second post in
> this link
> <http://stackoverflow.com/questions/14263284/create-non-intersecting-polygon-passing-through-all-given-points>
>
>
>
>
> On Monday, November 3, 2014 3:54:17 PM UTC+8, Justin Israel wrote:
>>
>> Did you try my exact example, selecting the locators in the correct
>> order? If you are box selecting them, then you are probably still getting
>> 1,2,3,4 which is causing the twist.
>>
>> On Mon, 3 Nov 2014 8:40 PM likage <[email protected]> wrote:
>>
>>> Can't remember the reason i added in sorted, but it was probably to make
>>> the hierarchy looks nice?
>>> Even so, I am still getting the twisted effect.
>>>
>>>
>>>
>>>
>>> On Monday, November 3, 2014 12:59:41 PM UTC+8, Justin Israel wrote:
>>>
>>>> The way I interpret your code is that even though you start out by
>>>> basing it on the selection order, you then sort the locators. According to
>>>> the layout of your locators in your images, this explains the twisted
>>>> effect, since it crosses diagonally from loc2 to loc3. If you do want to
>>>> control the order by the selection, then you wouldn’t want to sort it, and
>>>> instead preserve the selection order:
>>>>
>>>> locs = cmds.filterExpand(selectionMask=22, fp=True)if not locs:
>>>>     cmds.warning( "Please select a locator / No locators in selection " )
>>>>
>>>> sel = cmds.listRelatives(locs, parent=True)
>>>> points = [cmds.xform(t, q=True, ws=True, piv=True)[:3] for t in sel]
>>>> cmds.polyCreateFacet(p=points)
>>>>
>>>>
>>>> On Mon, Nov 3, 2014 at 4:02 PM, likage <[email protected]> wrote:
>>>>
>>>>> I am trying to create a triangulation (not sure if this is the right
>>>>> word) script? Basically what I am trying to achieve is create a polygon 
>>>>> out
>>>>> of the selection of the locators (it must be 3 or more locators)
>>>>>
>>>>> While I am able to do so, I am having this order of selection problem.
>>>>> Eg. In my scene, there are 4 locators - loc1, loc2, loc3, loc4
>>>>>
>>>>> If I drag select from the loc1 upwards to loc4, instead of creating
>>>>> the polygon like in img01
>>>>> <http://i378.photobucket.com/albums/oo226/melvados/img01.png>, it is
>>>>> created as shown in img02
>>>>> <http://i378.photobucket.com/albums/oo226/melvados/img02.png> ordered
>>>>> by the locator numbering sort of? Seems to me, it is sorting the selection
>>>>> based on its locator creation order, in which this is not what I am trying
>>>>> to do it
>>>>>
>>>>> Am I missing something?
>>>>>
>>>>> import maya.cmds as cmds
>>>>>
>>>>> pts = []
>>>>>
>>>>> cmds.select( cmds.listRelatives( type = 'locator', fullPath = True,
>>>>> allDescendents = True ) )
>>>>> cmds.select( cmds.listRelatives( parent = True, fullPath = True ) )
>>>>> sel = cmds.ls ( selection = True, type = 'transform' )
>>>>>
>>>>> if not sel:
>>>>>     cmds.warning( "Please select a locator / No locators in selection
>>>>> " )
>>>>>
>>>>>
>>>>> for loc in sorted(sel):
>>>>>     coords = cmds.xform (loc, query=True, worldSpace=True, pivots=True
>>>>> )[0:3]
>>>>>     print coords
>>>>>     pts.append(coords)
>>>>>
>>>>> cmds.polyCreateFacet(p = pts)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>  --
>>>>> 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/a80a98ca-d3be-4e29-8bfd-caca5b0b15fc%
>>>>> 40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/python_inside_maya/a80a98ca-d3be-4e29-8bfd-caca5b0b15fc%40googlegroups.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/c9a66f18-d471-49c2-b945-
>>> f6ab31e72659%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/c9a66f18-d471-49c2-b945-f6ab31e72659%40googlegroups.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/c8a21f7b-13be-46aa-b855-135e0f2f7f7c%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/c8a21f7b-13be-46aa-b855-135e0f2f7f7c%40googlegroups.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/CAPGFgA3SeMvzg6N1yGpoNnkVoz5yZWAF3mqeskKGJO1%3DbsAbrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to