utility nailsurface "Automatic Hammer" ( pickbutton picksurf "Pick Surface" pickbutton picknail "Pick Nail" label l1 "" button nailit "Nail it!" progressbar pb on picksurf picked ps do ( picksurf.text = ps.name ) on picknail picked ps do ( picknail.text = ps.name ) on nailit pressed do ( callbacks.removescripts id:#nailcb if (picksurf == undefined) then (messagebox "Pick a surface!") else if (picknail == undefined) then (messagebox "pick a nail!") else ( maxvert = picksurf.object.numverts u = picksurf.object settmp = #() for j = 1 to maxvert do ( t = copy picknail.object append settmp t -- t.position.controller = position_script() -- t.position.controller.script = ( -- "(in coordsys world (getvert $" + u.name + " " + (j as string) + "))\n") t.pos = (getvert u j) t.dir = (getNormal u j ) ---this is the line that sets the direction of the nail to the normal of the vertex t.parent = u pb.value = ((100*((j as float)/(maxvert as float))) as integer) hide t ) selectionsets["nailset"] = settmp settmp = undefined callbacks.addscript #prerender ("unhide selectionsets[#nailset]") id:#nailcb persistent:TRUE callbacks.addscript #postrender ("hide selectionsets[#nailset]") id:#nailcb persistent:TRUE messagebox "Script Finished." ) ) )