7
$\begingroup$

Is import another_blender_text_block possible in Blender with Python?

$\endgroup$
8
$\begingroup$

Yes it is possible. Name your text block (with .py on the end, otherwise you can't import it). You can import a text block using the text block's name without it's extension:

import mypythonfile

Then to run a function use:

mypythonfile.functionname()
| improve this answer | |
$\endgroup$
  • $\begingroup$ You mean blend file filename? It says No module named 'texttest' $\endgroup$ – kivig Nov 30 '13 at 15:50
  • $\begingroup$ @kivig no, the python file name (without it's extension). $\endgroup$ – CharlesL Nov 30 '13 at 15:53
  • $\begingroup$ I might have explained the point poorly - I want to run a script from a text block, that imports another textblock of the same blend file. Is that possible? $\endgroup$ – kivig Nov 30 '13 at 16:23
  • $\begingroup$ Hmm... it works for me. Does your first text block (the one your importing) have .py on the end? $\endgroup$ – CharlesL Nov 30 '13 at 16:28
  • 1
    $\begingroup$ @kivig exactly, but you still need to name the text block with .py on the end. $\endgroup$ – CharlesL Nov 30 '13 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.