Notifications
Clear all

[Closed] script_questions

hi evreybody,
i have no experince in max script,i’m a rigger but need some script items,
the questions are:
how to make a button that when it’s pressed do hide objects or unhide them,
how to make a button that when it’s pressed do key object in the scene,
and like this stuff…
i know how can i make these keys in UI but donno how to make them in rollout of an object
and store them in the rollout.

i was wondering if you guys could explain me how to do them,
any help would be welcome.

E.K

3 Replies

You need a 2 things. First, a rollut definition, and second, a collection of data, in the first case an array of objects.

MAXScript has a handy tool called the “Visual Maxscript Editor”. You can call it up like this:

Create a new maxscript. In the top menu of the maxscript editor, select Edit–>New Rollout.

This will bring up the editor. This editor allows you to add UI elements like buttons, spinners, color pickers, timers, drop down lists, etc. You can place them in the rollout, adjust all the properties, and then when you have something you like, click File–>Save. This will automatically spit out the code for the rollout definition. If you later want to edit it, put the mouse curser somewhere within the definition, and click Edit–>Edit Rollout to bring the dialog back up.

So lets start with a basic setup. Copy and paste the following code into a new mascript:


rollout RO_Test "Hide Objects" width:160 height:64
(
	checkButton ckb_1 "Hide Selected" pos:[8,8] width:144 height:48 --adds a check button
	
	local objs --We make a local variable to hold the objects being processed
	
	--this is an event handler, which runs code when a UI element
	--is being interacted with. Note that "state" refers to whether the checkbutton
	--is on or off. So if the it's on then we get the selection of objects as an array
	--then for each object in the array, we set it's isHidden property to true.
	--If the button is off, then we unhide the objects stored in the array.
	
	on ckb_1 changed state do 
	(
		if(state == on) then
		(
			objs = ($selection as array)
		
			for i in objs do
			(
				i.isHidden = true
			)
		)
		else
		(
			for i in objs do
			(
				i.isHidden = false
			)
		)
	)
)

--this line creates the dialog box we defined. To get rid of if it
--you can use destroyDialog RO_Test
createDialog RO_Test	

That should get you started.

-Dave

hey dave, realy thanks
you solved my problem,it works raly good,thanks alot.

hi dave,
sorry,have another request
if i want to make code for keys,
do i have to write the code like that you said above?
with ADDNEWKEYS?
or something else,should i do?

thanks
E.K