pickbutton in CustAttribute UI

pickbutton in CustAttribute UI

bhnh
Advocate Advocate
385 Views
3 Replies
Message 1 of 4

pickbutton in CustAttribute UI

bhnh
Advocate
Advocate
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.
0 Likes
386 Views
3 Replies
Replies (3)
Message 2 of 4

bhnh
Advocate
Advocate
OK, first problem sorted out.... I had forgotten the () after float_script. On to the next error. 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.
0 Likes
Message 3 of 4

bhnh
Advocate
Advocate
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.
0 Likes
Message 4 of 4

bhnh
Advocate
Advocate
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.
0 Likes