def makeDrains(): drainLayers = ['openchannels', 'gravitymains', 'lateraldrains', ] drainColors = [ System.Drawing.Color.MidnightBlue, System.Drawing.Color.Blue, System.Drawing.Color.CornflowerBlue, System.Drawing.Color.SkyBlue, ] for i in range(len(drainLayers)): lyr = drainLayers[i] newName = lyr+'-projected' lyrAtt = LayerUtils.layerAttributes(newName, drainColors[i]) # make the layer # get results resultPairs = IntersectionTools.smartCurveLayerProject(lyr, 'groundsurface', lyrAtt) # bake results for pair in resultPairs: scriptcontext.doc.Objects.AddCurve(pair[0], pair[1]) # get the catchbasins srf = doc.Objects.FindByLayer('groundsurface')[0].Geometry rawPts = Smart.RhinoObjectsToSmartFeatures(doc.Objects.FindByLayer('catchbasins')) pt3ds = [pt.geom.Location for pt in rawPts] lowPts = Smart.replaceGeometries(rawPts, pt3ds) smrtPts = IntersectionTools.smartPointProject(lowPts, srf) newPts = [pt.geom for pt in smrtPts] circles = GeomTools.pointsToCircles(newPts, 0.5) smrtCircles = Smart.replaceGeometries(smrtPts, circles) lyrAtt = LayerUtils.layerAttributes('catchbasins-projected', drainColors[3]) for circle in smrtCircles: doc.Objects.AddCircle(circle.geom, circle.objAttributes(lyrAtt))
def makeProjectedFiles(idList, layerList, fileSuffix): fmask = 'C:\\amigos\\dump\\%s-%s.3dm' outMask = 'C:\\amigos\\dump\\%s-' + fileSuffix + '.3dm' types = ['site', 'terrain'] outLayers = [s + '-projected' for s in layerList] for siteId in idList: FileUtils.deleteAll() fpaths = [(fmask % (siteId, t)) for t in types] FileUtils.importFiles(fpaths) for i, layer in enumerate(layerList): lyrAtt = LayerUtils.layerAttributes(outLayers[i]) # make the layer # determine geometry type sampleGeom = LayerUtils.getLayerGeometry(layer) if len(sampleGeom) > 0: if type(sampleGeom[0]) == Point: resultPairs = IntersectionTools.smartPointLayerProject( layer, 'groundsurface', lyrAtt) # bake results for pair in resultPairs: scriptcontext.doc.Objects.AddPoint(pair[0], pair[1]) else: resultPairs = IntersectionTools.smartCurveLayerProject( layer, 'groundsurface', lyrAtt) # bake results for pair in resultPairs: scriptcontext.doc.Objects.AddCurve(pair[0], pair[1]) outPath = outMask % siteId FileUtils.exportLayers(outLayers, outPath)
def makeProjectedFiles(idList, layerList, fileSuffix): fmask = 'C:\\amigos\\dump\\%s-%s.3dm' outMask = 'C:\\amigos\\dump\\%s-'+fileSuffix+'.3dm' types = ['site', 'terrain'] outLayers = [s+'-projected' for s in layerList] for siteId in idList: FileUtils.deleteAll() fpaths = [(fmask % (siteId, t)) for t in types] FileUtils.importFiles(fpaths) for i, layer in enumerate(layerList): lyrAtt = LayerUtils.layerAttributes(outLayers[i]) # make the layer # determine geometry type sampleGeom = LayerUtils.getLayerGeometry(layer) if len(sampleGeom) > 0: if type(sampleGeom[0]) == Point: resultPairs = IntersectionTools.smartPointLayerProject(layer, 'groundsurface', lyrAtt) # bake results for pair in resultPairs: scriptcontext.doc.Objects.AddPoint(pair[0], pair[1]) else: resultPairs = IntersectionTools.smartCurveLayerProject(layer, 'groundsurface', lyrAtt) # bake results for pair in resultPairs: scriptcontext.doc.Objects.AddCurve(pair[0], pair[1]) outPath = outMask % siteId FileUtils.exportLayers(outLayers, outPath)
def makeTerrainSurfaces(): ptGrid = GeomTools.pointGrid(76, 76, 8, 8) # get the mesh try: mesh = doc.Objects.FindByLayer('tin_pts')[0].Geometry # make the points interpPoints = IntersectionTools.interpolatePointsToTerrainMesh(ptGrid, mesh) # make the surface srf = Rhino.Geometry.NurbsSurface.CreateFromPoints(interpPoints, 76, 76, 3, 3) except: print 'No contents on "tin_pts" layer' print 'flat ground created' srf = Rhino.Geometry.NurbsSurface.CreateFromPoints(ptGrid, 76, 76, 3, 3) # put it on the layer srfAtt = LayerUtils.layerAttributes('groundsurface', System.Drawing.Color.LightGray) doc.Objects.AddSurface(srf, srfAtt) srfBrep = Brep.CreateFromSurface(srf) contours = IntersectionTools.contourBrepInZ(srfBrep, 0.5) bigAtt = LayerUtils.layerAttributes('bigcontours', System.Drawing.Color.Black) smallAtt = LayerUtils.layerAttributes('smallcontours', System.Drawing.Color.DimGray) for i in range(len(contours)): if i % 10 == 0: # make a big contour for crv in contours[i]: doc.Objects.AddCurve(crv, bigAtt) else: # make a small contour for crv in contours[i]: doc.Objects.AddCurve(crv, smallAtt)
def makeDrains(): drainLayers = [ 'openchannels', 'gravitymains', 'lateraldrains', ] drainColors = [ System.Drawing.Color.MidnightBlue, System.Drawing.Color.Blue, System.Drawing.Color.CornflowerBlue, System.Drawing.Color.SkyBlue, ] for i in range(len(drainLayers)): lyr = drainLayers[i] newName = lyr + '-projected' lyrAtt = LayerUtils.layerAttributes(newName, drainColors[i]) # make the layer # get results resultPairs = IntersectionTools.smartCurveLayerProject( lyr, 'groundsurface', lyrAtt) # bake results for pair in resultPairs: scriptcontext.doc.Objects.AddCurve(pair[0], pair[1]) # get the catchbasins srf = doc.Objects.FindByLayer('groundsurface')[0].Geometry rawPts = Smart.RhinoObjectsToSmartFeatures( doc.Objects.FindByLayer('catchbasins')) pt3ds = [pt.geom.Location for pt in rawPts] lowPts = Smart.replaceGeometries(rawPts, pt3ds) smrtPts = IntersectionTools.smartPointProject(lowPts, srf) newPts = [pt.geom for pt in smrtPts] circles = GeomTools.pointsToCircles(newPts, 0.5) smrtCircles = Smart.replaceGeometries(smrtPts, circles) lyrAtt = LayerUtils.layerAttributes('catchbasins-projected', drainColors[3]) for circle in smrtCircles: doc.Objects.AddCircle(circle.geom, circle.objAttributes(lyrAtt))
def makeTerrainSurfaces(): ptGrid = GeomTools.pointGrid(76, 76, 8, 8) # get the mesh try: mesh = doc.Objects.FindByLayer('tin_pts')[0].Geometry # make the points interpPoints = IntersectionTools.interpolatePointsToTerrainMesh( ptGrid, mesh) # make the surface srf = Rhino.Geometry.NurbsSurface.CreateFromPoints( interpPoints, 76, 76, 3, 3) except: print 'No contents on "tin_pts" layer' print 'flat ground created' srf = Rhino.Geometry.NurbsSurface.CreateFromPoints( ptGrid, 76, 76, 3, 3) # put it on the layer srfAtt = LayerUtils.layerAttributes('groundsurface', System.Drawing.Color.LightGray) doc.Objects.AddSurface(srf, srfAtt) srfBrep = Brep.CreateFromSurface(srf) contours = IntersectionTools.contourBrepInZ(srfBrep, 0.5) bigAtt = LayerUtils.layerAttributes('bigcontours', System.Drawing.Color.Black) smallAtt = LayerUtils.layerAttributes('smallcontours', System.Drawing.Color.DimGray) for i in range(len(contours)): if i % 10 == 0: # make a big contour for crv in contours[i]: doc.Objects.AddCurve(crv, bigAtt) else: # make a small contour for crv in contours[i]: doc.Objects.AddCurve(crv, smallAtt)
def addBillboards(): # must have projected things already FileUtils.importFile('C:\\amigos\\templates\\billboardangled.3dm') FileUtils.importFile('C:\\amigos\\templates\\billboardstraight.3dm') lyrAtt = LayerUtils.layerAttributes('billboards') bbs = LayerUtils.getLayerGeometry('geocodedbillboards-projected') bbs.extend(LayerUtils.getLayerGeometry('foundbillboards-projected')) bbpoints = [bb.Location for bb in bbs] frwys = LayerUtils.getLayerGeometry('freeways-projected') roads = LayerUtils.getLayerGeometry('roads-projected') for pt in bbpoints: vector = GeomTools.vectorToClosestCurve(pt, frwys, 100.0) if vector: # freeway within 100m bbModel = LayerUtils.getLayerGeometry('billboardangled') else: # no freeways within 100meters vector = GeomTools.vectorToClosestCurve(pt, roads) bbModel = LayerUtils.getLayerGeometry('billboardstraight') GeomTools.moveMany(bbModel, Vector3d(pt)) angle = vector.VectorAngle(Vector3d.XAxis, vector, Plane.WorldXY) GeomTools.rotateMany(bbModel, angle, Vector3d.ZAxis, pt) GeomTools.bakeMany(bbModel, lyrAtt) LayerUtils.deleteLayer('billboardstraight') LayerUtils.deleteLayer('billboardangled')
def addBillboards(): # must have projected things already FileUtils.importFile('C:\\amigos\\templates\\billboardangled.3dm') FileUtils.importFile('C:\\amigos\\templates\\billboardstraight.3dm') lyrAtt = LayerUtils.layerAttributes('billboards') bbs = LayerUtils.getLayerGeometry('geocodedbillboards-projected') bbs.extend( LayerUtils.getLayerGeometry('foundbillboards-projected') ) bbpoints = [bb.Location for bb in bbs] frwys = LayerUtils.getLayerGeometry('freeways-projected') roads = LayerUtils.getLayerGeometry('roads-projected') for pt in bbpoints: vector = GeomTools.vectorToClosestCurve(pt, frwys, 100.0) if vector: # freeway within 100m bbModel = LayerUtils.getLayerGeometry('billboardangled') else: # no freeways within 100meters vector = GeomTools.vectorToClosestCurve(pt, roads) bbModel = LayerUtils.getLayerGeometry('billboardstraight') GeomTools.moveMany( bbModel, Vector3d(pt) ) angle = vector.VectorAngle( Vector3d.XAxis, vector, Plane.WorldXY ) GeomTools.rotateMany( bbModel, angle, Vector3d.ZAxis, pt ) GeomTools.bakeMany( bbModel, lyrAtt ) LayerUtils.deleteLayer('billboardstraight') LayerUtils.deleteLayer('billboardangled')