Notifications
Clear all
[Closed] pickbutton help
Nov 17, 2014 6:25 am
i wrote this test script to test different maxscript commands.
1-i want the “copy” button to be gray until i pick an object.
2-“theobject” will be remove from the memory at the start.
3-how can i use “theobject” variable to make action such as
copy or move?
rollout rlt_test “test”
(
pickbutton btnPick "Pick"
button btncopy "copy" enabled:false
on btnPick picked theObject do
(
btnPick.object = theObject
btnPick.caption = theObject.name + "-selected"
)
if theObject != undefined then
(
btnPick enabled:false
)
else
(
btnPick enabled:true
)
)
createDialog rlt_test 150 70
thanx
2 Replies
Nov 17, 2014 6:25 am
In order to use the picked object, you need to create a variable so you can access it from other functions, events, etc. In the following example the picked object is stored in the local variable ‘obj’:
rollout RO_TEST "" width:156 height:80
(
pickbutton bt_pick "Pick" pos:[8,7] width:140 height:33
button bt_copy "Copy" pos:[8,40] width:140 height:32 enabled:false
local obj
on bt_pick picked arg do
(
if arg != undefined do
(
obj = arg
bt_copy.enabled = true
bt_pick.caption = obj.name
)
)
on bt_copy pressed do
(
if obj != undefined do
(
if not isdeleted obj then
(
maxops.clonenodes obj cloneType:#copy newnodes:&copied
msg = "Object was copied.
" + "\"" + copied[1].name + "\""
messagebox msg
)else(
messagebox "Object was deleted."
obj = undefined
bt_pick.caption = "Pick"
bt_copy.enabled = false
)
)
)
)
createDialog RO_TEST
PD: Please make sure you wrap your code between code tags when posting so it is easy to read and copy.
There is a button to do that in the message editor.
"#" "Wrap
tags around selected text"