Parent to Surface script

By -
2 mins
Last modification: 16 Sep, 2017

Here is a script for sticking objects onto a deforming surface(click to download): parentToSurface.mel This mel command allows one to attach selected objects to a selected mesh or nurbs surface. The objects will follow any deformation or transformation of the surface. To use put this script in your local scripts directory. In Maya select object(s) followed by a mesh or nurbs surface to attach to then enter "parentToSurface" in the command line. A follicle node will be created at the point on surface closest to the center of the object and the object will be parented to this follicle. Note that if the surface to attach to is a mesh it must have well defined UVs that range from 0-1 with no areas sharing the same value. For convenience drag the parentToSurface string onto the shelf to make a shelf button. This command uses the follicle node, which is normally used by the hair system. The follicle node is currently the only node in maya that can derive a rotate and translate based on a uv position for both meshes and nurbs surfaces. I found that I was explaining the complicated workflow of how to setup a follicle node in this manner so frequently that it was worth creating this script, which is much easier to use. One use of this script might be to attach buttons to a cloth object, or any deforming surface. For the example animation stuckOnCloth.avi the workflow was simply to first position all the button objects( in this case pipes, cones and cylinders ) in the desired position then select them followed by the cloth mesh and run this command. After one has attached an objects with this command one can also move it across the surface by editing the uv value on the follicle nodes. Also the node is parented to the follicle, so one is free to rotate and position the button object as desired with respect to the follicle. As with all the scripts on my blog, please feel free to modify and share with others.

editPfxOnPolyPath.mel parentToSurface.mel
Posted By
Published In
  • MEL
To post a comment please login or register
| 19 days ago
Has this stopped working? It's a vital script!
| 8 months ago
Hey I can't download anything but it would help me a lot using this script, is there any way I could find it somewhere else? Thanks!
| 4 years ago
Hi Duncan, I have some blobby particles converted to an output mesh that flows along to resemble mucous. What I want to do now is attach some objects to the mucous so they move along with it. I’ve tried using your parent to surface script, but instead of the follicle staying attached to the mesh, it jumps all over the mesh and back to the origin periodically too. I’ve also tried attaching locators to specific verts on the output mesh using constrain>point on poly, but it does the same thing. I’m thinking that because this surface is generated from particles, this might not be possible? Is it something to do with UVs? Any ideas on what to do or another approach to try please? Thanks so much for all your help!
Edited by TfQLqmMW 4 years ago
| 5 years ago
Many thanks Duncan, this script has been super helpful this morning.
Edited by POktMOf5 5 years ago
| 6 years ago
Thanks!! Im making a tree, as I needed to parent particle instances of nCloth leaves to branches with bend deformers and noise(time) attached to the curvature. I was about to give up as i had tried everything and now I have found this. Its so useful it should be included in maya.
Edited by QHdN2NC8 6 years ago
| 6 years ago
It seems to be a problem with the UVs for the follicles. It sets up one correctly, then doesn't seem to know what to do with the others and gives a massive number for the U co-ordinate and 0 for V. This leaves the follicle sitting at the origin....
Edited by TfQLqmMW 6 years ago
| 6 years ago
Hi Duncan, Nice script thankyou! However, I've come into a problem. I've created a single mesh from several separate pieces using mesh combine, converted it to cloth and now have the dynamics working nicely. The problem is in trying to stick some mesh objects to the deforming object only attaches one mesh. Although follicles are generated for all the other meshes, they do not move with the cloth, only the one mesh follows it. I've worked out the problem is with the mesh combine. Is there any way around this please?
Edited by TfQLqmMW 6 years ago
| 6 years ago
Here we are in 2013 and I'm STILL using this amazing script. Maya 2013 has a built in "point on poly" and "closest point" constraints but rotations are a huge problem.
Edited by DnjWzyKe 6 years ago
| 7 years ago
That is EXACTLY what I'm looking for. Thanks. Even better would be if the download link actually worked. Could you point me to a place where I can grab it? Million thanks, Nik
Edited by 6lgH5KuM 7 years ago
| 8 years ago
Great gadget! Thanks a lot! Daniel
| 10 years ago
I think that this is what I need! Thanks Duncan. I am simulating a marionette, and I need some way to drive the rig's controllers through the nCloth strings deformation caused by the marionette's manipulator handle.
| 10 years ago
I assume these are strictly "Unlimited" scripts, since a follicle node is being used in one.
| 10 years ago
Hi Duncan, thanks for all your works, I have some similar project in progress. Thank you for sharing all your technics Nicolas
| 12 years ago
hey duncan i am having a very weird problem. i have a tons of objects parented to a skin surface using ur script. but. mental ray wont render them unless i unparent from the follicle. what a nightmare. any ideas?
| 12 years ago
hey duncan. just to say thanks. i am directing a music video with a huge amount of objects that need to be stuck to a character. i have tried a few things until i found this script, whihc made everythin fall into place. the fact it work in hirarchy adn not contraints is beutifull. so well done.
| 12 years ago
A mix of both methods is usually best. Create single quad plane proxies for all your buttons and make them cloth. Then attach the detailed button models to these cloth planes with the parentToSurface script. You can also set the collide thickness on the cloth buttons to match the thickness of your real buttons.
| 12 years ago
Thanks Duncan. I've done buttons and other attachments on nCloth in two ways; one with follicles (which will be much easier now!), and by making the objects nCloth and keeping them in place using component to component restraints. I've found that the second method takes more computing power to simulate and is more troublesome, but you can get decent results using either method. I would guess that the best reason for doing it the second way is that you can make the buttons weigh more and pull the cloth down as they react to gravity.
*Save $66 per month on Autodesk's Suggested Retail Price (SRP) when purchasing 1 year term 3ds Max or Maya subscription.