I am trying to use a text block from within the same Blender file, following the (rather old) advice here: Python: is it possible to import another text block?

So I have two text blocks. One called Text and one called printy.py which contains the simplest of functions:

def printthing(): print('thing')

In 'Text', all it says is:

import bpy import printy printy.printthing()

I've saved and reopened the file. But I get: ModuleNotFoundError: No module named 'printy'

This seems laughably simple and I've seen the approach in a several places, e.g. Blender 2.80: Helper Modules but I can't make it work.

What am I missing?

  • $\begingroup$ Might not be a duplicate if desired result is the scripts registered per specific file automatically on loading the file. @edna, is this what you are asking? $\endgroup$ – Martynas Žiemys May 27 '19 at 5:16
  • $\begingroup$ @MartinZ In that case, maybe an older build will suit the need. Could wait for the change: developer.blender.org/… $\endgroup$ – HikariTW May 27 '19 at 5:43
  • $\begingroup$ @Hikariztw, I think I just misunderstood the question and you are right - it seems to be a duplicate. $\endgroup$ – Martynas Žiemys May 27 '19 at 6:49

Browse other questions tagged or ask your own question.