I have a 17 Gazillion lines text script in my .blend and i was wondering wether it is possible to create another text script in blender ( not from a file but integrated in blender ) that would contain the functions i use.
something like:
TEXT1:
import bpy
def MyAdd(a,b)
return(a+b)
and
TEXT2:
import bpy
import TEXT1
print(MyAdd(19,33))
Just like it is done in a C or C++ IDE…
Is it possible and if yes, how can it be done ?
Hi. I think I misunderstood what you originally wanted (I thought you wanted to dynamically create a second script). To access an existing secondary script, and get and run a function from it, you need to state the script as a module, so that it can be imported as a module.
Both of your questions have the same answer - they need to be imported somehow. In this case with as_module(). If you’d prefer to use abbreviations, I suggest making variable pointers. Like so:
I didn’t know this was this simple to do !
And from what i can remember, it is possible to list all functions in a module. Therefore, automate the suppression of ‘TEXT1’…
Raaah this looks great !
I don’t have time for now to try all this out but be sure i be back very soon with more questions @RPaladin