python script to use with 'make Live' heeelelllppp...

173 views
Skip to first unread message

sam williams

unread,
Aug 8, 2014, 9:59:52 AM8/8/14
to python_in...@googlegroups.com
Hey there,

You know when you make a surface 'live' and then you select and move another nearby object and it instantly snaps to the closest point on the 'live' surface...

well i basically want to do this with a script. so it selects the object near the 'live' surface and basically moves its position fractionally so it will snap to the 'live' surface. How come it works when i grab the central pivot of the move control, but not when i use the cmds.move() command?

is this possible with scripting?

If anyone can help me with this i would be very grateful,

thanks,
Sam

(the end result im trying to achieve is to cycle through points on a curve and snap them one at a time to the closest point on a nearby mesh)

Janos Hunyadi

unread,
Aug 9, 2014, 4:50:25 PM8/9/14
to python_in...@googlegroups.com
Take a look at the MMeshIntersetor, or the MFnMesh (getClosestPoint) in the Maya API. You can search for the closest point on the mesh to a given point.

You need to dive into the api though.

Janos

sam williams

unread,
Aug 10, 2014, 8:56:49 AM8/10/14
to python_in...@googlegroups.com
thankyou for your help mate. i will definately look into this;)
Sam

Marcus Ottosson

unread,
Aug 10, 2014, 9:42:32 AM8/10/14
to python_in...@googlegroups.com
If your intent on cycling through vertices and snapping them using Python, then this probably won't help much. But if you're looking to snap a curve onto a mesh via their closest locations and you happen to be running Maya 2015, then there's an option under Edit Mesh called "Project Curve on Mesh" that could do what you want.


--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/617d28ae-b4f6-4234-af65-87cbea82dcbf%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

sam williams

unread,
Aug 10, 2014, 1:19:02 PM8/10/14
to python_in...@googlegroups.com
Thanks Marcus,
Does this tool, know automatically the closest point on the mesh to project onto?.

It seams you have to tell it where to hit the mesh, based on a selected axis or from the perspective of the camera. I basically need each point on the curve to know which part of the mesh is mathematically closest and then move to this location. I tried the project curve on mesh in maya 2014, i dont know if there is an updated 'proximity' feature in 2015..

cheers,
Sam


On Sunday, August 10, 2014 2:42:32 PM UTC+1, Marcus Ottosson wrote:
If your intent on cycling through vertices and snapping them using Python, then this probably won't help much. But if you're looking to snap a curve onto a mesh via their closest locations and you happen to be running Maya 2015, then there's an option under Edit Mesh called "Project Curve on Mesh" that could do what you want.
On 10 August 2014 13:56, sam williams <samwill...@gmail.com> wrote:
thankyou for your help mate. i will definately look into this;)
Sam


On Saturday, August 9, 2014 9:50:25 PM UTC+1, Janos Hunyadi wrote:
Take a look at the MMeshIntersetor, or the MFnMesh (getClosestPoint) in the Maya API. You can search for the closest point on the mesh to a given point.

You need to dive into the api though.

Janos

On Friday, August 8, 2014 6:59:52 AM UTC-7, sam williams wrote:
Hey there,

You know when you make a surface 'live' and then you select and move another nearby object and it instantly snaps to the closest point on the 'live' surface...

well i basically want to do this with a script. so it selects the object near the 'live' surface and basically moves its position fractionally so it will snap to the 'live' surface. How come it works when i grab the central pivot of the move control, but not when i use the cmds.move() command?

is this possible with scripting?

If anyone can help me with this i would be very grateful,

thanks,
Sam

(the end result im trying to achieve is to cycle through points on a curve and snap them one at a time to the closest point on a nearby mesh)

--
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+unsub...@googlegroups.com.



--
Marcus Ottosson
konstr...@gmail.com

Marcus Ottosson

unread,
Aug 10, 2014, 3:11:10 PM8/10/14
to python_in...@googlegroups.com
Hi Sam,

That's a good point, you may be right, it might not be possible with that command alone. However, if you're up for getting a bit creative, there's one more approach I could suggest.

1. Loft your curve
2. Convert to polygons
3. Clear history of polygons
4. Wrap your original curve to the converted loft
5. Use the transfer attributes tool to snap the converted loft onto your target.
6. Clear history of curve
7. Delete converted loft

Clearly a bit involved, but when done via a script should be quite seamless, although I suspect that if I were more comfortable with the API and its raycasting methods I'd probably suggest that for you instead. :) Let me know how it goes!
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/025b0ca4-83da-469c-a0e7-eda5821dd886%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Marcus Ottosson
konstr...@gmail.com


Reply all
Reply to author
Forward
0 new messages