Move Objects to a Surface
When a terrain is not flat, it is time consuming to move each object (trees, lights, vehicles, or furniture) one by one. This script is really useful for this situation.
Go to Help > MAXScript Help >How To – Practical Examples > Move Objects to a Surface. This time, I will save this script to the tool bar. Inside of MAXSCRIPT box, copy all sentence;
macroscript MoveToSurface category:"HowTo"
(
fn g_filter o = superclassof o == Geometryclass
fn find_intersection z_node node_to_z =
(
local testRay = ray node_to_z.pos [0,0,-1]
local nodeMaxZ = z_node.max.z
testRay.pos.z = nodeMaxZ + 0.0001 * abs nodeMaxZ
intersectRay z_node testRay
)
on isEnabled return selection.count > 0
on Execute do
(
target_mesh = pickObject message:"Pick Target Surface:" filter:g_filter
if isValidNode target_mesh then
(
undo "MoveToSurface" on
(
for i in selection do
(
int_point = find_intersection target_mesh i
if int_point != undefined then i.pos = int_point.pos
)--end i loop
)--end undo
)--end if
)--end execute
)--end script
Then go to MAXScript > New Script… Paste this text, then go to Tools > Evaluate All.

Next, go to Customize > Customize User Interface > Toolbars. Under the Category, drop down menu choose HowTo(1). You will see MoveToSurface(2) under the Action now. Click New…(3) and type Script(4) then click OK to exit.

One last thing, make sure an object’s Pivot point that you want to move to surface is bottom of the object.
No comments:
Post a Comment