Beispiel #1
0
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))
Beispiel #2
0
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)
Beispiel #3
0
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')
Beispiel #4
0
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')
Beispiel #5
0
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))
Beispiel #6
0
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)
            geoms = []
            objs = model.Objects.FindByLayer(layer)
            for obj in objs:
                data = objUserStringDictionary(obj)
                for k in data:
                    if k in goodData:
                        if goodData[k] not in siteData:
                            siteData[goodData[k]] = [data[k]]
                        else:
                            siteData[goodData[k]].append( data[k] )
                geom = obj.Geometry
                geom.EnsurePrivateCopy()
                geoms.append( geom )
            layerAtt = LayerTools.layerAttributes( layer )
            if layer != 'site':
                GeomTools.bakeMany( geoms, layerAtt )
            else:
                siteCrv = geoms[0]
                bbox = siteCrv.GetBoundingBox(False)
                minPt, maxPt = bbox.Min, bbox.Max
                xyPlane = Rhino.Geometry.Plane.WorldXY
                rect = Rhino.Geometry.Rectangle3d( xyPlane, minPt, maxPt )
                newCrv = rect.ToNurbsCurve()
                GeomTools.bakeMany( [newCrv], layerAtt )

        # save watershed info
        pickleData( pickleFile, siteData )
        #print unpickleData( pickleFile )
        # zoom to everything
        Rhino.RhinoApp.RunScript('-_ZE ', True)
        # export to illustrator