I try to read the viewports from another file, but it doesn’t work perfectly.
It does read in the active viewports, but none of these new names, NOR any of the other views stored in the read file can be found either in NamedViews or in “View - Set View”.
Are there any workarounds to read in the views?
I try to import a file and have it act as if the file was “opened”.
Or can I open a Read Only file with out the “this is a read only file” warning.
Named views and viewports are not the same thing… There are both a view table and a named view table in the document… You can import named views from the named views panel… I don’t know yet how to import named views via scripting, though.
import scriptcontext
import rhinoscriptsyntax as rs
import Rhino
def TestImportNamedViews():
filename = rs.OpenFileName("Open", "Rhino 3D Models (*.3dm)|*.3dm||")
if filename:
f = Rhino.FileIO.File3dm.Read(filename)
if (f.NamedViews.Count > 0):
for vi in f.NamedViews:
scriptcontext.doc.NamedViews.Add(vi)
if __name__ == "__main__":
TestImportNamedViews() # Call the function defined above
This gave me the option to import instead of open the mini file, so I am now ready to pack up Holomark into one install file. Release Candidate here we come.
THANK YOU!