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…
Hi,
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 ?
Thanks !
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.
http://docs.python.org/lib/node42.html
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?
I’m sure I posted a reply to this a few days ago, oh well…
Basically, I’ve not tried this under python, but have been investigating the possibility using Java. This is what I’ve found…
Max can talk to “OLE Auutomation Servers” … commonly known as COM servers…
So, in order to get this to work, you will need to create your own COM server, register it under windows and, using Max’s “OLE Client” functions, connect and communicate with it…
There is some sample code on the install disk, but you will also want to look up “OLE Client” and “Running the OLE Demo” for more info.
I hope this helps
Shane
cgBartosz:
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>
thatoneguy:
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:
pymodule.py:
def plusone( valueList ):
for value in valueList:
value += 1
return valueLIst
msscript.ms:
pymodule = python.import "pymodule"
arr = #( 1,2,3 )
arr2 = pymodule.plusone( arr )
print arr2
—– Result of Print ———
2
3
4
cgBartosz:
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.