Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

using variables from a .py file

2 REPLIES 2
Reply
Message 1 of 3
houndman
283 Views, 2 Replies

using variables from a .py file

hello folks!

 

can somebody please enlighten me?

 

since 3dsmax is now shipped with python "support", i'm trying to use some global functions and variables from existing py-files which we are using for our pipeline.

 

i can't get this to work and since i'm only familiar with maxscript i'm wondering if i do something completely wrong....

 

lets say i have a lib.py file, containing several variables and functions i want to use,

for example var01, var02, function01 etc....

 

so in maxscript i use:

 

python.executefile "lib.py"    --->   results in "#success"

 

now i can call these functions and variables:

 

python.execute "print var01"  --->  results in "expectedValue" AND "#success

 

i'm also able to call functions:

 

python.execute "function01" ----> results in "expectedValue" AND "#success"

 

BUT

 

i want to further use these results in maxscript.... and i don't know how....

 

 

when i try to access the variables as usual (after executing the py file of course):

(like in MXS):

 

var01   it returns "undefined"

 

 

 

when i try to assign it as a "python function" like this:

 

myVariable = (python.execute "print var01") it results in "expectedValue" AND "#success"

 

so myVariable always contains "#success" but not the Value i actually wanted...

 

can someone clarify this, please ?

thx in advance

 

2 REPLIES 2
Message 2 of 3
Swordslayer
in reply to: houndman

There's a throwOnError:false argument which should do that but I couldn't spot a difference. If you are okay with parsing listener output yourself, that's another way:

 

(
	clearListener()
	python.Execute "print 'hello'" throwOnError:false
	local ls = listener as stringStream
	for i in i = -1/0. to -1/0. while not eof ls collect readLine ls
)

 

Message 3 of 3
jens.diemer
in reply to: Swordslayer

IMHO there should be a better python integration!

 

Vote here: http://3dsmaxfeedback.autodesk.com/forums/80701-sdk-and-scripting-enhancements/suggestions/6023730-b...

Jens

------------------------------------------------------------------------------------------------------------------
https://github.com/jedie/3dsmax_bugs | https://github.com/jedie/3dsmax_patches
Tags (1)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report