def CockpitWindowContours(Height=1.620, Depth=5):
    P1 = [0.000, 0.076, Height - 1.620 + 2.194]
    P2 = [0.000, 0.852, Height - 1.620 + 2.290]
    P3 = [0.000, 0.904, Height + 0.037]
    P4 = [0.000, 0.076, Height]
    CWC1 = rs.AddPolyline([P1, P2, P3, P4, P1])
    rs.SelectObject(CWC1)
    rs.Command("_FilletCorners 0.08 ")

    P1 = [0.000, 0.951, Height - 1.620 + 2.289]
    P2 = [0.000, 1.343, Height - 1.620 + 2.224]
    P3 = [0.000, 1.634, Height - 1.620 + 1.773]
    P4 = [0.000, 1.557, Height - 1.620 + 1.588]
    P5 = [0.000, 1.027, Height - 1.620 + 1.671]
    CWC2 = rs.AddPolyline([P1, P2, P3, P4, P5, P1])
    rs.SelectObject(CWC2)
    rs.Command("_FilletCorners 0.08 ")

    CWC3 = act.MirrorObjectXZ(CWC1)
    CWC4 = act.MirrorObjectXZ(CWC2)

    ExtPathId = rs.AddLine([0, 0, 0], [Depth, 0, 0])

    CWC1s = rs.ExtrudeCurve(CWC1, ExtPathId)
    CWC2s = rs.ExtrudeCurve(CWC2, ExtPathId)
    CWC3s = rs.ExtrudeCurve(CWC3, ExtPathId)
    CWC4s = rs.ExtrudeCurve(CWC4, ExtPathId)

    rs.DeleteObjects([CWC1, CWC2, CWC3, CWC4, ExtPathId])

    return CWC1s, CWC2s, CWC3s, CWC4s
def d(t, n):
    """
    receives:
         t = theta syuuki of sin  (0 < t < 90)
         n = number of waves  (0 < n < 50)
    works:
        draw waves
    returns:
        None
    """
    for x in range(0, n):
        points = []
        for y in range(1, n):
            p = (x, y, ma.sin((ma.radians(t * (y + x)))))
            points.append(p)
            #rs.AddPoint(p)
        a = rs.AddCurve(points, 5)
        b = rs.AddLine((x, 0, 0), (x + 0.7, 0, 0))
        rs.ExtrudeCurve(a, b)

    for y in range(1, n):
        list = []
        for x in range(0, n):
            p = (x, y, ma.cos(ma.radians(t * (x + y))))
            list.append(p)
        a = rs.AddCurve(list, 5)
        b = rs.AddLine((0, y, 0), (0, y + 0.7, 0))
        rs.ExtrudeCurve(a, b)
def c():
    a = rs.AddLine((0, 0, 0), (0, 0, 1))
    p = []
    r = 10
    for k in range(0, 50):
        t = (k * ma.sin((k * r) / (2 * ma.pi)), k * ma.cos(
            (k * r) / (2 * ma.pi)), 0)
        p.append(t)
    b = rs.AddCurve(p, 5)
    rs.ExtrudeCurve(a, b)
def MakeWindow(FuselageSrf, Xwc, Zwc):
    WinCenter = [Xwc, Zwc]
    WCurve = WindowContour(WinCenter)

    ExtPathStbd = rs.AddLine([0, 0, 0], [0, 10, 0])
    ExtPathPort = rs.AddLine([0, 0, 0], [0, -10, 0])

    TubeStbd = rs.ExtrudeCurve(WCurve, ExtPathStbd)
    FuselageSrf, WinStbd = rs.SplitBrep(FuselageSrf,
                                        TubeStbd,
                                        delete_input=True)
    TubePort = rs.ExtrudeCurve(WCurve, ExtPathPort)
    FuselageSrf, WinPort = rs.SplitBrep(FuselageSrf,
                                        TubePort,
                                        delete_input=True)

    rs.DeleteObjects([TubeStbd, TubePort, ExtPathStbd, ExtPathPort, WCurve])

    return WinStbd, WinPort, FuselageSrf
Beispiel #5
0
def draw_sikaku(h):
    p1 = (1000, 1000, h)
    p2 = (1000, -1000, h)
    p3 = (1000, 0, h)
    p4 = (-1000, 0, h)
    path = rs.AddLine(p1, p2)
    side = rs.AddLine(p3, p4)
    plate = rs.ExtrudeCurve(path, side)
    rs.DeleteObject(path)
    rs.DeleteObject(side)
    return plate
Beispiel #6
0
def get_frame_brep(outline_srf, border_thickness, thickness):
    """get the frame brep. This is a solid that is booleaned with the slices of
	terrain to make a border when border mode is on."""
    edge_crvs = rs.DuplicateEdgeCurves(outline_srf)
    outline_crv = rs.JoinCurves(edge_crvs)
    pt, _ = rs.CurveAreaCentroid(outline_crv)
    inner_crv = rs.OffsetCurve(outline_crv, pt, border_thickness, [0, 0, 1])
    rs.MoveObjects([outline_crv, inner_crv], [0, 0, thickness * 2])

    path_line = rs.AddLine([0, 0, 0], [0, 0, -thickness * 4])
    inner_brep = rs.ExtrudeCurve(inner_crv, path_line)
    outer_brep = rs.ExtrudeCurve(outline_crv, path_line)
    rs.CapPlanarHoles(inner_brep)
    rs.CapPlanarHoles(outer_brep)

    frame_brep = rs.BooleanDifference([outer_brep], [inner_brep])
    rs.DeleteObjects([outline_crv, inner_crv])
    rs.DeleteObjects(edge_crvs)
    rs.DeleteObject(path_line)
    return frame_brep
Beispiel #7
0
def draw_sikaku(i):
    h = height = 100
    r = radius = 100
    theta = ma.radians(i)
    p1 = (0, 0, 0)
    p2 = (0, 0, h)
    path = rs.AddLine(p1, p2)
    side = rs.AddLine((0, 0, -3), (r * ma.cos(theta), r * ma.sin(theta), -3))
    plate = rs.ExtrudeCurve(side, path)
    rs.DeleteObject(path)
    rs.DeleteObject(side)
    return plate
Beispiel #8
0
            def make(self):
                self.segments = rs.ExplodeCurves(self.Rect)

                treadLength = rs.CurveLength(self.segments[1]) / self.numRisers
                riserHeight = self.deltaHeight / self.numRisers
                runVector = rs.VectorCreate(
                    rs.CurveEndPoint(self.segments[1]),
                    rs.CurveStartPoint(self.segments[1]))
                unitRunVec = rs.VectorUnitize(runVector)
                treadVec = rs.VectorScale(unitRunVec, treadLength)
                riseVec = rs.VectorCreate([0, 0, riserHeight], [0, 0, 0])

                newPt = [
                    rs.CurveStartPoint(self.segments[0]).X,
                    rs.CurveStartPoint(self.segments[0]).Y,
                    rs.CurveStartPoint(self.segments[0]).Z - self.deltaHeight
                ]
                ptList = []
                ptList.append(rs.AddPoint(newPt))
                for i in range(self.numRisers):
                    tempPt = rs.CopyObject(ptList[-1])
                    rs.MoveObject(tempPt, riseVec)
                    ptList.append(tempPt)
                    tempPt = rs.CopyObject(ptList[-1])
                    rs.MoveObject(tempPt, treadVec)
                    ptList.append(tempPt)

                downLine = rs.VectorCreate([0, 0, 0], [0, 0, self.thickness])
                newBtmPt = rs.MoveObject(rs.CopyObject(ptList[0]), downLine)
                ptList.insert(0, newBtmPt)
                newBtmPt2 = rs.MoveObject(rs.CopyObject(ptList[-1]), downLine)
                ptList.append(newBtmPt2)

                stringer = rs.AddPolyline(ptList)
                closeCrv = rs.AddLine(rs.CurveStartPoint(stringer),
                                      rs.CurveEndPoint(stringer))

                newStringer = rs.JoinCurves([stringer, closeCrv], True)

                stair = rs.ExtrudeCurve(newStringer, self.segments[0])
                rs.CapPlanarHoles(stair)
                rs.DeleteObject(stringer)
                rs.DeleteObject(newStringer)
                rs.DeleteObjects(ptList)
                rs.DeleteObjects(self.segments)
                return stair
def e(theta, num):
    """
    receives:
        theta = degree of line ( 0 < theta < 45 ) 
        num = number of pattern ( 0 < num < 15 )
    works:
        draw tile pattern
    returns:
        None
    """
    def base(x, y):
        d = ma.radians(theta)

        r = 1 / ma.cos(d) - (ma.sin(d)**2) / ma.cos(d)
        n = r * ma.sin(d)
        k = r * ma.cos(d)

        a1 = (x, y, 0)
        b1 = (x, y + 1, 0)
        c1 = (x + 1, y + 1, 0)
        d1 = (x + 1, y, 0)

        a2 = (x + k, y + n, 0)
        b2 = (x + n, y + 1 - k, 0)
        c2 = (x + 1 - k, y + 1 - n, 0)
        d2 = (x + 1 - n, y + k, 0)

        l1 = rs.AddLine(a1, a2)
        l2 = rs.AddLine(b1, b2)
        l3 = rs.AddLine(c1, c2)
        l4 = rs.AddLine(d1, d2)

    for i in range(0, num):
        for k in range(0, num):
            base(i, k)

    line = rs.ObjectsByType(0)
    n = len(line)
    for i in range(0, n):
        a = line[i]
        b = rs.AddLine((0, 0, 0), (0, 0, 0.05))
        c = rs.RotateObject(b, (0, 0, 0), 90, None, False)
        s = rs.ExtrudeCurve(a, b)
        rs.ExtrudeSurface(s, c)
Beispiel #10
0
def splitSrfVerticallyByPts(srf,pts):
    normals=[]
    up=(0,0,1000000000)
    half=(0,0,500000000)
    cutters=[]
    for p in pts:
        uv=rs.SurfaceClosestPoint(srf,p)
        normal=rs.SurfaceNormal(srf,uv)
        normal=rs.VectorScale(normal,1000)
        normals.append(normal)
        botStart=rs.VectorAdd(rs.VectorSubtract(p,half),normal)
        botEnd=rs.VectorSubtract(rs.VectorSubtract(p,half),normal)

        l=rs.AddLine(botStart,botEnd)
        path=rs.AddLine(botStart,rs.VectorAdd(botStart,up))
        cutter=rs.ExtrudeCurve(l,path)
        rs.DeleteObjects([l,path])

        #print(rs.IsBrep(cutter))
        #print(cutter)
        cutters.append(cutter)
    # rs.SelectObjects(cutters)
    srfs=splitSrfBySrfs(srf,cutters)
    return srfs
Beispiel #11
0
import rhinoscriptsyntax as rs
import random

pickedCurves = rs.GetObjects("pick some curves", 4)
desiredArea = 1000.0

for curve in pickedCurves:
    length = rs.CurveLength(curve)
    extrudeAmt = desiredArea / length
    direcitonalVector = (random.uniform(-10, 10), random.uniform(-10, 10),
                         random.uniform(-10, 10))
    #how we have a vector with random x, y and z components
    #to give it the precise amplitude we want, we will normalize it, meaning it will keep the direction, but have a length of one unit
    #then, we'll scale the vector to the desired amplitude

    unitVect = rs.VectorUnitize(direcitonalVector)

    scaledVect = rs.VectorScale(unitVect, extrudeAmt)

    startPoint = rs.CurveMidPoint(curve)
    endPoint = rs.VectorAdd(startPoint, scaledVect)

    pathCurve = rs.AddLine(startPoint, endPoint)

    rs.ExtrudeCurve(curve, pathCurve)
    rs.DeleteObject(pathCurve)
    #further example: how to put the surface on a new layer
Beispiel #12
0
Points1 = rs.DivideCurve(L1, Ndiv, False)

#Second line of the base

p1 = (-1*L, W, 0)
p2 = (L,W,0)
L2 = rs.AddLine(p1, p2)
Points2 = rs.DivideCurve(L2, Ndiv, False)

#Stiffners of the base

rs.CurrentLayer("Beams")

for i in range(Ndiv + 1):
    A_line = rs.AddLine(Points1[i], Points2[i])
    rs.ExtrudeCurve(A_line, path)
    rs.DeleteObject(A_line)
    
#Platform of the base
rs.CurrentLayer("Surface")
rs.AddLoftSrf([L1, L2])

#Definition of parabola points
rs.CurrentLayer("Points")
for i in range(Ndiv + 1):
    x = Points1[i][0]
    P = [x, 0, Amp*(x-L)*(x + L)*(-1/10)]
    Points3.append(rs.AddPoint(P))
    
#Vertical lines btw Points1(base) and Points3 (Points form parabola)
rs.CurrentLayer("Columns")
def dd(t, n):
    """
    receives:
         t = theta syuuki of sin  (0 < t < 90)
         n = number of waves  (0 < n < 200)
    works:
        draw waves
    returns:
        None
    """
    list = []
    for x in range(0, n):
        for y in range(0, n):
            p = [x, y, 0]
            list.append(p)

    number = len(list)

    rx = rd.random() * n
    ry = rd.random() * n
    nn = n / 2

    for k in range(0, number):
        x = list[k][0]
        y = list[k][1]
        dx = x - rx
        dy = y - ry
        d = ma.sqrt(dx**2 + dy**2)

        if d < nn:
            list[k][2] = list[k][2] + (
                (nn - d) / 6) * ma.sin(ma.radians(d * 10))
        else:
            pass

    rx = rd.random() * n
    ry = rd.random() * n
    for k in range(0, number):
        x = list[k][0]
        y = list[k][1]
        dx = x - rx
        dy = y - ry
        d = ma.sqrt(dx**2 + dy**2)

        if d < nn:
            list[k][2] = list[k][2] + (nn - d) / 3 * ma.cos(ma.radians(d * 3))
        else:
            None
    rx = rd.random() * n
    ry = rd.random() * n
    for k in range(0, number):
        x = list[k][0]
        y = list[k][1]
        dx = x - rx
        dy = y - ry
        d = ma.sqrt(dx**2 + dy**2)

        if d < nn:
            list[k][2] = list[k][2] + (nn - d) / 10
        else:
            None
    for i in range(0, n):
        a = rs.AddCurve(list[i * n:(i + 1) * n], 5)
        b = rs.AddLine((x, 0, 0), (x + 0.7, 0, 0))
        rs.ExtrudeCurve(a, b)
Beispiel #14
0
import rhinoscriptsyntax as rs
import random

pickedCurves = rs.GetObjects("pick some curves", 4)

for curve in pickedCurves:
    #note, this is a good example of crafting procedure in reverse
    startPoint = rs.CurveMidPoint(curve)

    goalPoint = (startPoint[0], startPoint[1], 0)

    pathLine = rs.AddLine(startPoint, goalPoint)

    rs.ExtrudeCurve(curve, pathLine)
    rs.DeleteObject(pathLine)
 def cube(x, y, z):
     line1 = rs.AddLine((x, y, z), (x, y + 5, z))
     line2 = rs.AddLine((x, y, z), (x + 5, y, z))
     surface = rs.ExtrudeCurve(line1, line2)
     line3 = rs.AddLine((x, y, 0), (x, y, 5))
     rs.ExtrudeSurface(surface, line3)
    bottom_planes.append(planes)
  
    
# Rotate planes on ZAxis
rotated_planes = []
for i in bottom_planes:
    plane = rs.ViewCPlane()
    rndm_angle = random.randrange(-5, 5) 
    rotated_z = rs.RotatePlane(i, rndm_angle, planes.ZAxis)
    # Tilt control
    tilt = random.randrange(-5, 5) * max_tilt
    rotated_x = rs.RotatePlane(rotated_z, tilt, planes.XAxis)
    rotated_planes.append(rotated_x)
    
    
# Create solids
solids = []
lines = []
for j in range(0, len(rotated_planes)):
    line = rs.AddLine(bottom_pts[j], top_pts[j])
    lines.append(line)
    tilt = random.randrange(-5, 5) * max_tilt
    rot_lines = rs.RotateObject(line, bottom_pts[j], tilt, planes.XAxis, copy=False)
    rct = rs.AddRectangle( rotated_planes[j], 
    rg.Interval(-0.5 * block_w, 0.5 * block_w), 
    rg.Interval(-0.5 * block_d, 0.5 * block_d))
    solid = rs.ExtrudeCurve(rct, rot_lines)
    sld = rs.CapPlanarHoles(solid)
    solids.append(solid)
    
print('Ivan Perez | [email protected] | Bogotá | Colombia')
Beispiel #17
0
def Ramp_HeightSlope(path, width, slope):
    #Variables
    rampThickness = 6
    handrailOffset = 3
    handrailRadius = 1.5
    handrailHeight = 34
    if width < 36:
        width = 36
    width = width + (handrailOffset * 2)
    comments = ''

    handrailCenterlineOffset = (handrailOffset - handrailRadius / 2)

    rs.SimplifyCurve(path)

    runs = MakeRampRuns(path, width)

    if slope > .05:
        runData = CheckRunLengths(runs)
        runs = runData[0]
        comments += runData[1]

    runGeo = []
    hdrls = []
    finalHandrails = []
    vertMove = (0, 0, 0)

    for run in runs:
        length = rs.Distance(rs.CurveStartPoint(run[0]),
                             rs.CurveStartPoint(run[1]))

        stHeight = vertMove
        vertMove = (0, 0, length * slope)

        rs.MoveObject(run[-1], vertMove)
        rs.MoveObjects(run, stHeight)

        vertMove = rs.VectorAdd(stHeight, vertMove)

        srf = rs.AddLoftSrf(run)

        norm = rs.SurfaceNormal(srf[0], [.5, .5])
        if norm.Z < 0:
            rs.FlipSurface(srf[0], True)
            runGeo.append(srf[0])
        else:
            runGeo.append(srf[0])

        hdrls.append(MakeHandrailFromRuns(run, handrailCenterlineOffset))

        rs.DeleteObjects(run)

    #Get highest and lowest lines
    landingEdges = []
    for run in runGeo:
        curves = rs.DuplicateEdgeCurves(run)
        highestIndex = None
        highestValue = -999999
        lowestIndex = None
        lowestValue = 999999
        for i, curve in enumerate(curves):
            crvZ = rs.CurveMidPoint(curve)[2]
            if crvZ < lowestValue:
                lowestIndex = i
                lowestValue = crvZ
            if crvZ > highestValue:
                highestIndex = i
                highestValue = crvZ
        lowestEdge = rs.CopyObject(curves[lowestIndex])
        highestEdge = rs.CopyObject(curves[highestIndex])
        landingEdges.append(lowestEdge)
        rs.ReverseCurve(highestEdge)
        landingEdges.append(highestEdge)
        rs.DeleteObjects(curves)
    comments += 'Total ramp height {}"\n'.format(str(highestValue))

    #Make Landings
    landingGeos = MakeRampLandings(landingEdges, handrailCenterlineOffset)
    landings = landingGeos[0]
    hdrls += landingGeos[1]
    allHandrails = []
    for hdrl in hdrls:
        for each in hdrl:
            allHandrails.append(each)
    longRails = rs.JoinCurves(allHandrails, True)

    #Handrail Extension
    for rail in longRails:
        stPt = rs.CurveStartPoint(rail)
        stVec = rs.CurveTangent(rail, 0)
        stVecProj = rs.VectorScale(
            rs.VectorReverse(rs.VectorUnitize((stVec[0], stVec[1], 0))), 12)
        endPt = rs.CurveEndPoint(rail)
        endParam = rs.CurveClosestPoint(rail, endPt)
        endVec = rs.CurveTangent(rail, endParam)
        endVecProj = rs.VectorScale(
            rs.VectorUnitize((endVec[0], endVec[1], 0)), 12)
        stPtTemp = rs.CurveStartPoint(rail)
        endPtTemp = rs.CurveEndPoint(rail)
        stPtOffset = rs.MoveObject(stPtTemp, stVecProj)
        endPtOffset = rs.MoveObject(endPtTemp, endVecProj)
        stProj = rs.AddLine(stPt, stPtOffset)
        endProj = rs.AddLine(endPt, endPtOffset)
        finalHandrails.append(rs.JoinCurves([stProj, rail, endProj], True)[0])

        rs.DeleteObject(stPtOffset)
        rs.DeleteObject(endPtOffset)

    #Move handrails up
    for rail in finalHandrails:
        rs.MoveObject(rail, (0, 0, handrailHeight))

    #Make solid geometry
    topSurface = rs.JoinSurfaces(runGeo + landings, True)
    if topSurface is None: topSurface = runGeo

    btmSurface = rs.CopyObject(topSurface, (0, 0, -rampThickness))

    edgeCurves = rs.DuplicateSurfaceBorder(topSurface)

    extrusionLine = rs.AddLine((0, 0, 0), (0, 0, -rampThickness))
    extrusionGeo = rs.ExtrudeCurve(edgeCurves, extrusionLine)
    rs.DeleteObject(extrusionLine)
    rs.DeleteObject(edgeCurves)

    finalGeo = rs.JoinSurfaces([topSurface, btmSurface, extrusionGeo], True)

    #rs.EnableRedraw(True)
    #print "A"
    if slope <= .05:
        rs.DeleteObjects(finalHandrails)
        return [finalGeo, comments]
    else:
        return [finalGeo, comments, finalHandrails]
Beispiel #18
0
        def makeFireStair(rect, landingLevels):
            #HARD VARIABLES
            minGapSize = .2
            minTread = .260
            maxRiser = .180
            thickness = .15

            #(1)Determine Run Direction
            rs.SimplifyCurve(rect)
            rectSegments = rs.ExplodeCurves(rect)
            edge1 = rectSegments[0]
            edge3 = rectSegments[1]
            rs.DeleteObject(rectSegments[2])
            rs.DeleteObject(rectSegments[3])
            if rs.CurveLength(edge1) > rs.CurveLength(edge3):
                longEdge = edge1
                shortEdge = edge3
            else:
                longEdge = edge3
                shortEdge = edge1
            longVec = rs.VectorCreate(rs.CurveStartPoint(longEdge),
                                      rs.CurveEndPoint(longEdge))
            longVecRev = rs.VectorReverse(longVec)
            shortVec = rs.VectorCreate(rs.CurveStartPoint(shortEdge),
                                       rs.CurveEndPoint(shortEdge))
            shortVecRev = rs.VectorReverse(shortVec)
            rs.CurveArrows(longEdge, 2)
            rs.CurveArrows(shortEdge, 2)

            #(2)Stair Width
            stairWidth = (rs.CurveLength(shortEdge) - minGapSize) / 2

            #LandingRect
            landing1Plane = rs.PlaneFromFrame(rs.CurveStartPoint(shortEdge),
                                              shortVecRev, longVecRev)
            landing1 = rs.AddRectangle(landing1Plane,
                                       rs.CurveLength(shortEdge), stairWidth)
            landing2Plane = rs.PlaneFromFrame(rs.CurveEndPoint(longEdge),
                                              shortVec, longVec)
            landing2 = rs.AddRectangle(landing2Plane,
                                       rs.CurveLength(shortEdge), stairWidth)

            #(3)Run Length
            runLength = rs.CurveLength(longEdge) - (stairWidth * 2)

            #RunRects
            run1Plane = rs.PlaneFromFrame(
                rs.CurveEditPoints(landing1)[3], shortVecRev, longVecRev)
            run1Rect = rs.AddRectangle(run1Plane, stairWidth, runLength)
            run2Plane = rs.PlaneFromFrame(
                rs.CurveEditPoints(landing2)[3], shortVec, longVec)
            run2Rect = rs.AddRectangle(run2Plane, stairWidth, runLength)

            #(4)Num Flights between Landings
            numLevels = len(landingLevels)
            deltaLevels = []
            runsPerLevel = []
            maxRisersPerRun = math.floor(runLength / minTread)
            numRuns = 0

            for i in range(0, numLevels - 1):
                deltaLevels.append(landingLevels[i + 1] - landingLevels[i])
                minNumRisers = math.ceil(deltaLevels[i] / maxRiser)
                runsPerLevel.append(math.ceil(minNumRisers / maxRisersPerRun))
                numRuns = numRuns + int(runsPerLevel[i])

            #(5) Which flights

            listOfRuns = []
            for i in range(0, numRuns):
                if i % 2:  #if even
                    listOfRuns.append(rs.CopyObject(run1Rect))
                else:
                    listOfRuns.append(rs.CopyObject(run2Rect))

            #(6) Num Treads per run
            runsDeltaHeight = []
            for i in range(0, numLevels - 1):
                for j in range(0, int(runsPerLevel[i])):
                    runsDeltaHeight.append(deltaLevels[i] / runsPerLevel[i])

            numRisersPerRun = []
            for i in range(0, numRuns):
                numRisersPerRun.append(math.ceil(runsDeltaHeight[i] /
                                                 maxRiser))

            #(7) Move Runs
            elevation = 0
            landings = []
            for i in range(0, numRuns):
                elevation = elevation + runsDeltaHeight[i]
                translation = rs.VectorCreate([0, 0, elevation], [0, 0, 0])
                rs.MoveObject(listOfRuns[i], translation)
                if i % 2:
                    landings.append(
                        rs.MoveObject(rs.CopyObject(landing2), translation))
                else:
                    landings.append(
                        rs.MoveObject(rs.CopyObject(landing1), translation))

            #(8) Make Landings
            stairGeo = []
            for i in range(0, numRuns):
                dir = rs.VectorCreate([0, 0, 0], [0, 0, runsDeltaHeight[i]])
                #rs.MoveObject(landings[i], dir)
                path = rs.AddLine([0, 0, 0], [0, 0, -thickness])
                geo = rs.ExtrudeCurve(landings[i], path)
                rs.CapPlanarHoles(geo)
                stairGeo.append(geo)
                rs.DeleteObject(path)
            rs.DeleteObjects(landings)

            #(9) Draw Stairs
            runs = []
            for i in range(0, numRuns):
                runs.append(
                    Run(listOfRuns[i], runsDeltaHeight[i], numRisersPerRun[i]))
                stairGeo.append(runs[i].make())

            finalGeo = rs.BooleanUnion(stairGeo, delete_input=True)
            #Cleanup
            rs.DeleteObjects(listOfRuns)
            rs.DeleteObjects(rectSegments)
            rs.DeleteObject(landing1)
            rs.DeleteObject(landing2)
            rs.DeleteObject(run1Rect)
            rs.DeleteObject(run2Rect)
            print "done"
            return finalGeo
Beispiel #19
0
    coordinates2 = (x, y, 0)
    rs.AddPoint(coordinates2)
    coordinates2_list.append(coordinates2)

curve1 = rs.AddInterpCurve(coordinates1_list)
curve2 = rs.AddInterpCurve(coordinates2_list)
intersection_list = rs.CurveCurveIntersection(curve1, curve2)
#print(intersection_list)
points_intersection_list = []
for intersection in intersection_list:
    if intersection[0] == 1:
        print "Intersection point on first curve: ", intersection[1]
        points_intersection_list.append(intersection[1])
#print(points_intersection_list)
distances = []
for point in points_intersection_list:
    distances.append(rs.Distance((0, 0, 0), point))
print(distances)
distanceAndPointsPaired = zip(distances, points_intersection_list)
distanceAndPointsPaired.sort()
#need to take the second velue, because the first one is the beginning of the coordinates where the curves start
closestPoint = distanceAndPointsPaired[1][1]
closestDistance = distanceAndPointsPaired[1][0]
print(closestDistance)
#Extrude the curves by the pathline with the length that equals to the distance from the (0,0,0) to the closest intersection
(x, y, z) = closestPoint
endPoint = (x, y, z + closestDistance)
pathCurve = rs.AddLine(closestPoint, endPoint)
rs.ExtrudeCurve(curve1, pathCurve)
rs.ExtrudeCurve(curve2, pathCurve)
def makeFireStair(rect, landingLevels):
    #HARD VARIABLES
    minStairWidth = 1.118
    minHeadroom = 2.032
    maxRunRise = 3.658
    minNumRisers = 3
    minGapSize = .2
    minTread = .280
    maxTread = .400
    minRiser = .100
    maxRiser = .180
    thickness = .25
    maxRisersInRun = 16
    maxWidth = 2.4
    scissorStair = False
    hdrlHeight = .900
    #hdrlTopExtension = .305
    #hdrlBtmExtension = 1*treadDepth
    #hdrlMaxProjection = .114

    #(1)Determine Run Direction
    rs.SimplifyCurve(rect)
    rectSegments = rs.ExplodeCurves(rect)
    edge1 = rectSegments[0]
    edge3 = rectSegments[1]
    if rs.CurveLength(edge1) > rs.CurveLength(edge3):
        longEdge = edge1
        shortEdge = edge3
    else:
        longEdge = edge3
        shortEdge = edge1
    longVec = rs.VectorCreate(rs.CurveStartPoint(longEdge),
                              rs.CurveEndPoint(longEdge))
    longVecRev = rs.VectorReverse(longVec)
    shortVec = rs.VectorCreate(rs.CurveStartPoint(shortEdge),
                               rs.CurveEndPoint(shortEdge))
    shortVecRev = rs.VectorReverse(shortVec)

    #(2)Stair Width
    stairWidth = (rs.CurveLength(shortEdge) - minGapSize) / 2
    if stairWidth < .6:
        print "ERROR: Stair is ridiculously too narrow."
        return

    #(3)Run Length
    runLength = rs.CurveLength(longEdge) - (stairWidth * 2)
    if runLength < 1:
        print "ERROR: Stair is ridiculously too short."
        return

    #LandingRect
    landing1Plane = rs.PlaneFromFrame(rs.CurveStartPoint(shortEdge),
                                      shortVecRev, longVecRev)
    landing1 = rs.AddRectangle(landing1Plane, rs.CurveLength(shortEdge),
                               stairWidth)
    landing2Plane = rs.PlaneFromFrame(rs.CurveEndPoint(longEdge), shortVec,
                                      longVec)
    landing2 = rs.AddRectangle(landing2Plane, rs.CurveLength(shortEdge),
                               stairWidth)

    #RunRects
    run1Plane = rs.PlaneFromFrame(
        rs.CurveEditPoints(landing1)[3], shortVecRev, longVecRev)
    run1Rect = rs.AddRectangle(run1Plane, stairWidth, runLength)
    run2Plane = rs.PlaneFromFrame(
        rs.CurveEditPoints(landing2)[3], shortVec, longVec)
    run2Rect = rs.AddRectangle(run2Plane, stairWidth, runLength)

    #(4)Num Flights between Landings
    numLevels = len(landingLevels)
    deltaLevels = []
    runsPerLevel = []
    mostRisersInRun = math.floor(runLength / minTread)
    if mostRisersInRun > maxRisersInRun:
        mostRisersInRun = maxRisersInRun
    numRuns = 0

    for i in range(0, numLevels - 1):
        deltaLevels.append(landingLevels[i + 1] - landingLevels[i])
        minNumRisers = math.ceil(deltaLevels[i] / maxRiser)
        runsPerLevel.append(math.ceil(minNumRisers / mostRisersInRun))
        numRuns = numRuns + int(runsPerLevel[i])

    #(5) Which flights
    listOfRuns = []
    for i in range(0, numRuns):
        if i % 2:  #if even
            listOfRuns.append(rs.CopyObject(run1Rect))
        else:
            listOfRuns.append(rs.CopyObject(run2Rect))

    #(6) Num Treads per run
    runsDeltaHeight = []
    for i in range(0, numLevels - 1):
        for j in range(0, int(runsPerLevel[i])):
            runsDeltaHeight.append(deltaLevels[i] / runsPerLevel[i])

    numRisersPerRun = []
    for i in range(0, numRuns):
        numRisersPerRun.append(math.ceil(runsDeltaHeight[i] / maxRiser))

    #(7) Move Runs
    elevation = 0
    landings = []
    for i in range(0, numRuns):
        elevation = elevation + runsDeltaHeight[i]
        translation = rs.VectorCreate([0, 0, elevation], [0, 0, 0])
        rs.MoveObject(listOfRuns[i], translation)
        if i % 2:
            landings.append(rs.MoveObject(rs.CopyObject(landing2),
                                          translation))
        else:
            landings.append(rs.MoveObject(rs.CopyObject(landing1),
                                          translation))

    #(8) Make Landings
    stairGeo = []
    for i in range(0, numRuns):
        dir = rs.VectorCreate([0, 0, 0], [0, 0, runsDeltaHeight[i]])
        #rs.MoveObject(landings[i], dir)
        path = rs.AddLine([0, 0, 0], [0, 0, -thickness])
        geo = rs.ExtrudeCurve(landings[i], path)
        rs.CapPlanarHoles(geo)
        stairGeo.append(geo)
        rs.DeleteObject(path)
    rs.DeleteObjects(landings)

    #(9) Draw Stairs
    runs = []
    for i in range(0, numRuns):
        runs.append(
            Run(listOfRuns[i], runsDeltaHeight[i], numRisersPerRun[i],
                thickness, i, maxTread))
        stairGeo.append(runs[i].make())
        runs[i].makeHandrail(hdrlHeight, minGapSize)
        runs[i].printStats()
        runs[i].cleanup()

    finalGeo = rs.BooleanUnion(stairGeo, delete_input=True)

    #(10) Scissor Stairs
    if scissorStair:
        pt0 = rs.CurveMidPoint(rectSegments[0])
        pt1 = rs.CurveMidPoint(rectSegments[1])
        pt2 = rs.CurveMidPoint(rectSegments[2])
        pt3 = rs.CurveMidPoint(rectSegments[3])
        mir1 = rs.MirrorObject(finalGeo, pt0, pt2, copy=True)
        mirroredStair = rs.MirrorObject(mir1, pt1, pt3, copy=False)

    #(11)Label
    rs.SetUserText(finalGeo, "Brew", "Hot Coffee")
    if scissorStair:
        rs.SetUserText(mirroredStair, "Brew", "Hot Coffee")

    #Cleanup
    rs.DeleteObjects(listOfRuns)
    rs.DeleteObjects(rectSegments)
    rs.DeleteObject(landing1)
    rs.DeleteObject(landing2)
    rs.DeleteObject(run1Rect)
    rs.DeleteObject(run2Rect)
    print "done"
    return None
    def make(self):
        runVector = rs.VectorCreate(rs.CurveEndPoint(self.runLongEdge),
                                    rs.CurveStartPoint(self.runLongEdge))
        unitRunVec = rs.VectorUnitize(runVector)
        treadVec = rs.VectorScale(unitRunVec, self.treadLength)
        riseVec = rs.VectorCreate([0, 0, self.riserHeight], [0, 0, 0])

        newPt = [
            rs.CurveStartPoint(self.firstRiserEdge).X,
            rs.CurveStartPoint(self.firstRiserEdge).Y,
            rs.CurveStartPoint(self.firstRiserEdge).Z - self.deltaHeight
        ]

        ptList = []
        ptList.append(rs.AddPoint(newPt))
        for i in range(self.numRisers):
            tempPt = rs.CopyObject(ptList[-1])
            rs.MoveObject(tempPt, riseVec)
            ptList.append(tempPt)
            tempPt = rs.CopyObject(ptList[-1])
            rs.MoveObject(tempPt, treadVec)
            ptList.append(tempPt)

        #stringer construct offset line
        undersideLine = rs.AddLine(ptList[0], ptList[-1])
        closestPtParam = rs.CurveClosestPoint(undersideLine, ptList[1])
        closestPt = rs.EvaluateCurve(undersideLine, closestPtParam)
        perpVec = rs.VectorUnitize(rs.VectorCreate(ptList[1], closestPt))
        stringerBtm = rs.MoveObject(undersideLine,
                                    rs.VectorScale(perpVec, -self.thickness))
        cnstrLine = rs.ScaleObject(stringerBtm, rs.CurveMidPoint(stringerBtm),
                                   [2, 2, 2])

        #line going down
        btmPt = rs.MoveObject(ptList[0], [0, 0, -self.thickness])
        moveDir = rs.VectorCreate(ptList[2], ptList[1])
        btmPtMoved = rs.MoveObject(rs.CopyObject(btmPt),
                                   rs.VectorScale(moveDir, 3))
        btmLineCnstr = rs.AddLine(btmPt, btmPtMoved)
        ptIntersectBtm = rs.AddPoint(
            rs.LineLineIntersection(btmLineCnstr, cnstrLine)[0])  #yes

        #top lines
        topVec = rs.VectorScale(
            rs.VectorUnitize(rs.VectorCreate(ptList[-1], ptList[-2])),
            self.extenionLength)
        topPt1 = rs.MoveObject(ptList[-1], topVec)
        topPtDown = rs.MoveObject(rs.CopyObject(topPt1),
                                  [0, 0, -self.thickness])
        extLengthTemp = self.extenionLength
        if extLengthTemp < .1:
            extLengthTemp = .1
        topVec = rs.VectorScale(
            rs.VectorUnitize(rs.VectorCreate(ptList[-1], ptList[-2])),
            extLengthTemp)
        topPtTemp = rs.MoveObject(rs.CopyObject(topPtDown), topVec)
        topLine = rs.AddLine(topPtDown, topPtTemp)
        ptIntersectTop = rs.AddPoint(
            rs.LineLineIntersection(topLine, cnstrLine)[0])  #yes

        ptList.append(topPtDown)
        ptList.append(ptIntersectTop)
        ptList.append(ptIntersectBtm)

        stringer = rs.AddPolyline(ptList)
        closeCrv = rs.AddLine(rs.CurveStartPoint(stringer),
                              rs.CurveEndPoint(stringer))

        newStringer = rs.JoinCurves([stringer, closeCrv], True)

        stair = rs.ExtrudeCurve(newStringer, self.firstRiserEdge)

        rs.CapPlanarHoles(stair)

        #make handrail guide curve
        topOfNosing = rs.AddLine(ptList[1], ptList[-5])
        self.guideCrv = topOfNosing

        rs.DeleteObject(btmLineCnstr)
        rs.DeleteObject(btmPtMoved)
        rs.DeleteObject(btmLineCnstr)
        rs.DeleteObject(ptIntersectTop)
        rs.DeleteObject(undersideLine)
        rs.DeleteObject(topPtTemp)
        rs.DeleteObject(topLine)
        rs.DeleteObject(stringer)
        rs.DeleteObject(newStringer)
        rs.DeleteObjects(ptList)

        return stair
Beispiel #22
0
line2 = rs.AddLine(points[0], endPoint)

param = rs.SurfaceClosestPoint(face, points[1])
normal = rs.SurfaceNormal(face, param)
normalVect = distance * rs.VectorReverse(normal)
endPoint = points[1] + normalVect

line3 = rs.AddLine(points[1], endPoint)

curve1 = rs.AddFilletCurve(line, line2, radius)
curve2 = rs.AddFilletCurve(line, line3, radius)

curve = rs.JoinCurves([curve1, curve2], True)

profile = rs.ExtrudeCurve(curve, path)

splitSolids = rs.SplitBrep(solid, profile)

area1 = rs.SurfaceArea(splitSolids[0])
area2 = rs.SurfaceArea(splitSolids[1])
area3 = rs.SurfaceArea(splitSolids[2])

rs.DeleteObject(solid)

i = 0
swap = True

while swap == True:
    swap = False
    for i in range(0, 1):
Beispiel #23
0
#rs.DeleteObjects([A_lines, Poly_base, Poly_top])

#Create group
rs.AddGroup("Legs")
rs.AddObjectsToGroup(Legs, "Legs")

#Construct the table top, draw offset curve
offset_crv = rs.OffsetCurve(Poly_top,
                            Cen_top,
                            -(offset_dist),
                            normal=None,
                            style=1)

rs.CurrentLayer("Tabletop")
#extrude Offset Curve
extruded_crv = rs.ExtrudeCurve(offset_crv, extrude_path)

#cap Extruded shape
closed_polysrf = rs.CapPlanarHoles(extruded_crv)

#Delete objects
erase = [A_lines, Poly_base, Poly_top, offset_crv]
rs.DeleteObjects(erase)

#Redraw geometry
rs.EnableRedraw(True)

#zoom extents of drawn geometry
rs.ZoomExtents()

rs.CurrentLayer("Default")
Beispiel #24
0
import rhinoscriptsyntax as rs

p = rs.AddPoint(0, 0, 0)
q = rs.AddPoint(0, 0, 10)
t = rs.AddPoint(0, 5, 10)
#l=rs.AddLine(p,q)
l = rs.AddArc3Pt(p, q, t)
c = rs.AddCircle(p, 5)
m = rs.RotateObject(c, p, 45, None, False)
cy = rs.ExtrudeCurve(m, l)

for i in range(1, 25):
    i = i * 5
    p = rs.AddPoint(0, i, i)
    q = rs.AddPoint(i, i, i * 10)
    t = rs.AddPoint(i, i * 5, 0)
    l = rs.AddArc3Pt(p, q, t)
    c = rs.AddCircle(p, 5)
    m = rs.RotateObject(c, p, 45, None, False)
    cy = rs.ExtrudeCurve(c, l)