This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 as url | |
import json | |
h = "http://maps.googleapis.com/maps/api/geocode/json?address=9341+Venice+Boulevard+Culver+City,+California&sensor=false" | |
f = url.urlopen(h) # open the connection | |
s = f.read() # read the results as a string | |
d = json.loads(s) # convert the json string to a python dictionary | |
print d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Rhino.Geometry import Point3d, Vector3d, Curve | |
# inputs | |
# numBoids | |
# switch | |
# boundingBox | |
class Boid(): | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Rhino.Geometry import Point3d, Vector3d, Curve | |
# define our class | |
class RoboCookie: | |
def __init__(self, point): | |
self.flavor = "strawberry" | |
self.location = point | |
self.friends = None | |
self.direction = Vector3d( -point.X, -point.Y, -point.Z ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Rhino.Geometry import Vector3d, Point3d, Curve | |
class CakeBot: | |
def __init__(self, radius, center): | |
self.radius = radius | |
self.location = center | |
self.height = 0.5 | |
self.icingFlavor = "vanilla" | |
self.numSlices = 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import postsites | |
# select a folder to load data from and create a dict for db stuff | |
my_data_folder = 'C:/tampaGIS' | |
dbinfo = {'user':'postgres', 'dbname':'postgis', 'password':'postgrespass'} | |
### If you haven't yet made a config XLS file, execute this block: | |
f = postsites.makeXlsConfigurationFile(my_data_folder) | |
# it looks like loadFromXlsConfigurationFile returns a tuple, of the datasource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sites = { | |
'proposed_sites':{ 'name': 'proposed_sites', 'cols':['ogc_fid', 'fid_1', 'fid_1_1', 'objectid', 'assrdata_m', 'perimeter', 'ain', 'phase', 'lot', 'unit', 'moved', 'tra', 'pcltype', 'subdtype', 'tract', 'usecode', 'block', 'udate', 'editorname', 'parcel_typ', 'unit_no', 'pm_ref', 'tot_units', 'shape_area', 'shape_len', 'has_bb', 'count_', 'sum_oid_', 'sum_latitu', 'sum_longit', 'sum_buff_d', 'count_1']}, | |
} | |
micro = { | |
'parcel':{ 'name': 'parcel', 'cols':['ogc_fid', 'objectid', 'assrdata_m', 'perimeter', 'ain', 'phase', 'lot', 'unit', 'moved', 'tra', 'pcltype', 'subdtype', 'tract', 'usecode', 'block', 'udate', 'editorname', 'parcel_typ', 'unit_no', 'pm_ref', 'tot_units', 'shape_area', 'shape_len', 'has_bb']}, | |
'streetlights':{ 'name': 'streetlights', 'cols':['ogc_fid', 'objectid', 'angle', 'icon_txt', 'icon_id', 'ls', 'pole_type', 'lum_abbr', 'lumen', 'watts', 'lgt_type', 'sup_dist', 'petition', 'project', 'clmd', 'cc_no', 'l_no', 'pm', 'tract', 'uud', 'dateenr', 'sce_dist', 'sce_acct', 'sce_pol_i', 'sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import os | |
from rhinopythonscripts.LayerTools import * | |
from rhinopythonscripts.PickleTools import * | |
from rhinopythonscripts.IllustrationTools import * | |
from rhinopythonscripts.FileTools import * | |
from rhinopythonscripts.GeomTools import * | |
from scriptcontext import doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Rhino | |
import scriptcontext | |
# for accesssing GH classes | |
import clr | |
clr.AddReference("Grasshopper") | |
from Grasshopper.Kernel.Data import GH_Path | |
from Grasshopper import DataTree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
if EPSG: | |
url = 'http://spatialreference.org/ref/epsg/%s/ogcwkt/' % EPSG | |
f = urllib2.urlopen(url) | |
OGC_WKT = f.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scriptcontext | |
import Rhino | |
def getLayerGeometry(layerName, typefilter=Rhino.DocObjects.TextObject): | |
'''uses doc.Objects.FindByLayer and returns the Geometry of the | |
resulting RhinoObjects. If nothing found, returns an empty list.''' | |
objs = scriptcontext.doc.Objects.FindByLayer(layerName) | |
out = [] | |
for obj in objs: | |
if isinstance(obj, typefilter): |