attach to face using attachment contraint

attach to face using attachment contraint

Anonymous
Not applicable
458 Views
2 Replies
Message 1 of 3

attach to face using attachment contraint

Anonymous
Not applicable
i'm writing a script to attach a dummy object to the face of another object using the attachment constraint. here is what i have so far:


rollout face_linker "Link to Face"(

Group "Pick Parent Face" (
pickButton parent_PkBtn "Pick Parent Object"
label Parent_lbl "Parent Object: (none selected)"
label getface_lbl ""
Button parentFace_Btn "Grab Face" enabled: off
label parentFace_lbl "Face Number: (none selected)"
)
Group "Creat Dummy-Child"(
label dummyname_lbl "Name of new Dummy-Child object"
edittext dummy_txt "" fieldWidth:200
button createDummy_btn "Create Dummy Child" enabled: off
)
Group "About"(
button help_btn "Help" pos: width: 50
button about_btn "About" pos: witdh: 50
)

--Button comamnds:

on parent_PkBtn picked obj do (
parentOBJ = obj
select parentOBJ
modPanel.addModToSelection (Mesh_Select ()) ui:on
subobjectLevel = 3
getface_lbl.text = "select a face, then press 'Grab Face'"
Parent_lbl.text = "Parent Object: " + parentOBJ.name
parentpicked = true
if parentpicked == true do parentFace_Btn.enabled = on
)

on parentFace_Btn pressed do (
select = parentOBJ
parentFace = (getFaceSelection $) as array
if parentFace.count > 0 do (
facenum = (parentFace)
parentFace = (facenum as string)
parentFace_lbl.text = "Face Number: "+ parentFace
)
subobjectLevel = 0
deleteModifier $ 1
facepicked = true
if facepicked == true do createDummy_btn.enabled = on
)

on createDummy_btn pressed do(
if dummy_txt != "" do (
new_obj = dummy ()
dummyname = dummy_txt.text + "_"
new_obj.name = (uniquename dummyname)
new_obj.pos.controller = Attachment ()
)
)
)
if MainFloater != undefined do(
closerolloutfloater MainFloater
)
MainFloater = newRolloutFloater "Link to Face" 250 310
addrollout face_linker MainFloater


i'm stuck at the very end. i have searched through the max help files and documentation as well as online but i can't find the maxscript commands for the attachment constrain settings, mainly the object to attach, the face, and the A and B nodes associated with the attachment constrains

the reason I'm using the attachment constraint over a position script constraint is because the position script constrain doesn't seem to updates continuously, it only updates during playback.
0 Likes
459 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
See "Attachment Controller Keys" topic in the Reference and the example I put in there which attaches a Sphere to the end of a bending Cylinder. Doesn't get any clearer than that... 😉

A and B are the first two components of the Barycentric coordinates. Bary coords have 3 components whose sum is always 1.0, so providing two implicitly provides the third component. See the "WHAT ARE BARYCENTRIC COORDINATES" box in the Node Common Properties topic, intersectRayEx() method description.
0 Likes
Message 3 of 3

Anonymous
Not applicable
Doesn't get any clearer than that... 😉


you are absolutely right it doesn't get any clearer then that, thanks. i was able to finish up the script and i have V1.0.2 ready, a few changes to the layout and organization of the help and about sections. I'm still looking into the intersectray, is there an example that you can recommend or point me in the right direction for using intersectray to pick a face of an object?

Right now this scrip just creates a dummy that is attached to a surface and you simply link what you want to follow to the dummy.

Finished Script - Link to Face
0 Likes