Notifications
Clear all

[Closed] Python and PyQt in 3dsMax

Thanks for the fix Eric!

ehulser,

I’ll remember your answer once I will be ready to get my hands on scripting stuff in max.
Just one more – how hard it is to learn Python? Is it comparable with learning C++ which is ultra hard for novices in scripting? Is it okay to start learning Python without prior knowledge of some older languages?

@kashak

Learning python is considerably easier than learning C++. Python is still a scripting language and C++ is a compiled language, so you don’t have to worry about type casting or memory management or a lot of the lower level programming issues that throw off novice scripters. The advantage of python though is that in comparison to say Javascript or Maxscript, its much faster and more powerful. Its also cross-platform and cross-application, learning python to script 3dsMax (especially learning it with PyQt), you will also learn to be able to build standalone applications really easily. That and most major 3d apps (now thanks to this plugin) support python scripting – (3dsMax, Maya, Softimage, Blender, Houdini, Real Flow). Learning maxscript only gets you knowledge useful in 3dsMax.

Python vs. Maxscript as languages is no contest, however, this is new technology, and has no real documentation – you will need to understand and be able to work with maxscript to understand how to get around some of the differences of developing python for 3dsMax until it becomes more mainstream.

There are python examples for python programming, and there are maxscript examples for 3dsMax, but short of whats on our blur-dev website, no python examples exist for 3dsMax.

@kashak
You will currenlty first have to learn maxscript before you can use PYTHON in max. But PYTHON is so cool and if you dont code at all i would dive into PYTHON!
There is a great DVD set on MAXSCRIPT at www.cg-academy.net which i can highly recommend! I a way the second DVD “Maxscript for the masses” could be a good starter!

I am still new to PYTHON too (i can work fine in Maxscript) and now i have to learn QT too…
If you want to learn PYTHON scripting in combination with 3D i would highly recommend Houdini or even Blender… but for sure currently not MAX.

 eek

Im pretty interested in this – i had just started learning c#, but as I can’t really interface with the max SDK natively (other than using Esphere’s tools) i’m sort of stuck what direction to go in.

So this is essentially the maxscript api in python form? Where by i can call built in functions, normalize?, sin(), abs() etc?

how does attribute.parameter stuff work? e.g. can i ask for an objects transform through python? its controllers? and there values?

A quick example of the pyQT would be awesome – i’m not really sure how that stuff works.

3 Replies
(@solitude)
Joined: 11 months ago

Posts: 0

Check out the code site – http://code.google.com/p/blur-dev/wiki/Py3dsMaxTutBasics – Eric added a bunch of really good starter tutorials for python and pyqt…
I think everything you just asked is already an example there… except for abs() and normalize() which would be mxs.abs(num) or mxs.normalize(mxs.Point3 Value) for abs, you don’t actually need to call it through mxs since it’s also built into python… and sin / cos would also be in the python math module… but you can call it through mxs if you want, so either way should be fine.

Controllers specifically read this page: http://code.google.com/p/blur-dev/wiki/Py3dsMaxTutDiffs goes over what does / doesn’t work…

 eek
(@eek)
Joined: 11 months ago

Posts: 0

Thats awesome, i’m basically building my functions to be as generic as possible, even up to the point of building my own matrix handlers, converters etc in certain places. If i can learn a language that I can take between apps that would be great. Some questions I have:

How does pyQT compare with C# winForms? GDI+ stuff? Is it just a method to build interfaces or can we do drawing stuff with it? more advanced stuff?

As to .net and c# can we build library and interface with them in maxPython and maxPyQt?

one other little question, max natively supports script controllers with maxscript, is there support for this with python? or some python script controller in the works?

Questions regarding the BlurDev:

Do we have to download and build the python source 2.4.6? From the documentationI was reading it as blurCore was an executable which would install the lot – python, Qt, PyQt, BlurLib & blurPython.

What exact files do we need to actually download from the downloads? I got confused as

theres ‘Blur Python X32(Python24)’ and ‘Python for 3ds Max 10 x32 (python24)’

(@solitude)
Joined: 11 months ago

Posts: 0

I’m not familiar with C# to be honest, Eric would be the one to answer this really, but so far pyqt is super easy to use, and is very powerful… You should really download it and check out the example scripts. There are all sorts of drawing classes, and even opengl classes – the Realflow gui for instance is made off of QT (not python) natively… though not sure if they’re using the qt opengl modules or not. http://doc.trolltech.com/4.5/classes.html <<list of qt classes

For install you need to download python from python.org (if you’re using 64bit max you download 2.6 x64, if you’re using 32bit max you download 2.4 32bit)… then d/l and install pretty much everything else according to the max version / python 64 or 32.

Right now there is no python script controller… though that’d be freakin’ sweet.

If you build a .net or c# library, you should still be able to call them from python via the mxs module, as you would via maxscript… or there are most likely other modules to access .net libraries from python (though I’m still a Noob, so I don’t know what they’d be called)

EDIT: For the Scripted Controllers – you can call python.X via maxscript, so in theory you can have a script controller call python, but I think you’d still be running in maxscript syntax, etc…

–Ian

Hi all,

About PyQt I have done some modifications in blur.wingui to integrate it better in 3ds Max.

I have added a function in blur.wingui to be able to apply 3ds Max icon to a Dialog or Window.

In blur.wingui init.py, add before connectPlugin() :

(Need pywin library)

from win32gui import FindWindow, GetClassLong, GetIconInfo
 from win32con import GCL_HICONSM
 
 def applyMaxIcon(widget):
    dialogHandle = FindWindow( None, str(widget.windowTitle()) )
    
    maxIcon = GetClassLong( core.parentWindow(), GCL_HICONSM )
    if maxIcon != None:
 	  iconInfo = GetIconInfo(maxIcon)
 	  pixmap = QPixmap.fromWinHBITMAP( iconInfo[4], QPixmap.NoAlpha )
 	  pixmap.setMask( QBitmap( QPixmap.fromWinHBITMAP( iconInfo[3], QPixmap.NoAlpha ) ) )
 	  widget.setWindowIcon( QIcon( pixmap ) )

And in blur.wingui Dialog.py and Window.py, at the end of the constructor add:

blur.wingui.applyMaxIcon( self )

Also, in blur.wingui init.py, in connectPlugin() function, I have changed the call to app.setStyle() to set Windows style:

app.setStyle( 'Windows' )
1 Reply
(@loocas)
Joined: 11 months ago

Posts: 0

I can’t get these to work for me here. I don’t know why, but once I modify the files you suggest, I get tons of errors and the blurPython module won’t work anymore within Max (it won’t even load up the first time).

But I’m not that skilled with Qt, so I might have done it improperly. Can you, please, share your files so I can compare?

Thanks a lot!

Great stuff everyone. Thanks alot to you guys this looks truely promising.

As a quick heads up for ppl installing it here’s an issue i ran into (@Erik: i also added this to the google issue tracker). The BlurQT installer wiped my systemwide path variable instead of appending the correct directory (wich caused other apps to malfunction too heh). After replacing it with the original + appending the right path all seems to work now.
As a sidenote on my system the path is NOT c:/blur/common wich doesnt exist at all but c:/windows/system32/blur64. This is also where the installer is placing all the DLLs.

Apropos DLLs. Will Some of your tools also be opensourced ? I’d definately like to take a look at sql integration and some other stuff i guessed from the libs

Kind Regards,
Thorsten

  • booking tickets to California to kiss everyone’s a$$ at blur for bringing this to the public *

:buttrock: :buttrock: :buttrock: :buttrock:

You rock guys, you always have! Thanks a lot for this pure awesomeness, I can’t wait to start testing this out.

I’ve been on a mission of bringing IronPython to Max, but if this works better, I’ll be totally thrilled and happy! :buttrock:

:bowdown:

 eek

Cool thats awesome!

As to the python download, 2.4.6 is only a source release and not a binary release – how do we build the source?

-c

Looks like we’re running 2.4.2 in the studio…
http://www.python.org/download/releases/2.4.2/

but 2.4.4 also has binary releases…
http://www.python.org/download/releases/2.4.4/

No idea if that .2 would make a huge difference ( I doubt it)

Page 4 / 17