[Closed] Linking Tool for other properties via script?
Hi there
You all know the link tool used for parenting objects. Now is there a possibility to script a similar tool, with stuff like you click the button then, you click/drag over objects just as the linking tool does but linking other properties or even call some scripted function which takes the source and linked-to node and does stuff?
Basically like I said the link tool with similar behaviour but instead of linking transforms calling a function?
I guess that would be a macroscript. Currently I am thinking of no interface. Just a button exactly as the link tool but instead of linking two or more objects I want to call a function.
something like this:
macroScript wirePosRot
category:"Learn MXS with denisT"
buttonText:"POS ROT"
toolTip:"Sample Wire Position and Rotation"
autoUndoEnabled:off
silentErrors:off
(
local checked = off
on isChecked do checked
on isEnabled do objects.count > 1
on execute do if not checked do undo "WirePosRot" on
(
checked = on
if not isvalidnode (target = selection[1]) do target = pickObject select:on
if isvalidnode target and isvalidnode (source = pickObject rubberBand:target.pos) do undo "WirePosRot" on
(
source.rotation.controller[3].controller = target.position.controller[3].controller
)
checked = off
)
)
the macro binds z position of one node with z rotation of another. the first node might be selected or not.
of course it will be better to add filter functions. in my case for example it’s a test for right types of controllers…
here is the same but as dialog:
try(destroydialog wirePosRotDialog) catch()
rollout wirePosRotDialog "Learn MXS with denisT" width:200
(
checkbutton bind_bt "Bind Position and Rotation" width:191 pos:[4,4]
on bind_bt changed state do if state do
(
if not isvalidnode (target = selection[1]) do target = pickObject select:on
if isvalidnode target and isvalidnode (source = pickObject rubberBand:target.pos) do undo "WirePosRot" on
(
source.rotation.controller[3].controller = target.position.controller[3].controller
)
bind_bt.state = off
)
)
createdialog wirePosRotDialog
Okay tested it and it worked like a charm.
But I got difficulties to make it work for multiple objects.
Like take a set of objects, and link one other objects properties on to all of them. All with the rubberband.
EDIT: nvm got it