Hi Paul,

My apologies, you're right, I should have formed a better question with a
simple example file but I suppose the heat of production is getting to me,
thankfully Ian's answer was the perfect timely alternative.  Thanks Ian!

Today I can't replicate the issue, I was hoping to reply with a full
example and cut down Maya file.  I've opened the same character file, doing
the same thing and it's working as expected.  It's like when you report an
IT problem and when the IT guy stands next to you it's working as expected,
oh well, I digress.

I've updated the gist with the full code.  I've turned down the loop to 1
iteration (line 70) in my testing yesterday it had to be at 50 iterations
to be sure it correctly found the UV position.  If I do find a repeatable
mesh I'll definitely update this thread with examples.

Thanks again and thanks Ian

-Dave





On Wed, Mar 15, 2017 at 5:14 PM, Paul Molodowitch <[email protected]>
wrote:

> Hi David  - a few tips when seeking help on this list:
>
> - Whenever possible, provide all the code necessary to set up the scene to
> test
> - Provide all the pertinent code to replicate the problem
> - This will generally mean extracting and simplifying your code. Do so.
>
> Doing this will mean more work on your part - often extracting the
> pertinent piece so it can be run in isolation is not trivial - but it's
> worth it.  When troubleshooting, it's generally something you want to do
> anyway - it will help eliminate extra variables, and generally speed up
> your test / retry cycle a lot.  For others, it makes it much easier for
> them to diagnose your problem and help, as well as shows that you've taken
> some time to try to solve the issue on your own.
>
> In your case - we have no means of replicating your problem, so we have no
> way of knowing what's going on.  Is it a problem with the getUVAtPoint, or
> other code? And the bits of extra code you've chosen to include actually
> further confuse the issue, not clarify.  You include an outer loop, but
> don't even use the variable you're iterating over (x) in your snippet. How
> is "face" even getting changed?
>
> This code seems to work for me - and also provides a good example of a
> self-contained code sample:
>
> https://gist.github.com/elrond79/e920bd1fa8b6d5c2345dc32369bda4f5
>
> On Wed, Mar 15, 2017 at 7:11 AM David Moulder <[email protected]>
> wrote:
>
>> Thanks for pointing this out Andres,
>>
>> It's not obvious from the gist but this uses PyMel.  It's wrapping of the
>> API lets you use strings for the space param.  I believe its using a pymel
>> enum under the hood before constructing the MSpace object.
>>
>> Cheers
>>
>> On Wed, Mar 15, 2017 at 4:16 AM, Andres Weber <[email protected]>
>> wrote:
>>
>> I commented on your gist but I'll add here just in case you don't check
>> that often:
>>
>> The problem with this code is specifying your world space as a string
>> value. It requires an integer and for maximum future proofing you should
>> use the pre-defined one from the api:
>> OpenMaya.MSpace.kWorld
>>
>> Feed that into your second argument instead of "world" and assuming that
>> you've iterated through the faces correctly, it should return the correct
>> result.
>>
>> Help on built-in function getUVAtPoint:
>>
>> getUVAtPoint(...)
>>  getUVAtPoint(point, space=MSpace.kObject, uvSet='') -> (float, float,
>> int)
>>
>>  Returns a tuple containing the u and v coordinates of the point on
>>  the mesh closest to the given point, and the ID of the face
>>  containing that closest point.
>>
>>
>>
>>
>> On Tuesday, March 14, 2017 at 2:14:04 PM UTC-4, thirstydevil wrote:
>>
>> Just tried it, works like a charm.  I guess that when you've used
>> follicles so so long you don't look else where.  Doesn't solve the issue
>> above but if it's solid I'll swap the code out to this function call.
>>
>> Thanks Ian!
>>
>> -Dave
>>
>> On Tue, Mar 14, 2017 at 5:43 PM, Ian Waters <[email protected]> wrote:
>>
>> Hey Dave,
>>
>> Not a solution to your problem, but did you try the Surface Attach tool
>> that comes with Maya Muscle? We’ve found it to be a lifesaver.
>> Deform > Muscle > Bonus Rigging > Surface Attach
>>
>> Worth a shout :)
>> Ian
>>
>> On 14 Mar 2017, at 17:40, thirstydevil <[email protected]> wrote:
>>
>> So I've been having issues today with all types of rivet scripts, the
>> closets point on poly node or anything that is essentially using
>> maya.OpenMaya.MSpace.getUVAtPoint
>>
>> If I run the below just once I get [0,0] as the uv position.  If I run it
>> several times it will eventually return the correct result.  Maya 2017
>> update 3.
>>
>> Anyone experiencing this, is it normal?
>>
>> https://gist.github.com/thirstydevil/817c335c356e8c231d35fc013f654bfd
>>
>> -Dave
>>
>> --
>> 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/cc04ad67-2c28-4e30-bb4d-
>> d9766ac4c6db%40googlegroups.com
>> <https://groups.google.com/d/msgid/python_inside_maya/cc04ad67-2c28-4e30-bb4d-d9766ac4c6db%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/1561608D-5354-4611-9867-D8716AA374CB%40gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/1561608D-5354-4611-9867-D8716AA374CB%40gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>>
>> --
>> *David Moulder*
>> Technical Animator / Artist
>> [email protected]
>> *Professional Profile
>> <http://uk.linkedin.com/pub/david-moulder/1/b12/b5a>*
>>
>> Mobile: +44 (0)7814033242 <07814%20033242>
>> See who we know in common
>> <http://www.linkedin.com/e/wwk/5748982/?hs=false&tok=3tztwkse1silw1> Want
>> a signature like this?
>> <http://www.linkedin.com/e/sig/5748982/?hs=false&tok=3pwLU9-mBsilw1>
>>
>> --
>> 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/b18c1685-48ef-470d-83b5-
>> 142db540c2c3%40googlegroups.com
>> <https://groups.google.com/d/msgid/python_inside_maya/b18c1685-48ef-470d-83b5-142db540c2c3%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>>
>> --
>> *David Moulder*
>> Technical Animator / Artist
>> [email protected]
>> *Professional Profile
>> <http://uk.linkedin.com/pub/david-moulder/1/b12/b5a>*
>>
>> Mobile: +44 (0)7814033242 <+44%207814%20033242>
>> See who we know in common
>> <http://www.linkedin.com/e/wwk/5748982/?hs=false&tok=3tztwkse1silw1> Want
>> a signature like this?
>> <http://www.linkedin.com/e/sig/5748982/?hs=false&tok=3pwLU9-mBsilw1>
>>
>> --
>> 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/CABD4PkRWdgJ4dPUwVX%3De2NCC7R6PgVe6w-_
>> 7gCs9eLqvpgoD2g%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CABD4PkRWdgJ4dPUwVX%3De2NCC7R6PgVe6w-_7gCs9eLqvpgoD2g%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/CAAssL7YHfV4UjZhOSzD04WrM2HW5U
> cA-LqwRyu7hKA3pqiodkA%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAAssL7YHfV4UjZhOSzD04WrM2HW5UcA-LqwRyu7hKA3pqiodkA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*David Moulder*
Technical Animator / Artist
[email protected]
*Professional Profile <http://uk.linkedin.com/pub/david-moulder/1/b12/b5a>*

Mobile: +44 (0)7814033242
See who we know in common
<http://www.linkedin.com/e/wwk/5748982/?hs=false&tok=3tztwkse1silw1> Want a
signature like this?
<http://www.linkedin.com/e/sig/5748982/?hs=false&tok=3pwLU9-mBsilw1>

-- 
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/CABD4PkQ3Y6EPEC7ptHtqH%2BDQ_9tOVe2RVPc0nnWDEQ5dMjG9pg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to