I’m getting some wierd garbage collection errors when pairing python and max. So my script basically sends the “loadmaxfile” command with a file, max opens it, run a maxscript on it, and return a list of strings. then moves on to another file. simple enough right?
Well after about 3-4 files, max throws this wierd error:
“Unknown error occured during garbage collection. If you see this message frequently, restart max.” or something to that extent. I put the gc() in my maxscript hoping that would fix it, but no luck.
Am i not doing something here? My python stuff is pretty simple:
pyMax = win32com.client.Dispatch("MAX.Application.8")
pyMax._FlagAsMethod("loadMaxFile")
pyMax._FlagAsMethod("RenderItem")
...
for z in names:
print "Building object..."
newItem = item(z)
print "Object built, Loading into max..."
try:
pyMax.loadMaxFile("Z:\XXX" + z.replace("/", "\\"))
except pywintypes.com_error, e:
print e[1]
print "Rendering Item..."
renderedItems = []
try:
renderedItems = pyMax.RenderItem()
newItem.dbInsert(renderedItems)
except pywintypes.com_error, e:
print e[1]
print "Success, moving on..."
“item()” is a python object which does some DB stuff.
“RenderItem()” is the maxscript being run.
Thanks
I had a simular issue recently (not with the com bridge, but with max). I may be totally off the mark, but…it may have something to do with the inital heap settings for maxscript.
Go to Customize -> Preferences -> Maxscript (tab) and increase the maxscript memory to a larger amount…about 60-70meg should do the trick. Then try again.
At least you will know if it is a max issue or a com issue pretty quickly.
Also, play around the amount of memory as well till you find a setting you are comfortable with.
Hope it helps
Shane
Hi Brett,
I have a similar setup for keeping asset library’s in order, which essentially recursively goes through a library and updates the database where it needs to. I did notice that the machine I run it on has the max script heap size set to 128mb, so maybe Shane is on to something, I might try lowering the heap size and see what happens.
I’m interested to here how you go…
Cheers
Dave
ok, i set it to 128mb and it seemed to work pretty good. Due to some bugs with my script it will sometimes blow up max. But upping the heap size let me get through 12+ without issue which is way more than before. I will keep tweaking it and let you know what i find.
Thanks again
OK, so i removed the gc() call in my script and upped my heap to 256MB and its working much better now. Thanks for the help guys.
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.
Hey guys,
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”
etc.
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.
Thanks!
Eric Hulser
eric@blur.com
Tools Developer
Blur Studio
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.
Cheers!
– MartinB
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.
If you want I can put it on on http://paulneale.com , just mail it to
paul@paulneale.com
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!
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.