Notifications
Clear all

[Closed] Python and PyQt in 3dsMax

Yeah, you can definitely develop a way to have things work inside/outside of max. You don’t NEED to use a Dialog vs. a QDialog, you can see the things I’ve sublcassed in the blur.wingui.Dialog module, but mostly its a way to handle some of the 3dsMax hotkey disabling (which I still need to improve anyway…)

Easiest way to know is to just try/catch an import of mxs


  mxs = None
 try:
 	from Py3dsMax  import mxs	 # will work if inside of max
 	from blur.wingui import Dialog  # use the maxscript one
 except:
 	from PyQt4.QtGui import QDialog as Dialog  # bring in a standard one for external tools
 
 from PyQt4.QtGui import QLineEdit
 
 class MyDialog( Dialog ):
 	def __init__( self, parent = None ):
 		  Dialog.__init__( self, parent )
 		  
 		  self.resize( 400, 100 )
 		  
 		  self._filename = ''
 		  if ( mxs ):
 			 self._filename = mxs.maxFilePath + mxs.maxFileName
 
 		  edit = QLineEdit( self )
 		  edit.setText( self._filename )
 
 if ( mxs ):
 	MyDialog().show()
 else:
 	# For external apps, need to instance a QApplication manually
 	from PyQt4.QtGui import QApplication
 	app = QApplication([])
 	dialog = MyDialog()
 	dialog.show()
 	app.exec_()
  

Also – the reason Python was shutting down on you while you were running that code is because there was no QApplication initialized.

I am managing all the QApplication instances and general Qt initialization inside of 3dsMax, but if you are going to develop code that’ll run inside and outside, you’ll need to include Qt initialization code – namely, you cannot create instances of any class from the QtGui package before you initialize a QApplication, and you can only run 1 QApplication instance.

The one that runs from the blur.wingui plugin can be accessed by calling


 blur.wingui.app		# QApplication Instance
 blur.wingui.core	   # QWinWidget Instance that is the parent widget of all QWidgets in max
 blur.wingui.logger	 # The 3dsMax python logger window
 blur.wingui.progress  # multi progress bar widget
 

I can’t tell you how grateful I am for this plugin. I have started building a sophisticated plugin and I am so happy that I can do it in Python! It arrived exactly at the right moment!

Thanks!

I can’t wait to finally work with python in max, but i’m running into some issues. Has anyone gotten this to work for max 2009 xp 32 bit? I’m only getting the “BlurPython has not been loaded” error on startup. I don’t see the BlurPython24.dlx in the plugin manager either.

1 Reply
(@ehulser)
Joined: 11 months ago

Posts: 0

You may be loading your plugin.ini differently than what is expected. In 3dsMax 2008+ they changed their user plugin location to your documents & settings folder, if you hunt around for your plugin.ini, you should be able to add under [DIRECTORIES] blur=.\plugins\blur and it should work.

How do you specify flags in a function call, like ‘#select’ in the following call?

mergeMAXFile “test.max” #select

1 Reply
(@ypuech)
Joined: 11 months ago

Posts: 0

This problem was solved by Eric creating a new function called namify():
http://forums.cgsociety.org/showpost.php?p=6163215&postcount=31

Ah, thanks! I hadn’t seen this.

What would be the way to call a max command like

[left]max zoomext sel
[/left]
[left]

[/left]
[left]I tried various ways which seemed more or less logical, but none worked.

[/left]

I think the easiest way is:

python.exec("mxs.execute('max zoomext sel')")
1 Reply
(@mschmeling)
Joined: 10 months ago

Posts: 0

Duh… I didn’t know there was an ‘mxs.execute’ function… I don’t know MAXScript that well… Thanks.

Bevore i dive into it for no reason, is there any way to do scripted plugins/object types already ?

Regards,
Thorsten

I’m holding my breath for a 2010 build.

I’m turning blue!

Page 8 / 17