gui help

I want to create a GUI that is basically a ton of buttons with different images, where each button runs a command who's name is based on the names of other scripts i have.

First, I don't know how to house all the buttons on a grid so that there is a scroll bar if need be.

Second, I want the buttons to be created depending on the files in my script folder. Each button will run a script in my script folder.

In summary, the buttons need to be generated, but I don't know how to procedurally create buttons, their names, and what they do (even though all that info is given by the title of the files in the script folder.)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barigazy's picture

yep, without code we are

yep, without code we are chasing ghosts here.
Post the code or snippet if you know where is the problem if you want any help.That is the simple rule

bga

roosterMAP's picture

Here is what I got for my

Here is what I got for my script. I just need to make the bitmap update. Iv tried the whole "create ui refresh within the rollout... but i kept getting errors.

(
	--_greebles.ms cannot be bigger than 700KB
 
	Global String finalString = "blank"
	Global String displayImage = "C:\Program Files\Autodesk\3ds Max 2011\plugins\greebles\images\ " + finalString + ".jpg"
	myFiles = getFiles "C:\Program Files\Autodesk\3ds Max 2011\plugins\greebles\\*.ms"
	folder = "C:\Program Files\Autodesk\3ds Max 2011\plugins\greebles"
	displayImage = replace displayImage 64 1 ""
	print displayImage
	--displayImage = bitmap 300 300 
	--display displayImage
 
	rollout gpGUI "Greebles Placment GUI" width:1024 height:1500
	(
		bitmap templateBmp fileName: displayImage
		checkbox autoGrid "AutoGrid" pos:[10,60]
		listbox greeblesListBox "Greebles:" items:(myFiles) pos:[0, 400] selection:1 height:50 readOnly:false
		button startCreate "GO!"
 
		on autoGrid changed theState do
		(
			actionMan.executeAction 0 "40462"  -- Views: AutoGrid
		)
 
		on greeblesListBox selected nameIndex do
		(
			--run command
			s = myFiles[nameIndex]
			s_temp = replace s (s.count-11) 12 ""
			s = replace s_temp 1 56 ""
			finalString = s
			reloadGUI()
		)
 
		on startCreate pressed do
			(
				execute ("StartObjectCreation " + finalString)
			)
	)
	createdialog gpGUI width: 1024 height:1024 --run template
 
	fn reloadGUI =
	(
		createdialog gpGUI width: 1024 height:1024 --run template
	)
)
barigazy's picture

?

Can you describe step by step again what exactley you want to achive
with this tool. I fix a code a little but i don't know why do you need this size of UI. The code:

(
	--_greebles.ms cannot be bigger than 700KB
	local folder = @"C:\Program Files\Autodesk\3ds Max 2011\plugins\greebles"
	local finalString = "blank"
	local displayImage = folder + "\\" + finalString + ".jpg"
	local myFiles = getFiles (folder+"\\*.ms")
 
	local displayImage = replace displayImage 64 1 ""
	print displayImage
	--displayImage = bitmap 300 300 
	--display displayImage
 
	rollout gpGUI "Greebles Placment GUI" width:1024 height:1500
	(
		bitmap templateBmp fileName:displayImage
		checkbox autoGrid "AutoGrid" pos:[10,60]
		listbox greeblesListBox "Greebles:" items:(myFiles) pos:[0,400] selection:1 height:50
		button startCreate "GO!"
 
		on autoGrid changed state do maxOps.autoGrid = state --AutoGrid
 		on greeblesListBox selected nameIndex do
		(
			--run command
			local s = myFiles[nameIndex]
			s_temp = replace s (s.count-11) 12 ""
			s = replace s_temp 1 56 ""
			finalString = s
			reloadGUI()
		)
 		on startCreate pressed do (execute ("StartObjectCreation " + finalString))
	)
	createdialog gpGUI width: 1024 height:1024 --run template
 
	fn reloadGUI =
	(
		createdialog gpGUI width: 1024 height:1024 --run template
	)
)

bga

roosterMAP's picture

basically, i've converted a

basically, i've converted a bunch of my models into scripts. And I want to have this gui where i have a list of all these models in a list. I click on an object in the list and the bitmap updates to show me exactly what is being selected (i have a folder with one jpg per model).

now, when I select an object and press "go," and click and drag in the viewport, it will spawn and scale whichever model I have selected.

Right now, I have everything working except for the updating image.

barigazy's picture

And what about

And what about this

(
	--_greebles.ms cannot be bigger than 700KB
	local folder = @"C:\Program Files\Autodesk\3ds Max 2011\plugins\greebles"
	local finalString = "blank"
	local displayImage = folder + "\\" + finalString + ".jpg"
	local myFiles = getFiles (folder+"\\*.ms")
	local displayImage = replace displayImage 64 1 ""
 
	rollout gpGUI "Greebles Placment GUI" width:1024 height:1500
	(
		bitmap templateBmp fileName:displayImage
		checkbox autoGrid "AutoGrid" pos:[10,60]
		listbox greeblesListBox "Greebles:" items:(myFiles) pos:[0,400] selection:1 height:50
		button startCreate "GO!"
 
		on autoGrid changed state do maxOps.autoGrid = state --AutoGrid
 		on greeblesListBox selected nameIndex do
		(
			--run command
			local s = myFiles[nameIndex]
			s_temp = replace s (s.count-11) 12 ""
			s = replace s_temp 1 56 ""
			finalString = templateBmp.filename = s
		)
 		on startCreate pressed do (execute ("StartObjectCreation " + finalString))
	)
	createdialog gpGUI width: 1024 height:1024 --run template
)

bga

MKlejnowski's picture

why not nest the local

why not nest the local variables into the actual rollout and set them with the rollout "open" event handler? Wouldn't that remove the need to nest the code in brackets?

barigazy's picture

It is the same.I always place

It is the same.I always place locls / globals at the top for the clality. The bruckets can be used later if the user decide to create macroscript.
By the way, all scripters has a different style,but if everyone used the same pattern, then the MXS and other languaes would not be much interesting. Agreed!

:)

bga

roosterMAP's picture

Bitmap still not updating. I

Bitmap still not updating. I made a few changes to ur code (nothing substantial), but the bitmap is still stuck at C:\Program Files\Autodesk\3ds Max 2011\plugins\greebles\blank.jpg

Is there a command to redraw the bitmap with a new given filename?

(
	--_greebles.ms cannot be bigger than 700KB
	local folder = @"C:\Program Files\Autodesk\3ds Max 2011\plugins\greebles"
	local finalString = "blank"
	local displayImage = folder + "\\" + finalString + ".jpg"
	local myFiles = getFiles (folder+"\\*.ms")
 
	rollout gpGUI "Greebles Placment GUI" width:1024 height:500
	(
		bitmap templateBmp fileName:displayImage
		checkbox autoGrid "AutoGrid" pos:[10,60]
		button startCreate "GO!" pos:[10,100] width:50 height:50
		listbox greeblesListBox "Greebles:" items:(myFiles) pos:[12,328] selection:1 height:50
 
		on autoGrid changed state do maxOps.autoGrid = state --AutoGrid
 		on greeblesListBox selected nameIndex do
		(
			--run command
			local s = myFiles[nameIndex]
			s_temp = replace s (s.count-11) 12 ""
			s = replace s_temp 1 56 ""
			finalString = templateBmp.filename = s
		)
 		on startCreate pressed do (execute ("StartObjectCreation " + finalString))
	)
	createdialog gpGUI width: 1024 height:1024 --run template
)
barigazy's picture

The problem must be string

The problem must be string path
Try this
above line *finalString = templateBmp.filename = s*
put this

format "pathstring = %\n" s

and see what Listener throw.
Is path is correct than try another trick
above line *finalString = templateBmp.filename = s*
put this line

 
templateBmp.filename = undefined

This will remove current bitmap file and next line will be add new one.
And if all of that not help then the problem is map resolution for sure.

bga

roosterMAP's picture

Now it works. It was the path

Now it works. It was the path string that was wrong.

The problem was the line where you reinitialize finalString.

I just replaced it with the following:

finalString = templateBmp.filename = folder + "\\" + s + ".jpg"

Now it works.

Thx so much for all ur help! Still learnin. :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.