Example #1
0
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)
Example #2
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))
Example #3
0
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)
Example #4
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)
Example #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))
Example #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)