[Closed] Link controller UI with part of a parameter
I’m trying to have a dialog window with some UI elements, such as X/Y/Z, which would be linked to a dummys parameters. At the moment, I have them linked one by one in each their parameter like below, which currently works:
Dummy part
parameters dummyRollout
(
floatPosX type:#float animatable:true default:0
floatPosY type:#float animatable:true default:0
floatPosZ type:#float animatable:true default:0
)
and the dialog part
rollout rolloutDialog "Test" width:500 height:300
(
spinner spnPosX "X:" type:#worldunits controller:(dummyHelper.floatPosX.controller)
spinner spnPosY "Y:" type:#worldunits controller:(dummyHelper.floatPosY.controller)
spinner spnPosZ "Z:" type:#worldunits controller:(dummyHelper.floatPosZ.controller)
)
However I was wondering if it is possible to get one UI element linked to one part of a parameter, so I can have only one parameter, such as a point3, for example have the X UI linked to only the first value in the point3. However it doesn’t seem to work if you try to do something like this:
floatPos type:#point3 animatable:true default:[2,20,45]
spinner spnPosX "X:" type:#worldunits controller:(dummyHelper.floatPos.controller.x)
spinner spnPosY "Y:" type:#worldunits controller:(dummyHelper.floatPos.controller.y)
spinner spnPosZ "Z:" type:#worldunits controller:(dummyHelper.floatPos.controller.z)
Is it possible at all to do it sort of like that? I need to have the changes in the dummy to reflect on the UI and the other way around, especially regarding animation. I could always send the changes from the UI to the parameters manually with On Changed, however that wouldn’t be animatable in the UI.
I hope it makes sense.
you can’t do it with types #point2, #point3, #point4, … but can it with #tab types.
global MultiVarAttribute = attributes MultiVarAttribute
(
parameters params rollout:params
(
threeFloat type:#floatTab animatable:on tabsize:3 tabsizevariable:off ui:(ui_threeFloat1,ui_threeFloat2,ui_threeFloat3)
twoBool type:#boolTab animatable:off tabsize:2 tabsizevariable:off ui:(ui_twoBool1,ui_twoBool2)
)
rollout params "Parameters"
(
spinner ui_threeFloat1 "Value 1: " type:#float range:[-1e9,1e9,0] fieldwidth:60
spinner ui_threeFloat2 "Value 2: " type:#float range:[-1e9,1e9,0] fieldwidth:60
spinner ui_threeFloat3 "Value 3: " type:#float range:[-1e9,1e9,0] fieldwidth:60
checkbox ui_twoBool1 "Checked 1"
checkbox ui_twoBool2 "Checked 2"
)
)
delete objects
b = box isselected:on
custattributes.add b MultiVarAttribute baseobejct:on
/*
b.threeFloat
b.twoBool
*/
Ah sorry I never got to reply on this, that’s was just what I was looking for, never got around to finish the script since I had a little harddisk crash, and got a new job, but it will actually work on something else I’m working on, so a (very) delayed cheers!
Oh btw, I just did a quick test, the example you gave only works if the UI is the same place as the parameters. When I try to affect a dummys parameters using a dialog window like this:
spinner ui_threeFloat1 "Value 1: " type:#float range:[-1e9,1e9,0] fieldwidth:60 type:#float controller:(dummyObj.threeFloat[1].controller)
or
spinner ui_threeFloat1 "Value 1: " type:#float range:[-1e9,1e9,0] fieldwidth:60 type:#float controller:(dummyObj.threeFloat[1].value)
it throws up the error message:
Unable to convert: undefined to type: Controller
and
Unknown property: “value” in 0.0
There must be a way to link a external UI to the parameter?
EDIT: Huh, my previous message didn’t appear. Was thanking you for the reply (late I know). I just noticed that none of my messages seem to appear in the forum, so I’m not sure where I can see replies.
I tried for a while now to get this to work, but I just can’t seem to do what I want it to, when I split the parameters from the UI. When I try to use the attribute inside the dummy object script, I get the error: Syntax error: at eol, expected Plugin clause:
This is my test code, first the dummy script that creates the dummy with the parameters in the scene:
plugin Helper TestDummy
name:"TestDummy"
classID:#(15555555, -12323112)
category:"Standard"
extends:dummy
(
global MultiVarAttribute = attributes MultiVarAttribute
(
parameters paraDummy
(
testPos type:#floatTab animatable:on tabsize:3 tabsizevariable:off
)
)
local helperObj
on getDisplayMesh do
(
if (helperObj == undefined) do helperObj = createInstance pyramid width:10 depth:10 height:10 widthsegs:1 setRenderable:0
helperObj.mesh
)
tool create (
on mousePoint click do
(
viewTM = getCPTM()
nodeTM = (transMatrix worldPoint) * (inverse viewTM)
#stop
)
)
)
And this is the UI script which launches the dialogbox. It doesn’t link anything right now, since I can’t get the dummy to work:
try(destroydialog testDummy) catch()
curObj = $DummyObj
rollout testDummy "Dialog" height:300 width:400
(
spinner spnValue "Val: " pos:[55,56] width:45 height:16 enabled:true range:[1,1e+008,1] type:#float scale:1 \
--controller:(curObj.testPos[1])
on spnValue changed val do
(
format "Spinner/Amount: % / %
" val curObj.testPos
)
on testDummy open do
(
format "Amount: %
" curObj.testPos
--spnValue.controller = curObj.testPos[1]
)
)
createDialog testDummy pos:[300, 200]
How do I get around making the parameters into the global variable while still using the dummy object?
So I still can’t get it to work, I was looking into the documentation for attributes, and there seem to be some commands related to plugins, but nothing specific about how to combine the two.
weaponDataCA = attributes weaponData ( Parameters main ( ) ) b=box() custAttributes.add b weaponDataCA c=b.baseobject.custAttributes[1] d=classof c superclassof c isMSPluginClass d isMSCustAttribClass d isMSPluginClass b isMSCustAttribClass b
I’m kinda of lost here.
I give up, I simply cannot get the external UI to link up to the parameter in the object, no matter what I do, and I just cannot figure out what I’m doing wrong. I thought I could use the MultiVarAttribute to link up the UI, but I still get the Unable to convert: 0.0 to type: Controller.
--Destroy dialog if it already exists.
try(destroyDialog theRollout)catch()
(
global MultiVarAttribute = attributes MultiVarAttribute
(
parameters params rollout:theRollout
(
threeFloat type:#floatTab animatable:on tabsize:3 tabsizevariable:off ui:(ui_threeFloat1,ui_threeFloat2,ui_threeFloat3)
)
rollout theRollout "The Rollout" width:300 height:159
(
spinner ui_threeFloat1 "Value 1: " pos:[15,5] type:#float
spinner ui_threeFloat2 "Value 2: " pos:[15,26] type:#float
spinner ui_threeFloat3 "Value 3: " pos:[15,47] type:#float
button btn2 "Button" pos:[7,116] width:102 height:28
)
)
b = $
z = custAttributes.get b 1
if z == undefined then
custattributes.add b MultiVarAttribute baseobject:on
else
MultiVarAttribute = z
rollout theRollout "The Rollout" width:300
(
spinner ui1_threeFloat1 "Value 1: " type:#float controller:b.threeFloat[1]
spinner ui1_threeFloat2 "Value 2: " type:#float
spinner ui1_threeFloat3 "Value 3: " type:#float
button checkBtn "Button" pos:[7,116] width:102 height:28
on checkBtn pressed do
(
format "Check: %
" b.threeFloat[1]
)
)
)
createDialog theRollout