Message 1 of 6
semi-dynamic parameter default in scripted plugin
Not applicable
03-26-2009
12:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Does anyone know if there is a way to change the default value of a parameter before a scripted plugin object is created?
Essentially I want to count the number of a certain type of object in the scene and make the parameter default to that number plus one in the rollout.
ie if we had one box in the scene, it's 'testParam' would be set to one. With 20 boxes in the scene, if we created a new box it's 'testParam' would be 21.
I can set this in the 'tool create' section, but I want it to be visible in the rollout and changable before the object is created.
As an aside, does anyone know why the parameter defaults are used in the initial rollout rather than the rollout defaults?
Testing codes as follows:
The line:
is where I'm having the problem. Ideally it would be as simple as
however that doesn't work. Neither does (my implementation of) an execute line, as mentioned here
I'm trying the execute as follows;
or;
Any help much appreciated
Essentially I want to count the number of a certain type of object in the scene and make the parameter default to that number plus one in the rollout.
ie if we had one box in the scene, it's 'testParam' would be set to one. With 20 boxes in the scene, if we created a new box it's 'testParam' would be 21.
I can set this in the 'tool create' section, but I want it to be visible in the rollout and changable before the object is created.
As an aside, does anyone know why the parameter defaults are used in the initial rollout rather than the rollout defaults?
Testing codes as follows:
plugin helper test
name:"test"
category:"test"
classID:#(0x3d3f8c7a, 0x470fa329)
extends: exposetm
initialRollupState: 0x00000007
version: 1
(
fn GetNodeCount =
(
nodeCount =0
for i in helpers do
(
if (hasProperty i "pTestParam") then
(
nodeCount += 1
)
)
nodeCount
)
local lNodeCount = GetNodeCount()
parameters qmotionParam rollout: testRollout
(
pTestParam type:#integer animatable:false ui:uTestParam default:25
)
tool create
(
on mousePoint clickno do
(
if (clickno == 1) then
(
nodeTM.position = worldPoint
delegate.useParent = false
delegate.box = true
delegate.cross = false
)
)
on mouseMove clickno do
(
if (clickno == 2) then
(
nodeTM.position = worldPoint
)
else
(#stop)
)
)
rollout testRollout "Testing"
(
Spinner uTestParam "Test:" type:#integer range:
)
)
The line:
pTestParam type:#integer animatable:false ui:uTestParam default:25
is where I'm having the problem. Ideally it would be as simple as
pTestParam type:#integer animatable:false ui:uTestParam default:lNodeCount
however that doesn't work. Neither does (my implementation of) an execute line, as mentioned here
I'm trying the execute as follows;
parameters qmotionParam rollout: testRollout
(
execute "pTestParam type:#integer animatable:false ui:uTestParam default:" + lNodeCount as string
)
or;
execute "parameters qmotionParam rollout: testRollout\n (pTestParam type:#integer animatable:false ui:uTestParam default:" + lNodeCount as string+")"
Any help much appreciated