Exemplo n.º 1
0
vsp.SetParmVal(second_pod_id, "Z_Location", "XForm", 1.0)

fname = "apitest1.vsp3"

vsp.WriteVSPFile(fname)

geoms = vsp.FindGeoms()

print("All geoms in Vehicle.")
print(geoms)

errorMgr.PopErrorAndPrint(stdout)

# ==== Use Case 2 ====#

vsp.VSPRenew()
errorMgr.PopErrorAndPrint(stdout)

geoms = vsp.FindGeoms()

print("All geoms in Vehicle.")
print(geoms)

# Add Fuse
fuse_id = vsp.AddGeom("FUSELAGE")

# Get XSec Surf ID
xsurf_id = vsp.GetXSecSurf(fuse_id, 0)

# Change Type of First XSec
vsp.ChangeXSecShape(xsurf_id, 0, vsp.XS_SUPER_ELLIPSE)
Exemplo n.º 2
0
    def UpdateGeometry(self, actions):

        # OpenVSP Script Part
        os.chdir("/home/simonx/Documents/Udacity/ML/Projects/capstone/OpenVSP")
        stdout = vsp.cvar.cstdout
        errorMgr = vsp.ErrorMgrSingleton_getInstance()

        # WingBodyTestCase

        vsp.VSPRenew()
        errorMgr.PopErrorAndPrint(stdout)

        # Add Wing
        WingBody = vsp.AddGeom("WING", "")

        # Insert A Couple More Sections
        InsertXSec(WingBody, 1, XS_FOUR_SERIES)
        InsertXSec(WingBody, 1, XS_FOUR_SERIES)
        InsertXSec(WingBody, 1, XS_FOUR_SERIES)

        # Cut The Original Section
        CutXSec(WingBody, 1)

        # Change Driver
        SetDriverGroup(WingBody, 1, AREA_WSECT_DRIVER, ROOTC_WSECT_DRIVER,
                       TIPC_WSECT_DRIVER)

        SetParmVal(WingBody, "RotateAirfoilMatchDideralFlag", "WingGeom", 1.0)

        # Change Some Parameters 1st Section

        SetParmVal(WingBody, "Root_Chord", "XSec_1", 7.0)
        SetParmVal(WingBody, "Tip_Chord", "XSec_1", 3.0)
        SetParmVal(WingBody, "Area", "XSec_1", actions[0])
        SetParmVal(WingBody, "Sweep", "XSec_1", actions[1])

        # Because Sections Are Connected Change One Section At A Time Then Update
        Update()

        # Change Some Parameters 2nd Section
        SetParmVal(WingBody, "Tip_Chord", "XSec_2", 2.0)
        SetParmVal(WingBody, "Sweep", "XSec_2", 60.0)
        SetParmVal(WingBody, "Dihedral", "XSec_2", 30.0)
        Update()

        # Change Some Parameters 3rd Section
        SetParmVal(WingBody, "Sweep", "XSec_3", 60.0)
        SetParmVal(WingBody, "Dihedral", "XSec_3", 80.0)
        Update()

        # Change Airfoil
        SetParmVal(WingBody, "Camber", "XSecCurve_0", 0.02)
        Update()

        # print "All geoms in Vehicle."
        geoms = vsp.FindGeoms()
        print geoms

        # File basename
        baseName = "WingBody"
        csvName = baseName + "_Dege   nGeom.csv"
        stlName = baseName + "_DegenGeom.stl"
        vspName = baseName + ".vsp3"

        # Set File Name
        SetComputationFileName(DEGEN_GEOM_CSV_TYPE, csvName)
        SetComputationFileName(CFD_STL_TYPE, stlName)

        WriteVSPFile(vspName)
        # ComputeDegenGeom( SET_ALL, DEGEN_GEOM_CSV_TYPE );
        # ComputeCFDMesh( SET_ALL, CFD_STL_TYPE );        # Mesh

        # Check for errors

        num_err = errorMgr.GetNumTotalErrors()
        for i in range(0, num_err):
            err = errorMgr.PopLastError()
            print "error = ", err.m_ErrorString