What should I do if I have two instances of 3ds max launched, I want to control one of them with python and choose which one? Right now only max that was started first works as COM Server.
I just finished up the first version of this DLL for 3dsMax (still pretty rough) that we’re going to start using here at Blur…pretty much it embeds python for use inside of MAXScript, opening up all the modules that exist in python directly. There are some example scripts on how its used, but its relatively simple - you import your module, and work with with it as if you were in python.
re = python.import “re”
m = re.match “[a-zA-Z]*” “Test test test”
if ( m != undefined ) then ( print (m.group()) ) – prints “Test”
More examples in the DLL. We’re working (still) on getting BlurBeta running where everything will be open source, but until that gets up, I have the *.zip file with the DLL and would love some feedback on how its working, just no where to throw the zip. If anyone has a mirror, I can email the file to you and upload it so others can download. Otherwise, email me if you want the DLL and I’ll send it to you.
That is pretty cool! I can wait for your final release but if that is out, make sure to let us know! Directly connecting Python to MAXScript will make a bunch of people very happy over here.
Being able to use Python inside Max is a great new stuff and will make me learn Python much faster!
You can contact David Baker of maxplugins.de (he is on CGtalk forums). He can offer a subdomain with space to host your plugins and web stuff for free.
Not sure if this is going to create a double post, if so please delete.
There is now a link to the Python plugin from Blur Studios on my site at http://paulneale.com/
It is the second news article currently on the home page.
Thanks a lot for hosting it Paul, hopefully you guys will find it useful.
I’ll keep everyone posted on updates, please let me know of any bugs/issues, and I’ll also keep everyone up to date on the BlurBeta status
Thanks for creating it and thanks to Blur for allowing you to share it. Once you have BLur Beta back up and running let me know and I will pull it down from my site and link up to Blur Beta. Just email me updates and I will try and get them up there right away.
Thanks Eric and Paul.
If I understand, the goal of this DLX is to baccess Python modules in MAXScript like the dotNet wrapper that allow the use of .NET Framework. We’ll be able to also access our own Python modules and we’ll develop even more powerful tools.
So I have to learn Python now…
this is awesome. Thanks Eric and Paul! Im sure this will make many, many people happy
So I have to learn Python now…
you say that like it’s a bad thing
I know that I have to learn Python to improve my skills because as I want to work in a real 3D production environment in the future, Python is mandatory now.
Don’t worry, there’s no problem with learning a new language but I know that Python is a large development framework and there’s many interesting things to learn.
WOW… amazing… Loving it… WOW again… sooo easy… soo sweet…
Can not thank you enough…
Thank you, ehulser ,for sharing your blurPython.dlx. It seems to be a great tool. Maybe, you can help me with situation I’m having. I did all steps neccessary according to the read me file from plugin package. Command, python.import works for “sys” module but anything else returns undefined value.
Another question would be about 3dsmax COM/DCOM server and win32com.
It works just fine and it would be great if there is any possibility of getting progID of each max instance running. Do you know how to obtain it ?
cgBartosz - do you have an example of what was not working? I’m thinking it might be related to a problem I noticed recently - the way MAXScript passes variables back and forth between script and C++ is through the Name class instance, which is case insensitive. Which means, the first instance of a name created is the one stored, and since Python is case sensitive, this causes a problem. So, something like:
sys = python.import “sys”
sys.Path – would cause an error, because the path variable is all lowercase
sys.path – will still cause an error, because Max’s internal conversion already has the
– name value as an uppercase p
I’ve gotten around this in a newer version of the plugin, which I’m going to send to Paul to host, but could explain some discrepencies when accessing information. In terms of importing though, that should be case sensitive since it is string values and not names. If you send me an example I can look through it.
Also, some of the examples I had in the python zip about strings are apparently deprecated in python now (thanks to Keith Morrison for pointing this out):
ref: The following list of functions are also defined as methods of string and Unicode objects; see ``String Methods’’ (section 3.6.1) for more information on those. You should consider these functions as deprecated, although they will not be removed until Python 3.0.
So, just be wary of Python changes when building tools reliant on Python modules.
Importing “sys” module works, and importing “os” module returns an undefined value.
This is what I get in the listener after evaluating regex.ms sample script
undefined undefined -- Error occurred in anonymous codeblock -- Frame: -- split: undefined -- normpath: undefined -- splitList: undefined -- newnorm: undefined -- Unknown property: "path" in undefined print os undefined undefined print str undefined undefined
… conversation with listener
python.import "sys" <module 'sys' (built-in)> print sys.version "2.4.3 (#69, Jul 13 2006, 15:36:15) [MSC v.1400 32 bit (Intel)]" "2.4.3 (#69, Jul 13 2006, 15:36:15) [MSC v.1400 32 bit (Intel)]" ['C:\\Python25', '', 'E:\\3dsmax9'] ['C:\\Python25', '', 'E:\\3dsmax9'] <module 'sys' (built-in)> <module 'sys' (built-in)> global os = python.import "os" undefined global str = python.import "string" undefined python.import "os" undefined
from python interpreter…
IDLE 1.2.1 >>> import sys >>> print sys.path ['C:\\Python25\\Lib\\idlelib', ... 'C:\\Python25\\lib\\site-packages\\'] >>> print sys.version 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] >>>
Could someone do something reeeaalllly basic for me?
I see a lot of Python -> Max stuff. But how do I make the round trip? I’m still trying to wrap my mind around a “hello world” script.
I want to send data from max. Let’s just say an array.
[1,2,3] -> OLE -> Python. Have Python add 1 to each value and then reload it in Max.
What does that code look like?
Thats weird, I haven’t run into that. Has anyone else? Try just running this in your listener and see if it returns undefined:
os = python.import "os"
I get back the os module, from which I can run path functions, etc.:
os = python.import "os" <module 'os' from 'C:\python24\Lib\os.pyc'> os.path.split <function split at 0x10303BB0>
Not exactly sure where you are going with this/why you’d need it - if the idea is that you’d have an external python library to manipulate data that you want supply from max and get it back, it’d go like:
def plusone( valueList ): for value in valueList: value += 1 return valueLIst
pymodule = python.import "pymodule" arr = #( 1,2,3 ) arr2 = pymodule.plusone( arr ) print arr2
----- Result of Print ---------
Also, what version of Python do you have? Make sure that you can import the os module in Python itself - you can only import modules that exist within your Python install
ehulser, I got the update, I will post it as soon as I’m back to my office.
Fun with new python plugin.
In a startup script; initalize oddly named python and DotNet controls and data classes.
Write short script with simple UI with dotnet / MSX elements, data storage and malipulation using Dotnet data classes, python file access and MaxScript for Node access. Written with minimal line documentation.
Hand to co-worker asking what’s wrong… ha ha ha…