Max Script help - multi object selection to pickbutton


#1

Very new to scripting and trying to work out a marker file for a script that I need to pass some variables to.

I would like to use a pickbutton function to choose multiple objects, error check to insure the selections are geo and ideally update the pickbutton to show multiple selection or is there a better way?

I like having to click then have the ability to start selecting but not sure how to make this work. Then ofcourse pass them as an array to the script but what I have now is a mess and not sure how to fix this. My current marker file script is below :banghead:

global _pickOBJs = #()
try (destroydialog _GD1) catch()
rollout _RT1 “Rock Tool”
(
pickbutton _pickOBJ “Pick OBJ” autoDisplay:true tooltip:“Start Picking!..”
on _pickOBJs picked obj do
(
_PickOBJs = SelectByName() fn geo_filter obj = isKindOf obj Geometry showHidden:false
)
button _Go “Go”
on _Go pressed do
(
include @"<path to script file here"
FXRock _PickOBJs.object
)
)
createdialog _RockFX

Thanks in advance for the help!


#2

I am stuck Any ideas on how to make this work?


#3

use checkbutton and pickobject instead of using pickbutton. see mxs help for details

try(destroydialog pickObjectsRol) catch()
rollout pickObjectsRol "" width:200
(
	checkbutton pick_nodes_bt "Pick Nodes" width:180
	local nodes = #()
	on pick_nodes_bt changed state do
	(
		if state do
		(
			pick_nodes_bt.enabled = off
			nodes = #()
			while isvalidnode (obj = pickObject()) do appendifunique nodes obj
			format ">> %
" nodes
				
			pick_nodes_bt.enabled = on
			pick_nodes_bt.checked = off
		)
	)
)
createdialog pickObjectsRol

#4

This makes sense but is there a way to display the selection as the objects are clicked? That is what was nice about pickbutton is the object selected would display when clicked. I know there is the option rubberband to show bounding box for the pickObject() function but how about a display on the button itself of current selections? Also with this the focus is difficult to set to allow “H” to bring up a list option and select more then one object.

The next option is I would like to keep the “Go” option button click to cancel the selection phase and parse the selected objects into the next script. Currently have to right click to cancel the multi-selection and clicking off the pickbutton does not work.

Thanks for the help…


#5

#1 you probably should read the mxs help’s part about PickObject more carefully. There is a #select option for this method.

#2 you can set any text for ‘custom pick button’(checkbutton) every time you pick an object

#3 as you can see in my code i’m disabling checkbutton on time of picking nodes. If you want to end picking process using OFF of this button, just keep this button enabled, and use its state in the ‘while’ loop.