示例#1
0
def SplitObject(solid, cSrf):

    preInnerSrf = rs.CopyObject(cSrf)
    innerSrfs = rs.TrimBrep(preInnerSrf, solid)
    if not innerSrfs:
        rs.DeleteObject(preInnerSrf)
        return [solid]
    solids = []
    solids.append(solid)

    for srf in innerSrfs:
        newSolids = []
        for obj in solids:
            splitObjs = rs.SplitBrep(obj, srf, True)
            if not splitObjs:
                newSolids.append(obj)
            else:
                for sObj in splitObjs:
                    toJoin = [sObj, srf]
                    newSolids.append(rs.JoinSurfaces(toJoin))
                rs.DeleteObjects(splitObjs)
        solids = newSolids

    rs.DeleteObjects(innerSrfs)

    return solids
 def Cut(self, polysurface, holes):
     for hole in holes:
         new = rs.SplitBrep(polysurface, hole, True)
         polysurface = next(x for x in new if rs.IsPolysurface(x))
         for n in new:
             if n is not polysurface:
                 rs.DeleteObject(n)
     return rs.JoinSurfaces([polysurface] + holes, True)
def splitModel(objs, cutLevel):
    point = Rhino.Geometry.Point3d(0,0,cutLevel)
    
    belowDir = rs.AddLine(point, [0,0,-9999])
    aboveDir = rs.AddLine(point, [0,0,9999])
    circle = rs.AddCircle(point, 9999)
    circleSrf = rs.AddPlanarSrf(circle)
    
    aboveGroup = rs.AddGroup("Above")
    belowGroup = rs.AddGroup("Below")
    
    
    for obj in objs:
        ptBtm = rs.BoundingBox(obj)[0]
        ptTop = rs.BoundingBox(obj)[6]
        if ptBtm[2]>cutLevel:
            intersecting = False
            rs.AddObjectToGroup(obj, "Above")
            #print "Object Above"
        elif ptTop[2]<cutLevel:
            intersecting = False
            rs.AddObjectToGroup(obj, "Below")
            #print "Object Below"
        else:
            intersecting = True
        
        if intersecting:
            if rs.IsBrep(obj):
                closed = False
                if rs.IsPolysurfaceClosed(obj):
                    closed = True
                try:
                    copy = rs.CopyObject(obj)
                    splitSrfs = rs.SplitBrep(obj, circleSrf, True)
                    for splitSrf in splitSrfs:
                        #print "looping"
                        if closed:
                            rs.CapPlanarHoles(splitSrf)
                        rs.MatchObjectAttributes(splitSrf, copy)
                        ptBtm = rs.BoundingBox(splitSrf)[0]
                        ptTop = rs.BoundingBox(splitSrf)[6]
                        mdPtZ = (ptBtm[2] + ptTop[2]) / 2
                        if mdPtZ>cutLevel:
                            rs.AddObjectToGroup(splitSrf, "Above")
                        else:
                            rs.AddObjectToGroup(splitSrf, "Below")
                    rs.DeleteObject(copy)
                    rs.DeleteObject(obj)
                except:
                    None
            if rs.IsBlockInstance(obj):
                contents = rs.ExplodeBlockInstance(obj)
                for content in contents:
                    objs.append(content)
    rs.DeleteObject(belowDir)
    rs.DeleteObject(aboveDir)
    rs.DeleteObject(circle)
    rs.DeleteObject(circleSrf)
示例#4
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]
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
 def SplitAndKeepSmallest(self, object, cutting):
     objects = rs.SplitBrep(object, cutting, True)
     # sort split object parts by surface area
     meta = [(i, rs.SurfaceArea(objects[i])[0])
             for i in range(len(objects))]
     meta.sort(key=lambda iy: -iy[1])
     # delete other parts
     for i in range(len(meta) - 1):
         object = objects[meta[i][0]]
         rs.DeleteObject(object)
     return objects[meta[len(meta) - 1][0]]
示例#7
0
    def split(srfs,cutter,stop=False):
        ##print('iter:{},num srfs:{}'.format(iteration,len(srfs)))
        outbin=[]
        for s in srfs:
            if not rs.IsBrep(s):
                continue
            result=rs.SplitBrep(s,cutter,True)
            #print('$result is ',result)

            if result is None:
                # pass
                outbin.append(s)
            else:
                outbin+=split(result,cutter)
        return outbin
示例#8
0
 def slice_ref(self, r, p, n):
     cutter = rh.AddCutPlane([r], Pt(p), Pt(p + vx(1, p.cs)),
                             Pt(vy(1, p.cs)))
     rs = rh.SplitBrep(r, cutter, True)
     rs = rs or [r]
     for e in rs:
         rh.CapPlanarHoles(e)
     keep, clear = partition(
         rs, lambda r:
         (fromPt(rh.SurfaceVolumeCentroid(r)[0]) - p).dot(n) < 0)
     rh.DeleteObjects(clear)
     rh.DeleteObject(cutter)
     if keep == []:
         return empty_ref()
     else:
         return single_ref_or_union(keep)
 def SplitAndKeep(self, object, cutting, index, axis=1):
     objects = rs.SplitBrep(object, cutting, True)
     # sort split object parts by centroid y
     meta = [(i, rs.SurfaceAreaCentroid(objects[i])[0][axis])
             for i in range(len(objects))]
     meta.sort(key=lambda iy: iy[1])
     # delete other parts
     try:
         exclusion = set(index)
     except TypeError:
         exclusion = set()
         exclusion.add(index)
     results = []
     for i in range(len(meta)):
         object = objects[meta[i][0]]
         if i not in exclusion:
             rs.DeleteObject(object)
         else:
             results.append(object)
     return results[0] if len(results) == 1 else results
示例#10
0
def SplitGeometry(objs, plane, dir=1):
    global diffRadius
    circle = Rhino.Geometry.Circle(plane, diffRadius)
    negShape = Rhino.Geometry.Cylinder(circle, diffRadius * dir)
    negShapeBrep = negShape.ToBrep(True, True)
    negShapeGeo = sc.doc.Objects.AddBrep(negShapeBrep)

    visibleGeometry = []

    for obj in objs:
        if rs.IsBrep(obj):
            if rs.IsPolysurfaceClosed(obj):
                resultObjs = rs.BooleanDifference(obj, negShapeGeo, False)
                if resultObjs is None:
                    visibleGeometry.append(obj)
                elif len(resultObjs) < 1:
                    visibleGeometry.append(obj)
                else:
                    for each in resultObjs:
                        visibleGeometry.append(each)
            else:
                resultObjs = rs.SplitBrep(obj, negShapeGeo)
                if resultObjs is None:
                    visibleGeometry.append(obj)
                elif len(resultObjs) < 1:
                    visibleGeometry.append(obj)
                else:
                    for each in resultObjs:
                        if IsAbovePlane(each, plane.OriginZ):
                            if dir == -1:
                                visibleGeometry.append(each)
                            else:
                                rs.DeleteObject(each)
                        else:
                            if dir == 1:
                                visibleGeometry.append(each)
                            else:
                                rs.DeleteObject(each)

    rs.DeleteObject(negShapeGeo)
    return visibleGeometry
    insulation_Panels.append(insulation_odd)

all = rs.AllObjects(False, False, False, False)
for item in range(0, len(all), 1):
    item = all[item]
    test = rs.IsCurve(item)
    if test == True:
        rs.DeleteObject(item)

insulation_Panels_temp = []

for i in range(0, len(insulation_Panels), 1):
    item = insulation_Panels[i]
    for j in range(0, len(window_frame_all), 1):
        window_frame = window_frame_all[j]
        split = rs.SplitBrep(item, window_frame, True)

        if split == None:
            insulation_Panels_temp.append(item)

        else:
            for pie in range(0, len(split), 1):
                pie = split[pie]
                insulation_Panels_temp.append(pie)

insulation_Panels = insulation_Panels_temp
insulation_Panels_temp = []

#print insulation_Panels
for item in range(0, len(insulation_Panels), 1):
    item = insulation_Panels[item]
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()
示例#13
0
def TurbofanNacelle(EngineSection,
                    Chord,
                    CentreLocation=[0, 0, 0],
                    ScarfAngle=3,
                    HighlightRadius=1.45,
                    MeanNacelleLength=5.67):
    # The defaults yield a nacelle similar to that of an RR Trent 1000 / GEnx

    HighlightDepth = 0.12 * MeanNacelleLength
    SectionNo = 100

    # Draw the nacelle with the centre of the intake highlight circle in 0,0,0
    rs.EnableRedraw(False)
    Highlight = rs.AddCircle3Pt((0, 0, HighlightRadius),
                                (0, -HighlightRadius, 0),
                                (0, 0, -HighlightRadius))
    HighlightCutterCircle = rs.AddCircle3Pt((0, 0, HighlightRadius * 1.5),
                                            (0, -HighlightRadius * 1.5, 0),
                                            (0, 0, -HighlightRadius * 1.5))

    # Fan disk for CFD boundary conditions
    FanCircle = rs.CopyObject(Highlight, (MeanNacelleLength * 0.25, 0, 0))
    FanDisk = rs.AddPlanarSrf(FanCircle)
    # Aft outflow for CFD boundary conditions
    BypassCircle = rs.CopyObject(Highlight, (MeanNacelleLength * 0.85, 0, 0))
    BypassDisk = rs.AddPlanarSrf(BypassCircle)
    rs.DeleteObjects([FanCircle, BypassCircle])

    # Outflow cone
    TailConeBasePoint = [MeanNacelleLength * 0.84, 0, 0]
    TailConeApex = [MeanNacelleLength * 1.35, 0, 0]
    TailConeRadius = HighlightRadius * 0.782
    TailCone = rs.AddCone(TailConeBasePoint, TailConeApex, TailConeRadius)
    # Spinner cone
    SpinnerConeBasePoint = [MeanNacelleLength * 0.26, 0, 0]
    SpinnerConeApex = [MeanNacelleLength * 0.08, 0, 0]
    SpinnerConeRadius = MeanNacelleLength * 0.09
    Spinner = rs.AddCone(SpinnerConeBasePoint, SpinnerConeApex,
                         SpinnerConeRadius)

    # Tilt the intake
    RotVec = rs.VectorCreate((0, 0, 0), (0, 1, 0))
    Highlight = rs.RotateObject(Highlight, (0, 0, 0), ScarfAngle, axis=RotVec)

    # Set up the disk for separating the intake lip later
    HighlightCutterCircle = rs.RotateObject(HighlightCutterCircle, (0, 0, 0),
                                            ScarfAngle,
                                            axis=RotVec)
    HighlightCutterDisk = rs.AddPlanarSrf(HighlightCutterCircle)
    rs.DeleteObject(HighlightCutterCircle)
    rs.MoveObject(HighlightCutterDisk, (HighlightDepth, 0, 0))

    # Build the actual airfoil sections to define the nacelle
    HighlightPointVector = rs.DivideCurve(Highlight, SectionNo)

    Sections = []
    TailPoints = []
    Rotation = 0
    Twist = 0
    AirfoilSeligName = 'goe613'
    SmoothingPasses = 1

    for HighlightPoint in HighlightPointVector:
        ChordLength = MeanNacelleLength - HighlightPoint.X
        Af = primitives.Airfoil(HighlightPoint, ChordLength, Rotation, Twist,
                                airconics_setup.SeligPath)
        AfCurve, Chrd = primitives.Airfoil.AddAirfoilFromSeligFile(
            Af, AirfoilSeligName, SmoothingPasses)
        rs.DeleteObject(Chrd)
        P = rs.CurveEndPoint(AfCurve)
        list.append(TailPoints, P)
        AfCurve = act.AddTEtoOpenAirfoil(AfCurve)
        list.append(Sections, AfCurve)
        Rotation = Rotation + 360.0 / SectionNo

    list.append(TailPoints, TailPoints[0])

    # Build the actual nacelle OML surface
    EndCircle = rs.AddInterpCurve(TailPoints)
    Nacelle = rs.AddSweep2([Highlight, EndCircle], Sections, closed=True)
    # Separate the lip
    Cowling, HighlightSection = rs.SplitBrep(Nacelle, HighlightCutterDisk,
                                             True)

    # Now build the pylon between the engine and the specified chord on the wing
    CP1 = [
        MeanNacelleLength * 0.26 + CentreLocation[0], CentreLocation[1],
        CentreLocation[2] + HighlightRadius * 0.1
    ]
    CP2 = [
        MeanNacelleLength * 0.4 + CentreLocation[0], CentreLocation[1],
        HighlightRadius * 1.45 + CentreLocation[2]
    ]
    CP3 = rs.CurveEndPoint(Chord)
    rs.ReverseCurve(Chord)
    CP4 = rs.CurveEndPoint(Chord)

    # Move the engine into its actual place on the wing
    rs.MoveObjects(
        [HighlightSection, Cowling, FanDisk, BypassDisk, TailCone, Spinner],
        CentreLocation)

    # Pylon wireframe
    PylonTop = rs.AddInterpCurve([CP1, CP2, CP3, CP4])
    PylonAf = primitives.Airfoil(CP1, MeanNacelleLength * 1.35, 90, 0,
                                 airconics_setup.SeligPath)
    PylonAfCurve, PylonChord = primitives.Airfoil.AddNACA4(
        PylonAf, 0, 0, 12, 3)
    LowerTE = rs.CurveEndPoint(PylonChord)
    PylonTE = rs.AddLine(LowerTE, CP4)

    # Create the actual pylon surface
    PylonLeft = rs.AddNetworkSrf([PylonTop, PylonAfCurve, PylonTE])
    rs.MoveObject(PylonLeft, (0, -CentreLocation[1], 0))
    PylonRight = act.MirrorObjectXZ(PylonLeft)
    rs.MoveObject(PylonLeft, (0, CentreLocation[1], 0))
    rs.MoveObject(PylonRight, (0, CentreLocation[1], 0))
    PylonAfCurve = act.AddTEtoOpenAirfoil(PylonAfCurve)
    PylonAfSrf = rs.AddPlanarSrf(PylonAfCurve)

    # Assigning basic surface properties
    act.AssignMaterial(Cowling, "ShinyBABlueMetal")
    act.AssignMaterial(HighlightSection, "UnpaintedMetal")
    act.AssignMaterial(TailCone, "UnpaintedMetal")
    act.AssignMaterial(FanDisk, "FanDisk")
    act.AssignMaterial(Spinner, "ShinyBlack")
    act.AssignMaterial(BypassDisk, "FanDisk")
    act.AssignMaterial(PylonLeft, "White_composite_external")
    act.AssignMaterial(PylonRight, "White_composite_external")

    # Clean-up
    rs.DeleteObject(HighlightCutterDisk)
    rs.DeleteObjects(Sections)
    rs.DeleteObject(EndCircle)
    rs.DeleteObject(Highlight)
    rs.DeleteObjects([PylonTop, PylonAfCurve, PylonChord, PylonTE])

    rs.Redraw()

    TFEngine = [
        Cowling, HighlightSection, TailCone, FanDisk, Spinner, BypassDisk
    ]
    TFPylon = [PylonLeft, PylonRight, PylonAfSrf]

    return TFEngine, TFPylon
    def RemoveSurfacesOutsideOfBox(self, b_length):
        """
        Main method which calls all auxilliary functions to trim out of bounds
        fractures.

        Parameter
        --------
        b_length: float
            length of domain/boundary
            
        Raises
        ------
        ValueError
            if boundary length is less than zero.
        """
        try:
            if b_length <= 0:
                raise ValueError
        except ValueError:
            print("Value of boundary should be greater than 0")
        else:
            # Create boundary surfaces
            boundaries = self.CreateBoundary(b_length)
            # Get all layers in the document
            all_layers = rs.LayerNames()
            # To avoid error messages about deleting current layers:
            # make a blank layer
            rs.AddLayer('Blank Layer')
            rs.CurrentLayer('Blank Layer')
            # Make a layer for intersecting fractures
            boundary_intersection_layer = "Boundary_Intersections"
            if rs.IsLayer(boundary_intersection_layer):
                rs.PurgeLayer(boundary_intersection_layer)  # Deletes layer
            # make boundary_intersection_layer the current layer
            rs.AddLayer(boundary_intersection_layer)
            rs.CurrentLayer(boundary_intersection_layer)
            rs.LayerColor(boundary_intersection_layer, [200, 0, 0])
            # Make a polysurface of all the boundaries
            # This polysurf can be used with SplitBrep
            # If you compare surfaces individually, then fractures which
            # intersect more than one surface (i.e. corners)
            # do not get split correctly.
            box = rs.JoinSurfaces(boundaries)
            all_surfaces = []
            # Go over all the layers to find fractures
            for layer in all_layers:
                # Only act if layer is a fracture layer
                # Some layers have short names, so ask for 1st
                # letter first, then rest
                if layer[0] == 'F':
                    if layer[0:8] == 'FRACTURE':
                        # Get surfaces in this layer
                        surfs = self.GetSurfaceFromFractureLayer(layer)
                        for surf in surfs:  # BUT SURFS IS JUST A GUID
                            all_surfaces.append(surf)
            all_new_surfaces = []  # Store the split surfaces of the fractures
            # print "Number of surfaces examined for splitting: ",
            # len(all_surfaces)
            for surf in all_surfaces:
                # Run intersection test
                boundaries_touched = 0
                # for boundary in boundaries:
                # Use splitbrep here to split the fracture
                # surfaces by the boundaries directly
                # Brings back a polysurf which must be converted into a surface
                new_polysurfs = rs.SplitBrep(surf, box)
                if type(new_polysurfs) == list:
                    boundaries_touched += 1
                    for polysurf in new_polysurfs:
                        # Because sometimes there are multiple surfaces
                        new_surfs = self.ConvertPolysurfaceToSurface(polysurf)
                        for new_surfs_i in new_surfs[1]:
                            all_new_surfaces.append(new_surfs_i)
                            # append to domain fracture list
                            self.my_fractures.append(new_surfs_i)
                if boundaries_touched == 0:
                    # This means the fracture didn't intersect a boundary
                    # Add it to the list as well, so the final layer
                    # has all the fracs
                    copied_surf = rs.CopyObject(surf)
                    rs.ObjectLayer(copied_surf, boundary_intersection_layer)
                    # ARE WE APPENDING THE FRAC OUTSIDE OR INSIDE
                    all_new_surfaces.append(copied_surf)
                    # append to domain fracture list
                    self.my_fractures.append(copied_surf)
            # print "Number of surfaces after splitting: ",
            # len(all_new_surfaces)
            # Make extended boundary surfaces to check
            ext_boundaries = self.CreateSetOfExtendedBoundaries(
                boundaries, b_length)
            # Now, remove any surfaces which aren't inside the volume
            for surf in all_new_surfaces:
                self.RemoveSurfacesIfAnyIntersectBoundary(surf, ext_boundaries)
            # We don't need the extra boundaries anymore
            for boundary in ext_boundaries:
                rs.DeleteObject(boundary)
            for boundary in boundaries:
                rs.DeleteObject(boundary)
            rs.DeleteObject(box)
            return
示例#15
0
param = rs.SurfaceClosestPoint(miterFace, intersectPoints[0])
normal = rs.SurfaceNormal(miterFace, param)
miterEndPoint = intersectPoints[0] + normal
miterVector = normal

line = rs.AddLine(outerEndPoint, miterEndPoint)
rs.HideObject(line)
midPoint = rs.CurveMidPoint(line)

normalVector = rs.VectorCrossProduct(outerVector, miterVector)

cutPlane = rs.AddCutPlane(solid, intersectPoints[0], midPoint, normal = normalVector)
rs.HideObject(cutPlane)

splitSolids = rs.SplitBrep(solid, cutPlane, True)

rs.CapPlanarHoles(splitSolids[0])
rs.CapPlanarHoles(splitSolids[1])

if  rs.SurfaceArea(splitSolids[0]) > rs.SurfaceArea(splitSolids[1]):
    rs.DeleteObject(splitSolids[1])
else:
    rs.DeleteObject(splitSolids[0]) 

if not solid2:
    x = 0
else: 
    splitSolids = rs.SplitBrep(solid2, cutPlane, True)

    rs.CapPlanarHoles(splitSolids[0])
示例#16
0
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):
        if rs.SurfaceArea(splitSolids[i]) > rs.SurfaceArea(splitSolids[i + 1]):
            tmp = splitSolids[i + 1]