Maxscript: Grasping functions

Maxscript: Grasping functions

Anonymous
Not applicable
341 Views
0 Replies
Message 1 of 1

Maxscript: Grasping functions

Anonymous
Not applicable

Im trying to understand this example-code and why or where z_node and node_to_z is defined. All i can see is the "subobject" being defined, not the actual z_node var.

 

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 inselection 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 

 I'm in need of a script like this but on spline subobject-level, on knots. I'm thinking it will involve looping trough shapes,segments and knots in a nested form and applying a similar intersect-function?

 

/Fred

0 Likes
342 Views
0 Replies
Replies (0)