why is my python function not working?

why is my python function not working?

Anonymous
Not applicable
1,069 Views
5 Replies
Message 1 of 6

why is my python function not working?

Anonymous
Not applicable

i want to create object using python in 3ds max . just to create a simple default size box  i need to write this long code each time i create an object.

obj = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.Box)

node = MaxPlus.Factory.CreateNode(obj)

ughhh....

so i tried to make a function :

 

import MaxPlus

def create(geo):
       obj = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.geo)
       node = MaxPlus.Factory.CreateNode(obj)

 

create("Box")

 

--result

Traceback (most recent call last):
File "<input>", line 2, in <create>
AttributeError: type object 'ClassIds' has no attribute 'geo'

 

unfortunately this  didn't work.maxPython.JPG

 

i dont know why . 

Is there any way to create object so i dont need to write these long lines of code each time? Thank in advance. 

0 Likes
1,070 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

Try this...

import MaxPlus
def create(geo):

    obj = MaxPlus.Factory.CreateGeomObject(eval("MaxPlus.ClassIds.%s" %geo))
    node = MaxPlus.Factory.CreateNode(obj)

create("Box")
Message 3 of 6

Anonymous
Not applicable

Thank you. Yes this works fine. i was quite dumb hahaha. Can i ask if you have  some experiences working with python inside 3ds max ? I'm wondering  if python is as powerful as maxscript inside 3ds max.

0 Likes
Message 4 of 6

Anonymous
Not applicable

My experience is very limited. I've just started to work with python in max an the lack of more documentation makes me struggle a lot.

I think maxscript is more straightfoward specially if you don't have access to pymxs library, like me. Because I have to create tools compatible with max 2016.

Anyway, I using it because python is a live powerful language but the thing that make me make this choice in the end is the posibility to use pyside to create UIs.

Anyway my current code is plagued of maxscript  snippet trying to overcomethe difficulties I have trying to do some things with python. Some because on my lack of knowledge of the implementation of python in max, some because the implemetation really has some limitations.

Message 5 of 6

Anonymous
Not applicable

Yes i was thinking the same thing. I wish python in max be as flexible as in maya and do some improvement in documentation

0 Likes
Message 6 of 6

Anonymous
Not applicable

I suposse pymxs is close to the idea of the maya implementation of python. But in the end the main issue I think is the main software. It's pretty old and the core is still the very same. At least that's the impression I get navigating for the code exposed in the sdk.  That, in my opinion, tax heavily any endeavor of develope for this platform.