If a user had opened a none Rhino file (eg a stp file)
The filename is displayed in the window title:
How would I retrieve the info on the imported file.
IS that available through RhinoCommon or should I just grab that title somehow ( if so does anybody know how)
Hi @Willem, one way would be to grab the required info from the command line after the file has been opened (or imported). A similar question has been answered here.
Note that Rhino 6 seems to have a different string in the command line than the one shown in the example linked above.
Another way would be to get the title from the process id. Below was tested with Rhino 6, with only one open instance:
import System
from System.Diagnostics import Process
try:
proc = Process.GetCurrentProcess()
title = Process.GetProcessById(proc.Id).MainWindowTitle
text = title.Split()[0]
except:
text = None
print text
Your script did not work, after some checking I got a working setup:
Yours did not get the title for some reason. I found I can grab the title directly from the proc in your script
import System
try:
title = System.Diagnostics.Process.GetCurrentProcess().MainWindowTitle
text = title.Split()[0]
except:
text = None
print text
Hi @Willem, hm, just checked and above first snippet seems to work over here. But your change is also working well. It should be noted that for an unsaved doc without having opened a non 3dm file, the title text returned is just “Rhinoceros”.