1
$\begingroup$

While making a new script I need to import modules from another script

I am developing the script inside Blenders "scripting workspace"

from sys import path
path.append(bpy.path.abspath("//")+'K://path/to the folder/that/has-the-script')
from Script import add_plane_mesh

Ends up in error

ModuleNotFoundError: No module named 'Script'

How to fix this?

$\endgroup$

1 Answer 1

1
$\begingroup$

I don't think you want to append the abspath of the current blend file to the full path of the script folder.

Try this instead: (Note the use of 'r' as prefix to the path, so that the backslash characters are not treated as string escapes.)

import bpy
from sys import path
path.append(r'K:\path\to the folder\that\has-the-script')
from Script import add_plane_mesh
$\endgroup$
5
  • $\begingroup$ Seems to be working.... Now need to learn how to execute the script I imported. Thanks for the help.. Just for me to know. I have a script (lets call it script1) that runs on its own. When running it places a cube in the model. The script I import is "script1" Is it possible when running the new script to "execute" script1 and draw the cube? $\endgroup$
    – cecevo
    Dec 18, 2021 at 10:02
  • $\begingroup$ The cleanest way to do this would be to put the script's code inside a function, and then call the function when you want to draw the cube. $\endgroup$ Dec 18, 2021 at 17:07
  • $\begingroup$ Thanks Marty for helping me out!! Appreciate it $\endgroup$
    – cecevo
    Dec 18, 2021 at 17:12
  • $\begingroup$ You're welcome. Enjoy Blender Python programming. $\endgroup$ Dec 18, 2021 at 17:39
  • $\begingroup$ Thanks Marty. you 2 $\endgroup$
    – cecevo
    Dec 18, 2021 at 17:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .