A little tricky workaround could be to get all the command history lines and pick the
last one that start with “Successfully read file” and ends with “.dxf”
Use the trigger to restart the script (when you open a new file).
Note that this script will always return the path of the last .dxf file opened… if, after that, you open a .somethingelse file it will still retrieve the path of the last .dxf file.
From here it should be not complex to add rules inside the script.
Tell if you need help.
Code:
private void RunScript(object x, ref object Path)
{
// Getting Command History text
string text = Rhino.RhinoApp.CommandHistoryWindowText;
// Splitting into array of lists
string[] results = text.Split(new [] { '\r', '\n' });
string path = null;
foreach(string s in results){
// Checking if the current command-line is the opening of a dxf file
if(s.StartsWith("Successfully read file \"") && s.EndsWith(".dxf\"")){
path = s;
// Removing first characters
path = path.Remove(0, 24);
// Removing last character
path = path.Remove(path.Length - 1, 1);
}
}
Path = path;
}