forked from mcneel/rhino-developer-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSampleImportNamedViews.py
23 lines (21 loc) · 984 Bytes
/
SampleImportNamedViews.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
################################################################################
# SampleImportNamedViews.py -- May 2014
# Copyright (c) 2017 Robert McNeel & Associates.
# See License.md in the root of this repository for details.
################################################################################
import scriptcontext
import rhinoscriptsyntax as rs
import Rhino
# Demonstrates how to import named views from a 3dm file.
def SampleImportNamedViews():
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)
# Check to see if this file is being executed as the "main" python
# script instead of being used as a module by some other python script
# This allows us to use the module which ever way we want.
if __name__ == "__main__":
SampleImportNamedViews()