Re: [Maya-Python] MMeshIntersector: Getting world position / matrix of point in object space

2018-08-01 Thread Luiz Amaral
You should at least pass the identity matrix like this

meshIntersect.create(mesh, om2.MMatrix.identity)

-- 
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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/fab96010-ac16-49c7-8452-68851e98f0d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] MMeshIntersector: Getting world position / matrix of point in object space

2018-08-01 Thread Luiz Amaral
Try this

matr = om2.MMatrix(dag.inclusiveMatrix())
meshIntersect.create(mesh, matr)

-- 
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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/5d3acb67-af64-44b9-9871-aea7967bae66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] MMeshIntersector: Getting world position / matrix of point in object space

2018-08-01 Thread igo rov
Hi,
as for the missing Matrix parameter, there is this thread:
https://groups.google.com/forum/#!topic/python_inside_maya/axX7W8imeEU

I have the same problems as described there, if I pass the matrix I will
get this error: More keyword list entries (4) than format specifiers (2)

But you are right, there has to be a Matrix parameter as the documentation
says:.

then the matrix passed to create() should provide the mapping
from world space to the mesh's object space.


So for me the MMeshIntersector is not working

2018-08-01 23:47 GMT+02:00 Luiz Amaral :

> Hey there,
>
> “ ‘Point’ Specifies the location for which to evaluate the closest point
> on the mesh. `point' is transformed using the matrix parameter passed to
> the create() method, so for example if your matrix maps world to object
> space, then `point' should be specified in world space.”
>
> You should either pass the cube’s world matrix on creation or pass the
> point localized to the cube’s space on get closest point.
>
> Since you created the MMeshIntercector without passing a matrix to it the
> get closest point function expects a localized position.
>
> That’s why you are getting a “random” point instead of the closest point
> to locator2.
>
> If you pass the cube’s world matrix to the create just multiply the result
> of the get closest point by the same matrix and your locator will snap to
> the expected place.
>
> Or you can keep create the way it is and multiply the point by the inverse
> of the cube’s world matrix before passing it to the get closest point and
> then multiply the result by the world matrix again.
>
> Cheers,
>
> Luiz
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Python Programming for Autodesk Maya" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/python_inside_maya/zGdhBD6SuUE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/python_inside_maya/82d9cdd0-b19f-4da4-b36d-
> 883ef7f86deb%40googlegroups.com.
> 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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CANAXgk8_jZvjo2%3Dp0jvNk06iWC_Oq584yEiUv%2BeS8Z12HSt5Cg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Catching maya's error ?

2018-08-01 Thread Virbhadra Gupta
Really that much simple.
Thanks!!!

-- 
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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/f9d07dc4-1344-4685-a4b1-a354c57b0158%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Catching maya's error ?

2018-08-01 Thread Marcus Ottosson
try:
do_something()except Exception as e:
cmds.warning(e)


On Wed, 1 Aug 2018 at 21:19, Virbhadra Gupta  wrote:

> hello,
> i have a code where i am using try and except
>
> ex:
>
> try:
> do_something()
> except:
> cmds.warning("some error")
>
> function may give some error ex: "pCube03 not found", "can't constraint
> pCube02"
> how can we catch that error message and use that in except as warning.
>
> --
> 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 python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/96dd4b77-890d-4a5c-b3a9-0c1ffa70614f%40googlegroups.com
> 
> .
> 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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOA0COxAFhr9Ue3f5t46cF1vC2pvhXb%3DGTXwZQ3y35H6bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Catching maya's error ?

2018-08-01 Thread Virbhadra Gupta
hello,
i have a code where i am using try and except

ex:

try:
do_something()
except:
cmds.warning("some error")

function may give some error ex: "pCube03 not found", "can't constraint 
pCube02"
how can we catch that error message and use that in except as warning.

-- 
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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/96dd4b77-890d-4a5c-b3a9-0c1ffa70614f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.