PDA

View Full Version : pickbutton in CustAttribute UI


bhnh
03-25-2008, 02:40 PM
I've run into a bit of a syntatical problem. The idea here is that a box is created with a pickbutton as a custAtt UI. With the pickbutton pressed, any object selected will align with the box's y-position. Here's what I've got:
(
ca = attributes new
(
parameters main rollout:params
(
custLink type:#node ui:pbt_cl
)

rollout params "Pickbutton Test"
(
local targ
pickbutton pbt_cl "Custom Connect"

on pbt_cl picked obj do
(targ = obj)
)
)

rollout test "pbt test"
(
button btn "Make Box"

on btn pressed do
(
b = box()
custAttributes.add b ca
holder = point()
holder.parent = b
fs = float_script
holder.position.x_position.controller = fs
fs.addNode "this" b
fs.addNode "picked" targ
fs.script = "with animate off (picked.pos.y = this.parent.pos.y)"


)
)
createDialog test 200 50
)
The above code throws the following error: -- Type error: Assign needs controller, got: float_script
Any guidance on where I screwed up? Many thanks.

PEN
03-25-2008, 02:55 PM
Looks like you just missed the parentheses at the end. I have not tested how ever. The controller is an object and just like any object it needs those if you are not passing any other parameters to it at the time of creation.
fs = float_script()

bhnh
03-25-2008, 03:09 PM
Argh!:scream: Thanks, Paul. I expect a higher level of mistakes from myself.

bhnh
03-25-2008, 03:46 PM
On to the next error.:rolleyes: The following code...
(
ca = attributes new
(
parameters main rollout:params
(
custLink type:#node ui:pbt_cl
)
rollout params "Pickbutton Test"
(
local targ
pickbutton pbt_cl "Custom Connect"

on pbt_cl picked obj do
(targ = obj)
)
)
rollout test "pbt test"
(
button btn "Make Box"

on btn pressed do
(
b = box()
custAttributes.add b ca
holder = point()
holder.parent = b
fs = float_script()
holder.position.x_position.controller = fs
fs.addNode "this" b
fs.addNode "picked" targ
fs.script = "with animate off (if (picked.isSelected == true) then picked.pos.y = this.parent.pos.y)"


)
)
createDialog test 200 50
)
Throws the following error...
-- Runtime error: IScriptCtrl::SetExpression - Expression evaluation error:
MAXScript Script Controller Exception: -- Unknown property: "isSelected" in undefined[
I'm goofing up the expression somehow.

decon
03-26-2008, 12:59 PM
why don't you just say

on pbt_cl picked obj do (
targ = obj
targ.pos.y = $.pos.y
)

then the holder has no function, but maybe i missed something .. :)

bhnh
03-26-2008, 07:57 PM
If only it were that easy, Timo; I'd pounce on it. If you try that variation in the code posted, though, nothing happens. The holder's required to be an outside listener to dynamic events after the box has been created.

As I currently understand it, float script variables are stored locally to the script. So modifying the "targ" variable elsewhere in the code (ie...outside of the float script)...will have no effect on the float script.

bhnh
03-26-2008, 11:07 PM
OK, here's BlunderingAround 2.0...
(
local obj
ca = attributes new
(
parameters main rollout:params
(
targ type:#node ui:pbt_cl
)

rollout params "Pickbutton Test"
(
pickbutton pbt_cl "Custom Connect" autodisplay:true

on pbt_cl picked obj do
(targ = obj)
)
)

rollout test "pbt test"
(
button btn "Make Box"

on btn pressed do
(
b = box()
custAttributes.add b ca
holder = point()
holder.parent = b
holder.position.x_position.controller = float_script()
fs = holder.position.x_position.controller
fs.addNode "this" b
fs.script = "try(this.targ = obj\n
with animate off (this.targ.pos.y = this.pos.y))catch(0)"
)
)
createDialog test 200 50
)
I do have it at the point where a picked object will be assigned as the box's .targ property, but there's still no position change called from the script. I'm still mystified as to how to construct and insert the "SetNode" in the script. I'm finding the MAXScript Reference on the subject to be a little too abbreviated for me to understand.

bhnh
03-27-2008, 11:08 PM
For Search and Archive purposes, here (at last) is a working version of the code:
(
local obj
ca = attributes new
(
parameters main rollout:params
(
targ type:#node ui:pbt_cl
)
rollout params "Pickbutton Test"
(
pickbutton pbt_cl "Custom Connect" autodisplay:true

on pbt_cl picked obj do
(this.targ = obj)
)
)
rollout test "pbt test"
(
button btn "Make Box"

on btn pressed do
(
b = box()
custAttributes.add b ca
holder = point()
holder.parent = b
holder.position.x_position.controller = float_script()
fs = holder.position.x_position.controller
fs.addNode "box" b
fs.script = "try(with animate off (box.targ.rotation.x = box.rotation.x))catch(0)"
)
)
createDialog test 200 50
)
A HUGE thank-you to Tyson Ibele over at the SimplyCG forum for helping me sort this out.

CGTalk Moderation
03-27-2008, 11:08 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.