Notifications
Clear all

[Closed] Adding UI elements after rollout is created?

Hi,

I want to create a button or any ui element after rollout creation within same rollout.

 rollout test "Test" 
(
 
button b1 "Button 1"
 
on button b1 pressed do ( button b2 "Button 2" )   -- how can I achive this?
 
)
createdialog test 200 200

if it is not possible with maxscript then any idea of using dotnet?

8 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

you can’t directly add new control to already created rollout but as usually it might be a workaround…
one of that is to use subrollouts… you can add and remove subrollouts from existent rollout, and you can create new subrollouts on fly with any set of controls.

I’ve never got the chance to try it, but you should take a look at “RolloutCreator Functions” in MaxScript Reference. It should provide what you need.

  • Enrico

the rollout creator essentially generates a script that executes creating a whole new rollout.

Maxscript does not have the ability to create UI elements on the fly, its a parser based compilation, and its really annoying.

We got around it by re-creating the UI everytime we needed a change, but it is not the most efficient and is cumbersome. If you are using DotNet in maxscript, you’ll still run into that problem because your still creating rollout controls. If you’re using DotNet in a C++ application, it probably can be done.

This is one of the reasons we looked into integrating Python & PyQt into 3dsMax, was to be able to build more robust user interfaces. Qt is a powerful C++ programming framework with a very, very strong GUI core, PyQt is the python wrapper for it.

I don’t know what your needs are specifically, so that may be more than you’re really wanting to deal with, but you can read more about it on this thread:

http://forums.cgsociety.org/showthread.php?f=98&t=816475

For more information on everything, we’ve setup a lot of tutorials and walkthroughs to get you started at:

http://blur-dev.googlecode.com/

An example of adding items on the fly (python code) – I know this might seem like a lot and quite overwhelming, but its actually very, very quick to pick up – you’d be surprised (this also handles all the resizing and layout and organization etc.)


 
 from Py3dsMax		import mxs			  # Import maxscript as a python module
 from blur.wingui		import Dialog			  # Import a PyQt QDialog setup for 3dsMax
 from PyQt4.QtCore	import SIGNAL			# Qt way to map widget signals to methods
 from PyQt4.QtGui	import QPushButton		# Push button class
 from PyQt4.QtGui	import QVBoxLayout		# Resizable layout
 
 # Subclass the dialog to make my own one
 class MyDialog( Dialog ):
 	def __init__( self ):
 		""" Constructor Method """
 		Dialog.__init__( self )
 		
 		layout = QVBoxLayout()
 			
 		# Add button #1
 		button = QPushButton( self )
 		button.setText( "Add a Button" )
 			
 		# Connect the button's clicked signal
 		self.connect( button, SIGNAL( 'clicked()' ), self.addButton )
 		
 		layout.addWidget( button )
 		self.setLayout( layout )
 					
 	def addButton( self ):
 		""" Create a new button in the interface """
 		button = QPushButton( self )
 		button.setText( 'A New Button' )
 		self.layout().addWidget( button )
 
 MyDialog().show()
 
   

AFAIK, you can add controls to a windows form created with .NET, and some .NET controls have a “controls” property that let you add other controls to it, like the FlowLayoutPanel.

Hi everyone, thanks for your suggetions, I am going with python way…

ehulser: I am vary inspired by Python/PyQt and the abilities it has, have been thinking to use it but you get me started I am deffinetly going with it.

Thanks for the code, is there any Installation instruction page available on your site? I don’t know what exactly i need to install to get started with PyQt.

also when I go to python site to find 2.6 x64 installer, I didnt find it, they have x86 installer and AMD64 installer, can I use the AMD64 installer for my intel machine?

Thanks again for wonderful Python integration with max.
Ravi

@ bkravi

i’d definitely recommend the python way personally, though it is very new still, so we’re still ironing out the kinks.

All installation instructions you’ll need are on:

http://code.google.com/p/blur-dev/wiki/BlurCore

From there you can also go to the rest of the wiki for help on installing the Py3dsMax system and view tutorials to bridge the gap between maxscript and python.

The AMD64 installer is the standard Python 2.6 x64, thats the one we use as well.

Good luck! Let me know if you have any questions or run into any problems

you can use dotnet form

Thanks ehulser, I hope this will be vary amazing ride.