Ejemplo n.º 1
0
def planeexample():
    origin = rs.GetPoint("Plane origin")
    if not origin: return

    ptX = rs.GetPoint("Plane X-axis", origin)
    if not ptX: return
    ptY = rs.GetPoint("Plane Y-axis", origin)
    if not ptY: return
	
    x = rs.Distance(origin, ptX)
    y = rs.Distance(origin, ptY)
    plane = rs.PlaneFromPoints(origin, ptX, ptY)
    rs.AddPlaneSurface(plane, 1.0, 1.0)
    rs.AddPlaneSurface(plane, x, y)
Ejemplo n.º 2
0
def addplane(m, n, dx, dy):
    for i in range(m):
        for j in range(n):
            plane = rs.WorldXYPlane()
            origin = (i * dx, j * dy, 0)
            newplane = rs.MovePlane(plane, origin)
            rs.AddPlaneSurface(newplane, dx, dy)
def cutAtPlan(level):
    planPlane = rs.AddPlaneSurface([-1000,-1000,level], 3000, 3000)
    baseLayer = rs.AddLayer("60_PLANS")
    newParent = rs.AddLayer("PLAN_"+str(level), parent = baseLayer)
    origLayer = rs.CurrentLayer()
    shortName = rs.LayerName(origLayer, fullpath = False)
    
    #newChildsParent = rs.AddLayer( , parent = newParent)
    newChild = rs.AddLayer(shortName, parent = newParent, color = rs.LayerColor(origLayer))
    rs.CurrentLayer(newChild)
    
    objs = rs.ObjectsByLayer(origLayer)
    #if len(objs)<1:
    #    skip = True
    intersectCrvs = []
    tempCrv = None
    for obj in objs:
        if rs.IsBrep(obj):
            
            tempCrv = rs.IntersectBreps(obj, planPlane)
        if tempCrv != None:
            intersectCrvs.append(tempCrv)
    
    for crv in intersectCrvs:
        if not None:
            rs.ObjectLayer(crv, newChild)
    
    rs.DeleteObject(planPlane)
    rs.CurrentLayer(origLayer)
Ejemplo n.º 4
0
def Build_Key(Point, colors, tol):
    """
    Build key for tolerance shading.
    Create color coded text objects and planes.
    """
    low2 = "-" + str(tol[2]) + '"' + " and lower"
    low1 = "-" + str(tol[2]) + '"' + " to -" + str(tol[1]) + '"'
    low0 = "-" + str(tol[1]) + " to -" + str(tol[0]) + '"'
    good = "-" + str(tol[0]) + " to +" + str(tol[0]) + '"'
    high0 = "+" + str(tol[0]) + " to +" + str(tol[1]) + '"'
    high1 = "+" + str(tol[1]) + " to +" + str(tol[2]) + '"'
    high2 = "+" + str(tol[2]) + " and higher"

    stringList = [high2, high1, high0, good, low0, low1, low2]
    objs = []
    for i in range(len(stringList)):
        pt = rs.coerce3dpoint([0, 0, 1.5 * i + 3])
        plane = rs.PlaneFromNormal(pt + Point, [0, -1, 0], [1, 0, 0])
        txt = rs.AddText(stringList[i], plane)
        srf = rs.AddPlaneSurface(plane, 1, 1)
        rs.MoveObject(srf, [-2, 0, 0])
        stringColor = "Tol_" + colors[i].ToString().split("[")[1].rstrip("]")

        mt.OrganizeLayer(stringColor,
                         Objects=[srf, txt],
                         Render=colors[i],
                         Color=colors[i])
Ejemplo n.º 5
0
def cutAtPlan(level, join):
    cutPlane = rs.AddPlaneSurface([-1000,-1000,level], 3000, 3000)
    plane = rs.PlaneFromNormal([-1000,-1000,0], [0,0,1])
    planPlane = rs.AddPlaneSurface(plane, 3000, 3000)
    
    objs = rs.VisibleObjects()
    intersectCrvs = []
    tempCrv = None
    for obj in objs:
        if rs.IsBrep(obj):
            tempCrv = rs.IntersectBreps(obj, cutPlane)
        if tempCrv:
            rs.MatchObjectAttributes(tempCrv, obj)
            newCrvs = flatten(tempCrv)
    rs.DeleteObject(cutPlane)
    rs.DeleteObject(planPlane)
Ejemplo n.º 6
0
def RunCommand():
  rc, corners = Rhino.Input.RhinoGet.GetRectangle()
  if rc <> Rhino.Commands.Result.Success:
      return rc

  plane = Rhino.Geometry.Plane(corners[0], corners[1], corners[2])
  u_dir = rs.Distance(corners[0], corners[1])
  v_dir = rs.Distance(corners[1], corners[2])
  rs.AddPlaneSurface(plane, u_dir, v_dir)
Ejemplo n.º 7
0
def trimSurface(sur):
    #sur = getSurfaces()['ref']
    pl = rs.AddPlaneSurface(rs.WorldXYPlane(), 40000.0, 6000.0)
    rs.MoveObject(pl, (-3000, -500, 2100))
    lsrf = rs.SplitBrep(sur, pl)
    rs.DeleteObject(pl)
    rs.DeleteObject(lsrf[0])
    rs.DeleteObject(sur)
    rs.ObjectName(lsrf[1], 'mod')
    return lsrf[1]
Ejemplo n.º 8
0
def RecursiveSquare(plane, u_dir, v_dir):
    
    if u_dir == 0: # an equality check
        return 1
        
        
    if v_dir == 0:
        return 1
    
    else:
        rs.AddPlaneSurface(plane, u_dir, v_dir)
        
        return RecursiveSquare(plane, u_dir, v_dir)
Ejemplo n.º 9
0
 def offset_vector(self, point, cross_section_index, point_index):
     modulo = len(self.point_lists[cross_section_index - 1])
     prev_point_1 = self.point_lists[cross_section_index - 1][
         (point_index - 2) %
         modulo] if cross_section_index % 2 == 0 else self.point_lists[
             cross_section_index - 1][(point_index - 1) % modulo]
     prev_point_2 = self.point_lists[cross_section_index - 1][
         (point_index - 1) %
         modulo] if cross_section_index % 2 == 0 else self.point_lists[
             cross_section_index - 1][point_index]
     in_between_vector = rs.VectorAdd(rs.VectorCreate(prev_point_1, point),
                                      rs.VectorCreate(prev_point_2, point))
     normal_vector = rs.SurfaceNormal(
         self.brep, rs.SurfaceClosestPoint(self.brep, point))
     plane = rs.PlaneFromFrame(point, in_between_vector, normal_vector)
     vector = rs.SurfaceNormal(rs.AddPlaneSurface(plane, 1, 1), [0, 0])
     unit_vector = rs.VectorUnitize(vector)
     return [rs.VectorScale(unit_vector, 2), in_between_vector]
Ejemplo n.º 10
0
def contourPt(obj, pt):
    """
    creates a contour according to xy plane at specified height
    obj: single object to contour
    pt: a point to contour at
    """
    planPlane = rs.AddPlaneSurface([-10000, -10000, pt[2]], 30000, 30000)
    intersectCrvs = []
    tempCrv = None

    if rs.IsBrep(obj):
        tempCrv = rs.IntersectBreps(obj, planPlane)
    if tempCrv != None:
        objName = rs.ObjectName(obj)
        rs.ObjectName(tempCrv, objName)
        intersectCrvs.append(tempCrv)
        rs.MatchObjectAttributes(tempCrv, obj)
    rs.DeleteObject(planPlane)
    return intersectCrvs
Ejemplo n.º 11
0
def CutSect(SurfaceId, SpanStation):
    # SpanStation is assumed to be along the y direction, in the range [0,1]

    (Xmin, Ymin, Zmin, Xmax, Ymax, Zmax) = ObjectsExtents(SurfaceId)

    YStation = Ymin + (Ymax - Ymin) * SpanStation
    OriginX = Xmin - 1
    OriginZ = Zmin - 1

    CutPlane = rs.PlaneFromPoints((OriginX, YStation, OriginZ),
                                  (Xmax + 1, YStation, OriginZ),
                                  (OriginX, YStation, Zmax + 1))
    CutPlaneSrf = rs.AddPlaneSurface(
        CutPlane,
        max([(Xmax - Xmin), (Ymax - Ymin), (Zmax - Zmin)]) + 1,
        max([(Xmax - Xmin), (Ymax - Ymin), (Zmax - Zmin)]) + 1)

    I = rs.IntersectBreps(CutPlaneSrf, SurfaceId)
    Section = I[0]
    rs.DeleteObject(CutPlaneSrf)

    (Xmin, Ymin, Zmin, Xmax, Ymax, Zmax) = ObjectsExtents(Section)

    # Find the apparent chord of the section (that is, the line connecting the fore
    # most and aftmost points on the curve
    DivPoints = rs.DivideCurve(Section, 200)

    Xs = []
    Ys = []
    Zs = []
    for DP in DivPoints:
        list.append(Xs, DP[0])
        list.append(Ys, DP[1])
        list.append(Zs, DP[2])

    val, idx = min((val, idx) for (idx, val) in enumerate(Xs))
    LeadingPoint = [Xs[idx], Ys[idx], Zs[idx]]
    val, idx = max((val, idx) for (idx, val) in enumerate(Xs))
    TrailingPoint = [Xs[idx], Ys[idx], Zs[idx]]

    Chord = rs.AddLine(TrailingPoint, LeadingPoint)

    return Section, Chord
 def initSlice(self, init_geo):
     result = []
     plane = rs.PlaneFromPoints((-5000, -5000, 0), (0, -5000, 0),
                                (-5000, 0, 0))
     planeSrf = rs.AddPlaneSurface(plane, 10000, 10000)
     crv = rs.IntersectBreps(init_geo, planeSrf)
     result.append(crv)
     while True:
         vec = rs.CreateVector((0, 0, self.layer_height))
         planeSrf = rs.MoveObject(planeSrf, vec)
         crv = rs.IntersectBreps(init_geo, planeSrf)
         if crv == None:
             break
         else:
             result.append(crv)
     result = rs.JoinCurves(result)
     for i in range(1, len(result)):
         if not rs.CurveDirectionsMatch(result[0], result[i]):
             rs.ReverseCurve(result[i])
     return result
Ejemplo n.º 13
0
def flatten(crvs):
    planPlane = rs.AddPlaneSurface([-1000,-1000,0], 3000, 3000)
    
    #projectedCrvs = rs.ProjectCurveToSurface(crvs, planPlane, [0,0,-1])
    projectedCrvs = []
    
    for crv in crvs:
        explodedCrvs = rs.ExplodeCurves(crv)
        if explodedCrvs:
            for explodedCrv in explodedCrvs:
                tempCrv = rs.ProjectCurveToSurface(explodedCrv, planPlane, [0,0,-1])
                rs.DeleteObject(explodedCrv)
                rs.MatchObjectAttributes(tempCrv, crv)
                projectedCrvs.append(tempCrv)
            rs.DeleteObject(crv)
        else:
            tempCrv = rs.ProjectCurveToSurface(crv, planPlane, [0,0,-1])
            rs.MatchObjectAttributes(tempCrv, crv)
            rs.DeleteObjects(crv)
            projectedCrvs.append(tempCrv)
        
    rs.DeleteObject(planPlane)
    
    return projectedCrvs
Ejemplo n.º 14
0
def WhoFramedTheSurface():
    surface_id = rs.GetObject("Surface to frame", 8, True, True)
    if not surface_id: return

    count = rs.GetInteger("Number of iterations per direction", 20, 2)
    if not count: return

    udomain = rs.SurfaceDomain(surface_id, 0)
    vdomain = rs.SurfaceDomain(surface_id, 1)
    ustep = (udomain[1] - udomain[0]) / count
    vstep = (vdomain[1] - vdomain[0]) / count

    rs.EnableRedraw(False)
    u = udomain[0]
    while u <= udomain[1]:
        v = vdomain[0]
        while v <= vdomain[1]:
            pt = rs.EvaluateSurface(surface_id, u, v)
            if rs.Distance(pt, rs.BrepClosestPoint(surface_id, pt)[0]) < 0.1:
                srf_frame = rs.SurfaceFrame(surface_id, [u, v])
                rs.AddPlaneSurface(srf_frame, 1.0, 1.0)
            v += vstep
        u += ustep
    rs.EnableRedraw(True)
Ejemplo n.º 15
0
s1 = rs.AddPoint(0, 0, 20)
e1 = rs.AddPoint(20, 0, 0)

s2 = rs.AddPoint(0, 40, 10)
e2 = rs.AddPoint(30, 40, 0)

#lineFrom = rs.GetPoint("Plane From:")
#lineTo = rs.GetPoint("Plane To:")
#distance = rs.Distance(lineFrom, lineTo)
#plane = rs.LinePlane([lineFrom, lineTo])
#rs.AddPlaneSurface( plane, distance, distance )

distance = rs.Distance(s1, e1)
plane = rs.LinePlane([s1, e1])
p1 = rs.AddPlaneSurface(plane, distance, distance)
rs.HideObject(p1)

distance = rs.Distance(s2, e2)
plane = rs.LinePlane([s2, e2])
p2 = rs.AddPlaneSurface(plane, distance, distance)
rs.HideObject(p2)

l1 = rs.AddLine(s1, e1)
l2 = rs.AddLine(s2, e2)

if l1:
    points1 = rs.DivideCurve(l1, 20)
    for point in points1:
        rs.AddPoint(point)
    rs.MoveObjects(points1, y)
import rhinoscriptsyntax as rs

idSurface = rs.GetObject("Surface to frame", 8, True, True)
faces = []

intCount = rs.GetInteger("Number of iterations per direction", 20, 2)

uDomain = rs.SurfaceDomain(idSurface, 0)
vDomain = rs.SurfaceDomain(idSurface, 1)
uStep = int((uDomain[1] - uDomain[0]) / intCount)
vStep = int((vDomain[1] - vDomain[0]) / intCount)

rs.EnableRedraw(False)
for u in range(int(uDomain[0]), int(uDomain[1]), int(uStep)):
    for v in range(int(vDomain[0]), int(vDomain[1]), int(vStep)):
        pt = rs.EvaluateSurface(idSurface, u, v)
        srfFrame = rs.SurfaceFrame(idSurface, [u, v])
        rs.AddPlaneSurface(srfFrame, 2.0, 2.0)
        #rs.AddEllipse(srfFrame, 1.0, 3.0)
        component = rs.GetObject("component to populate", rs.filter.mesh)
        faces = rs.MeshFaces(component, False)
        rs.AddMesh(faces, srfFrame)

rs.EnableRedraw(True)
def transonic_airliner(
    Propulsion=1,  # 1 - twin, 2 - quad 
    EngineDia=2.9,  # Diameter of engine intake highlight 
    FuselageScaling=[55.902, 55.902, 55.902],  # [x,y,z] scale factors
    NoseLengthRatio=0.182,  # Proportion of forward tapering section of the fuselage 
    TailLengthRatio=0.293,  # Proportion of aft tapering section of the fuselage
    WingScaleFactor=44.56,
    WingChordFactor=1.0,
    Topology=1,  # Topology = 2 will yield a box wing airliner - use with caution, this is just for demo purposes.
    SpanStation1=0.31,  # Inboard engine at this span station
    SpanStation2=0.625,  # Outboard engine at this span station (ignored if Propulsion=1)
    EngineCtrBelowLE=0.3558,  # Engine below leading edge, normalised by the length of the nacelle - range: [0.35,0.5]
    EngineCtrFwdOfLE=0.9837,  # Engine forward of leading edge, normalised by the length of the nacelle - range: [0.85,1.5]
    Scarf_deg=3):  # Engine scarf angle

    # Build fuselage geometry
    rs.EnableRedraw(False)
    try:
        FuselageOMLSurf, SternPoint = fuselage_oml.FuselageOML(
            NoseLengthRatio,
            TailLengthRatio,
            Scaling=FuselageScaling,
            NoseCoordinates=[0, 0, 0],
            CylindricalMidSection=False,
            SimplificationReqd=False)
    except:
        print "Fuselage fitting failed - stopping."
        return

    FuselageHeight = FuselageScaling[2] * 0.105
    FuselageLength = FuselageScaling[0]
    FuselageWidth = FuselageScaling[1] * 0.106
    rs.Redraw()

    if FuselageOMLSurf is None:
        print "Failed to fit fuselage surface, stopping."
        return

    FSurf = rs.CopyObject(FuselageOMLSurf)

    # Position of the apex of the wing
    if FuselageHeight < 8.0:
        WingApex = [0.1748 * FuselageLength, 0,
                    -0.0523 * FuselageHeight]  #787:[9.77,0,-0.307]
    else:
        WingApex = [0.1748 * FuselageLength, 0,
                    -0.1 * FuselageHeight]  #787:[9.77,0,-0.307]

    # Set up the wing object, including the list of user-defined functions that
    # describe the spanwise variations of sweep, dihedral, etc.
    LooseSurf = 1
    if Topology == 1:
        SegmentNo = 10
        Wing = liftingsurface.LiftingSurface(WingApex,
                                             ta.mySweepAngleFunctionAirliner,
                                             ta.myDihedralFunctionAirliner,
                                             ta.myTwistFunctionAirliner,
                                             ta.myChordFunctionAirliner,
                                             ta.myAirfoilFunctionAirliner,
                                             LooseSurf,
                                             SegmentNo,
                                             TipRequired=True)
    elif Topology == 2:
        SegmentNo = 101
        Wing = liftingsurface.LiftingSurface(WingApex,
                                             ta.mySweepAngleFunctionAirliner,
                                             bw.myDihedralFunctionBoxWing,
                                             ta.myTwistFunctionAirliner,
                                             ta.myChordFunctionAirliner,
                                             ta.myAirfoilFunctionAirliner,
                                             LooseSurf,
                                             SegmentNo,
                                             TipRequired=True)

    # Instantiate the wing object and add it to the document
    rs.EnableRedraw(False)
    WingSurf, ActualSemiSpan, LSP_area, RootChord, AR, WingTip = Wing.GenerateLiftingSurface(
        WingChordFactor, WingScaleFactor)
    rs.Redraw()

    if Topology == 1:
        # Add wing to body fairing
        WTBFXCentre = WingApex[
            0] + RootChord / 2.0 + RootChord * 0.1297  # 787: 23.8
        if FuselageHeight < 8.0:
            WTBFZ = RootChord * 0.009  #787: 0.2
            WTBFheight = 0.1212 * RootChord  #787:2.7
            WTBFwidth = 1.08 * FuselageWidth
        else:
            WTBFZ = WingApex[2] + 0.005 * RootChord
            WTBFheight = 0.09 * RootChord
            WTBFwidth = 1.15 * FuselageWidth

        WTBFlength = 1.167 * RootChord  #787:26

        WTBFXStern = WTBFXCentre + WTBFlength / 2.0

        CommS = "_Ellipsoid %3.2f,0,%3.2f %3.2f,0,%3.2f %3.2f,%3.2f,%3.2f %3.2f,0,%3.2f " % (
            WTBFXCentre, WTBFZ, WTBFXStern, WTBFZ, 0.5 *
            (WTBFXCentre + WTBFXStern), 0.5 * WTBFwidth, WTBFZ, 0.5 *
            (WTBFXCentre + WTBFXStern), WTBFheight)

        rs.EnableRedraw(False)

        rs.CurrentView("Perspective")
        rs.Command(CommS)
        LO = rs.LastCreatedObjects()
        WTBF = LO[0]
        rs.Redraw()

        # Trim wing inboard section
        CutCirc = rs.AddCircle3Pt((0, WTBFwidth / 4, -45),
                                  (0, WTBFwidth / 4, 45),
                                  (90, WTBFwidth / 4, 0))
        CutCircDisk = rs.AddPlanarSrf(CutCirc)
        CutDisk = CutCircDisk[0]
        rs.ReverseSurface(CutDisk, 1)
        rs.TrimBrep(WingSurf, CutDisk)
    elif Topology == 2:
        # Overlapping wing tips
        CutCirc = rs.AddCircle3Pt((0, 0, -45), (0, 0, 45), (90, 0, 0))
        CutCircDisk = rs.AddPlanarSrf(CutCirc)
        CutDisk = CutCircDisk[0]
        rs.ReverseSurface(CutDisk, 1)
        rs.TrimBrep(WingSurf, CutDisk)

    # Engine installation (nacelle and pylon)

    if Propulsion == 1:
        # Twin, wing mounted
        SpanStation = SpanStation1
        NacelleLength = 1.95 * EngineDia
        rs.EnableRedraw(False)
        EngineSection, Chord = act.CutSect(WingSurf, SpanStation)
        CEP = rs.CurveEndPoint(Chord)
        EngineStbd, PylonStbd = engine.TurbofanNacelle(
            EngineSection,
            Chord,
            CentreLocation=[
                CEP.X - EngineCtrFwdOfLE * NacelleLength, CEP.Y,
                CEP.Z - EngineCtrBelowLE * NacelleLength
            ],
            ScarfAngle=Scarf_deg,
            HighlightRadius=EngineDia / 2.0,
            MeanNacelleLength=NacelleLength)
        rs.Redraw()
    elif Propulsion == 2:
        # Quad, wing-mounted
        NacelleLength = 1.95 * EngineDia

        rs.EnableRedraw(False)
        EngineSection, Chord = act.CutSect(WingSurf, SpanStation1)
        CEP = rs.CurveEndPoint(Chord)

        EngineStbd1, PylonStbd1 = engine.TurbofanNacelle(
            EngineSection,
            Chord,
            CentreLocation=[
                CEP.X - EngineCtrFwdOfLE * NacelleLength, CEP.Y,
                CEP.Z - EngineCtrBelowLE * NacelleLength
            ],
            ScarfAngle=Scarf_deg,
            HighlightRadius=EngineDia / 2.0,
            MeanNacelleLength=NacelleLength)

        rs.DeleteObjects([EngineSection, Chord])

        EngineSection, Chord = act.CutSect(WingSurf, SpanStation2)
        CEP = rs.CurveEndPoint(Chord)

        EngineStbd2, PylonStbd2 = engine.TurbofanNacelle(
            EngineSection,
            Chord,
            CentreLocation=[
                CEP.X - EngineCtrFwdOfLE * NacelleLength, CEP.Y,
                CEP.Z - EngineCtrBelowLE * NacelleLength
            ],
            ScarfAngle=Scarf_deg,
            HighlightRadius=EngineDia / 2.0,
            MeanNacelleLength=NacelleLength)
        rs.Redraw()

    # Script for generating and positioning the fin
    rs.EnableRedraw(False)
    # Position of the apex of the fin
    P = [0.6524 * FuselageLength, 0.003, FuselageHeight * 0.384]
    #P = [36.47,0.003,2.254]55.902
    RotVec = rs.VectorCreate([1, 0, 0], [0, 0, 0])
    LooseSurf = 1
    SegmentNo = 200
    Fin = liftingsurface.LiftingSurface(P, tail.mySweepAngleFunctionFin,
                                        tail.myDihedralFunctionFin,
                                        tail.myTwistFunctionFin,
                                        tail.myChordFunctionFin,
                                        tail.myAirfoilFunctionFin, LooseSurf,
                                        SegmentNo)
    ChordFactor = 1.01  #787:1.01
    if Topology == 1:
        ScaleFactor = WingScaleFactor / 2.032  #787:21.93
    elif Topology == 2:
        ScaleFactor = WingScaleFactor / 3.5
    FinSurf, FinActualSemiSpan, FinArea, FinRootChord, FinAR, FinTip = Fin.GenerateLiftingSurface(
        ChordFactor, ScaleFactor)
    FinSurf = rs.RotateObject(FinSurf, P, 90, axis=RotVec)
    FinTip = rs.RotateObject(FinTip, P, 90, axis=RotVec)

    if Topology == 1:
        # Tailplane
        P = [0.7692 * FuselageLength, 0.000, FuselageHeight * 0.29]
        RotVec = rs.VectorCreate([1, 0, 0], [0, 0, 0])
        LooseSurf = 1
        SegmentNo = 100
        TP = liftingsurface.LiftingSurface(P, tail.mySweepAngleFunctionTP,
                                           tail.myDihedralFunctionTP,
                                           tail.myTwistFunctionTP,
                                           tail.myChordFunctionTP,
                                           tail.myAirfoilFunctionTP, LooseSurf,
                                           SegmentNo)
        ChordFactor = 1.01
        ScaleFactor = 0.388 * WingScaleFactor  #787:17.3
        TPSurf, TPActualSemiSpan, TPArea, TPRootChord, TPAR, TPTip = TP.GenerateLiftingSurface(
            ChordFactor, ScaleFactor)

    rs.EnableRedraw(True)

    rs.DeleteObjects([EngineSection, Chord])
    try:
        rs.DeleteObjects([CutCirc])
    except:
        pass

    try:
        rs.DeleteObjects([CutCircDisk])
    except:
        pass

    # Windows

    # Cockpit windows:
    rs.EnableRedraw(False)

    CockpitWindowTop = 0.305 * FuselageHeight

    CWC1s, CWC2s, CWC3s, CWC4s = fuselage_oml.CockpitWindowContours(
        Height=CockpitWindowTop, Depth=6)

    FuselageOMLSurf, Win1 = rs.SplitBrep(FuselageOMLSurf,
                                         CWC1s,
                                         delete_input=True)
    FuselageOMLSurf, Win2 = rs.SplitBrep(FuselageOMLSurf,
                                         CWC2s,
                                         delete_input=True)
    FuselageOMLSurf, Win3 = rs.SplitBrep(FuselageOMLSurf,
                                         CWC3s,
                                         delete_input=True)
    FuselageOMLSurf, Win4 = rs.SplitBrep(FuselageOMLSurf,
                                         CWC4s,
                                         delete_input=True)

    rs.DeleteObjects([CWC1s, CWC2s, CWC3s, CWC4s])

    (Xmin, Ymin, Zmin, Xmax, Ymax,
     Zmax) = act.ObjectsExtents([Win1, Win2, Win3, Win4])
    CockpitBulkheadX = Xmax

    CockpitWallPlane = rs.PlaneFromPoints([CockpitBulkheadX, -15, -15],
                                          [CockpitBulkheadX, 15, -15],
                                          [CockpitBulkheadX, -15, 15])

    CockpitWall = rs.AddPlaneSurface(CockpitWallPlane, 30, 30)

    if 'WTBF' in locals():
        rs.TrimBrep(WTBF, CockpitWall)

    rs.DeleteObject(CockpitWall)

    # Window lines
    WIN = [1]
    NOWIN = [0]

    # A typical window pattern (including emergency exit windows)
    WinVec = WIN + 2 * NOWIN + 9 * WIN + 3 * NOWIN + WIN + NOWIN + 24 * WIN + 2 * NOWIN + WIN + NOWIN + 14 * WIN + 2 * NOWIN + WIN + 20 * WIN + 2 * NOWIN + WIN + NOWIN + 20 * WIN

    if FuselageHeight < 8.0:
        # Single deck
        WindowLineHeight = 0.3555 * FuselageHeight
        WinX = 0.1157 * FuselageLength
        WindowPitch = 0.609
        WinInd = -1
        while WinX < 0.75 * FuselageLength:
            WinInd = WinInd + 1
            if WinVec[WinInd] == 1 and WinX > CockpitBulkheadX:
                WinStbd, WinPort, FuselageOMLSurf = fuselage_oml.MakeWindow(
                    FuselageOMLSurf, WinX, WindowLineHeight)
                act.AssignMaterial(WinStbd, "Plexiglass")
                act.AssignMaterial(WinPort, "Plexiglass")
            WinX = WinX + WindowPitch
    else:
        # Fuselage big enough to accommodate two decks
        # Lower deck
        WindowLineHeight = 0.17 * FuselageHeight  #0.166
        WinX = 0.1 * FuselageLength  #0.112
        WindowPitch = 0.609
        WinInd = 0
        while WinX < 0.757 * FuselageLength:
            WinInd = WinInd + 1
            if WinVec[WinInd] == 1 and WinX > CockpitBulkheadX:
                WinStbd, WinPort, FuselageOMLSurf = fuselage_oml.MakeWindow(
                    FuselageOMLSurf, WinX, WindowLineHeight)
                act.AssignMaterial(WinStbd, "Plexiglass")
                act.AssignMaterial(WinPort, "Plexiglass")
            WinX = WinX + WindowPitch
        # Upper deck
        WindowLineHeight = 0.49 * FuselageHeight
        WinX = 0.174 * FuselageLength  #0.184
        WinInd = 0
        while WinX < 0.757 * FuselageLength:
            WinInd = WinInd + 1
            if WinVec[WinInd] == 1 and WinX > CockpitBulkheadX:
                WinStbd, WinPort, FuselageOMLSurf = fuselage_oml.MakeWindow(
                    FuselageOMLSurf, WinX, WindowLineHeight)
                act.AssignMaterial(WinStbd, "Plexiglass")
                act.AssignMaterial(WinPort, "Plexiglass")
            WinX = WinX + WindowPitch

    rs.Redraw()

    act.AssignMaterial(FuselageOMLSurf, "White_composite_external")
    act.AssignMaterial(WingSurf, "White_composite_external")
    try:
        act.AssignMaterial(TPSurf, "ShinyBARedMetal")
    except:
        pass
    act.AssignMaterial(FinSurf, "ShinyBARedMetal")
    act.AssignMaterial(Win1, "Plexiglass")
    act.AssignMaterial(Win2, "Plexiglass")
    act.AssignMaterial(Win3, "Plexiglass")
    act.AssignMaterial(Win4, "Plexiglass")

    # Mirror the geometry as required
    act.MirrorObjectXZ(WingSurf)
    act.MirrorObjectXZ(WingTip)
    try:
        act.MirrorObjectXZ(TPSurf)
        act.MirrorObjectXZ(TPTip)
    except:
        pass
    if Propulsion == 1:
        for ObjId in EngineStbd:
            act.MirrorObjectXZ(ObjId)
        act.MirrorObjectXZ(PylonStbd)
    elif Propulsion == 2:
        for ObjId in EngineStbd1:
            act.MirrorObjectXZ(ObjId)
        act.MirrorObjectXZ(PylonStbd1)
        for ObjId in EngineStbd2:
            act.MirrorObjectXZ(ObjId)
        act.MirrorObjectXZ(PylonStbd2)

    rs.DeleteObject(FSurf)
    rs.Redraw()
Ejemplo n.º 18
0
# Load the Optitrack CSV file parser module.
import optitrack.csv_reader as csv
from optitrack.geometry import *

# Find the path to the test data file located alongside the script.
filename = os.path.join( os.path.abspath(os.path.dirname(__file__)), "sample_optitrack_take.csv")

# Read the file.
take = csv.Take().readCSV(filename)

# Print out some statistics
print "Found rigid bodies:", take.rigid_bodies.keys()

# Process the first rigid body into a set of planes.
bodies = take.rigid_bodies.values()

# for now:
xaxis = [1,0,0]
yaxis = [0,1,0]

if len(bodies) > 0:
    body = bodies[0]
    for pos,rot in zip(body.positions, body.rotations):
        if pos is not None and rot is not None:
            xaxis, yaxis = quaternion_to_xaxis_yaxis(rot)
            plane = rs.PlaneFromFrame(pos, xaxis, yaxis)

            # create a visible plane, assuming units are in meters
            rs.AddPlaneSurface( plane, 0.1, 0.1 )
Ejemplo n.º 19
0
currentl = rs.CurrentLayer("Heel_0")

copy0 = rs.CopyObject(hull)
rs.ObjectLayer(copy0, "Heel_0")

rs.LayerVisible("Default", False)

#####################################################
####                                             ####
#### Creating DWL and obtaining submerged volume ####
####                                             ####
#####################################################

aux_plane = rs.PlaneFromFrame( [-5,-50,draft], [1,0,0], [0,1,0] )
dwl = rs.AddPlaneSurface(aux_plane, 100, 100)

inter = rs.BooleanIntersection(copy0, dwl, False)

Nabla = rs.SurfaceVolumeCentroid(inter)
if Nabla:
    cb = rs.AddPoint(Nabla[0])

Volume0 = rs.SurfaceVolume(inter)
Initial_Volume = Volume0[0]

####################################
####                            ####
#### Heeled volume calculations ####
####                            ####
####################################
Ejemplo n.º 20
0
uDomain = rs.SurfaceDomain(idSurface, 0)
vDomain = rs.SurfaceDomain(idSurface, 1)

# get size int from domain & / by intended count = increment between surfaces
uStep = (uDomain[1] - uDomain[0]) / intCount
vStep = (vDomain[1] - vDomain[0]) / intCount

#print uStep
#print vStep

rs.EnableRedraw(False)

# loop through size of surface by step increment in both u & v directions
for u in rs.frange(uDomain[0], uDomain[1], uStep):
    for v in rs.frange(vDomain[0], vDomain[1], vStep):
        pt = rs.EvaluateSurface(idSurface, u,
                                v)  # get points at each domain step
        if rs.Distance(pt, rs.BrepClosestPoint(idSurface, pt)[0]) < 0.1:
            srfFrame = rs.SurfaceFrame(
                idSurface, [u, v])  # create ref plane at each division point
            newPlane = rs.AddPlaneSurface(
                srfFrame, 1.0, 1.0)  # create surface at each ref plane
            # add height guideline from plane's origin to "ceiling"
            centerPt = rs.SurfaceAreaCentroid(
                newPlane)  # locate center of each new plane
            limit = 10  # set "ceiling"
            endPt = limit - centerPt[0][
                2]  # access z coordinate with the tuple
            rs.AddLine(centerPt[0], rs.PointAdd(centerPt[0], (0, 0, endPt)))

rs.EnableRedraw(True)  # refresh viewport at one time only
Ejemplo n.º 21
0
    z.append(rd.uniform(40, 150))

lineaire = x, y, z

# Intersection des perp frame de l'axe avec la surface

DomAxe = []
DomAxe = rs.CurveDomain(Axe)

OrigineAxe = rs.EvaluateCurve(Axe, DomAxe[0])
cutplane = rs.CurvePerpFrame(Axe, DomAxe[0])

clength = []

if cutplane:
    planesrf = rs.AddPlaneSurface(cutplane, 100, 100)
    curves = rs.IntersectBreps(srf, planesrf)
    rs.DeleteObject(planesrf)
    clength = rs.CurveLength(curves)

#Best Candidate
bat_Util = []

for j in range(len(z) - 1):
    bat_Util.append(0)

for k in range(len(z) - 1):
    ind = 0
    BDiff = 10
    IsMatching = False
    if bat_Util[k] == 0:
Ejemplo n.º 22
0
line2 = [startPoint2, endPoint2]
line2ID = rs.AddLine(line2[0], line2[1])  # Returns another ObjectID
int1 = rs.LineLineIntersection(
    line1ID, line2ID)  # passing the ObjectIDs to the function.

#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#Practice 6 ####################################################################

import rhinoscriptsyntax as rs
ptOrigin = rs.GetPoint("Plane origin")
ptX = rs.GetPoint("Plane X-axis", ptOrigin)
ptY = rs.GetPoint("Plane Y-axis", ptOrigin)
dX = rs.Distance(ptOrigin, ptX)
dY = rs.Distance(ptOrigin, ptY)
arrPlane = rs.PlaneFromPoints(ptOrigin, ptX, ptY)
rs.AddPlaneSurface(arrPlane, 1.0, 1.0)
rs.AddPlaneSurface(arrPlane, dX, dY)

#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#Practice 7 ####################################################################

import rhinoscriptsyntax as rs
import math
#Call rs.EnableRedraw(False)
for t in rs.frange(-50, 50, 1.25):  #-100,90,3
    arrPoint = [t * math.sin(5 * t), t * math.cos(5 * t), t]
    print(arrPoint)
    rs.AddPoint(arrPoint)
    #Call rs.EnableRedraw(True)

#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Ejemplo n.º 23
0
box_point = rs.BoundingBox(box_param)
rs.DeleteObject(box_param)

distance_x = rs.GetReal("Vertical Distance", 0.4)
height = rs.GetReal("Z height",0.0)
filament = rs.GetReal("Filament Diameter",1.75)
Layerheight = rs.GetReal("Layer Height",0.2)
extrude_temp = rs.GetReal("Extrude temperture",205)
bed_temp = rs.GetReal("Bed temperture",60)
printspeed = rs.GetReal("Print speed",2500)
multi = rs.GetReal("Extrude multiply",1.0)

plane = Rhino.Geometry.Plane(box_point[0], box_point[1], box_point[2])
u_dir = rs.Distance(box_point[0], box_point[1])
v_dir = rs.Distance(box_point[1], box_point[2])
surface = rs.AddPlaneSurface(plane, u_dir, v_dir)

box_value = box_point[6]

array_z_number = int(box_value[2] // Layerheight)

if surface:
    array_lines=[]
    line = rs.AddLine(box_point[0],box_point[3])
    array_number = int(box_value[0] // distance_x)

    #Array line
    if line:
        i = 0
        for i in range(array_number):
            offset_x = distance_x * i