[Closed] link object to vertex script problem
Hello everyone, I am attempting to link an object to a vertex, and I found this script at
http://www.3dluvr.com/content/article/51
Does anyone have any idea why it doesn’t seem to allow me to successfully pick a vertex to use? or, is there any other good solution to link an object to a vertex or group of vertices? (like clusters in other programs)
Thanks
text of script attached below
MainFloater = NewRolloutFloater “Link To Vertex” 300 315
Rollout Vert_Linker “Vertex Linker” (
group “Pick Vert” (
Label getvert1L “Select a vertex to be parent”
Label getvert2L “then hit ‘Get Selected Vert’”
Button GetVert_Button “Get Selected Vert”
Label vertnumL “Vertex Number: (none selected)”
) – close group
group “Pick Child” (
Label childL “Select Child Object”
PickButton GetChild_PB “Get Child”
Label childnameL “Child Object: (none)”
) – close group
group “Link ME Plz!” (
Button LinkME_Button “Link ME!” enabled:off
) –close group
on GetVert_Button pressed do (
parentOBJ = $
vertnum = (getvertselection parentOBJ)[1]
vertnumL.text = “Vertex Number: ” + (vertnum as string)
VertPicked = true
if ChildPicked == true do LinkME_Button.enabled = on
) – close on getvert
on GetChild_PB picked obj do (
Child_Obj = obj
childnameL.text = “Child Object: ” + Child_Obj.name
ChildPicked = true
if VertPicked == true do LinkME_button.enabled = on
) –close on getchild
on LinkME_button pressed do (
Child_Obj.position.controller = position_script()
Child_Obj.position.controller.script = “getvert parentOBJ vertnum”
) –close on linkme
) – Close Rollout
addRollout Vert_Linker MainFloater – Add Rollout to the main floater
hi, you could try doing it manually…
(a scene with box01 and a sphere01)
- Select sphere01. (this is the object that we are going to move)
- Assign a script controller for its position.
- Open up the script controller properties and type this code:
getvert $box01 1
What this code basically does is it gets the vertex of box01, the index of the vertex would be 1.
So incase you want to change your target object, just change $box01 to the name of your object, dont forget to include the “$”.
And the number at the end of the code goes for the index of the vertex.
You could also type the same code on the listener, you’ll get the position of the vertex.
hope this helps
Thanks for your reply, I’m not too familiar with maxscript but I’d like to learn… Since I posted I found a way to attach it using the attachment constraint which worked fine.
Thanks again,
Josh