architecture-building-systems / revitpythonshell

An IronPython scripting environment for Autodesk Revit and Vasari
MIT License
494 stars 113 forks source link

Add script directory to sys.path #28

Closed eirannejad closed 6 years ago

eirannejad commented 8 years ago

It'll be great if the directory containing the script is added to the sys.path before running the script so the script can load external libraries without manually adding this to the sys.path.

daren-thomas commented 8 years ago

This is a brilliant idea! It should definitely apply to external scripts - and probably also to the location of the assembly for rpsaddin scripts!

Why didn't I think of this before? I guess I just assumed you'd use the "Search Paths" functionality in the configuration dialog... That is also the point in the code that I would use to add the new code...

eirannejad commented 8 years ago

yeah that would be amazing if you can implement this.

eirannejad commented 6 years ago

Seems like this has already been implemented. See ScriptExecutor.cs/ExecuteScript()

// Add script directory address to sys search paths
var path = engine.GetSearchPaths();
path.Add(System.IO.Path.GetDirectoryName(sourcePath));
engine.SetSearchPaths(path);
daren-thomas commented 6 years ago

Oh. Well. Maybe I built a time machine or something? Anyway. Closing :-)