Hi, I’m trying to import a local module file that has a dependency into a main script in the script editor. Here is my main script:
#! python3
# env: /my/current/folder
# env: /my/python/environment
import rhinoscriptsyntax as rs
from ScriptFile import *
rs.AddPoint((1,2,3)) # works
works() # works
doesnt_work() # error: NameError: name 'rs' is not defined
Add import rhinoscriptsyntax as rs to the ScriptFile as well. The name rs is defined locally in the current scope. Your main script scope is different from the module scope. You would not expect a variable named my_sphere to show up and be accessible inside an imported module
Alternatively you can pass rs as an argument to the function but then that’s not common since rs does not change and can be statically accessible from many scopes