-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsite_import.py
More file actions
executable file
·122 lines (102 loc) · 3.1 KB
/
Copy pathsite_import.py
File metadata and controls
executable file
·122 lines (102 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
###### THIS IS AN IronPython SCRIPT ######
# Import Standard Library
import os
import sys
import random
import cPickle
# Import .NET Libraries
import System
# Import Rhino Libraries
import Rhino
#import rhinoscriptsyntax as rs
import Rhino.RhinoApp as app
from scriptcontext import doc
# Project Imports
if 'rhinopythonscripts' in sys.modules:
del sys.modules['rhinopythonscripts']
print 'rhinopythonscripts cleared'
if 'GeoJson2Rhino' in sys.modules:
del sys.modules['GeoJson2Rhino']
print 'GeoJson2Rhino cleared'
#### LOCAL CODE LIBRARIES ####
#from rhinopythonscripts import GeoJson2Rhino
from rhinopostsites import *
from rhinopythonscripts import GeoJson2Rhino
from rhinopythonscripts.RunCPythonScript import run
from rhinopythonscripts.FileTools import *
# data import
from site_ids import ids
from sample_sites import jsons
def storeSites():
sites = []
for id in ids:
sitejson = jsons[id]
root = os.path.abspath('C:\Users\demonchaux\Dropbox\Amigos De Los Rios\siteJSONS')
fname = os.path.join(root, ('%s.json' % id))
f = open(fname, 'w')
f.write(sitejson)
f.close()
def saveSites(idList):
for id in idList:
#site = jsons[id]
root = os.path.abspath('C:\Users\demonchaux\Dropbox\Amigos De Los Rios')
rhroot = os.path.join(root, 'site3dms')
rhfname = os.path.join(rhroot, ('%s-site.3dm' % id))
# get the json
guids = GeoJson2Rhino.load(site)
saveDoc(rhfname)
deleteAll()
def buildSite(siteId):
rhroot = os.path.abspath('C:\\amigos\\dump')
rhfname = os.path.join(rhroot, ('%s-site.3dm' % siteId))
# get the json
siteData = getSite(siteId)
deleteAll()
GeoJson2Rhino.load(siteData)
exportFile(rhfname)
def buildWatersheds(siteId):
rhroot = os.path.abspath('C:\\amigos\\dump')
rhfname = os.path.join(rhroot, ('%s-watersheds.3dm' % siteId))
# get the json
siteData = getSite(siteId)
deleteAll()
GeoJson2Rhino.load(siteData)
exportFile(rhfname)
def getRandy():
seq = range(766)
random.shuffle(seq)
p = 'ids = [\n'
e = '\n]'
ids = ',\n'.join([('%s' % s) for s in seq[:50]])
f = open('site_ids.py', 'w')
f.write(p+ids+e)
f.close()
return ids
def testenv():
for m in sys.modules:
print m
def getSite(siteId):
cModulePath = os.path.abspath('C:/Users/demonchaux/Dropbox/localcode/loadAmigosData.py')
args = [siteId]
out, err, code = run(cModulePath, args)
#print code
if code == 1: # it choked on something
print err
elif code == 0: # there was some result
#print out
return out
def addSite(site):
# with either a site object or json, makes a site.
if type(site) == str:
return GeoJson2Rhino.load(site)
if __name__=='__main__':
from site_ids import ids
idList = range(462,767)[50:]
doc.UndoRecordingEnabled = False
doc.Views.RedrawEnabled = False
for site in ids:
print 'Building Site %s' % site
#buildSite(site)
buildWatersheds(site)
doc.Views.RedrawEnabled = True
doc.UndoRecordingEnabled = True