Vehicle Functions¶
The Vehicle group of functions are high-level commands that pertain to the entire OpenVSP model.
|
Update the entire vehicle and all lower level children. |
|
Exit the program with a specific error code |
|
Cause OpenVSP to crash in a variety of ways. |
Return the OpenVSP update count and also reset it to zero. |
|
Get the file name of the current OpenVSP project |
|
Clear the current OpenVSP model |
Details¶
- openvsp.Update(update_managers=True)[source]¶
Update the entire vehicle and all lower level children. An input, which is true by default, is available to specify if managers should be updated as well. The managers are typically updated by their respective GUI, so must be updated through the API as well to avoid unexpected behavior.
fid = AddGeom( "FUSELAGE", "" ) # Add Fuselage xsec_surf = GetXSecSurf( fid, 0 ) # Get First (and Only) XSec Surf num_xsecs = GetNumXSec( xsec_surf ) Update() before_max = GetGeomBBoxMax( fid, 0, False ) #==== Set Tan Angles At Nose/Tail SetXSecTanAngles( GetXSec( xsec_surf, 0 ), XSEC_BOTH_SIDES, 90, -1.0e12, -1.0e12, -1.0e12 ) SetXSecTanAngles( GetXSec( xsec_surf, num_xsecs - 1 ), XSEC_BOTH_SIDES, -90, -1.0e12, -1.0e12, -1.0e12 ) Update() # Force Surface Update after_max = GetGeomBBoxMax( fid, 0, False ) # Blunting the nose and tail pushes the surface out, which only shows up in # the bounding box once Update() has rebuilt it. assert dist( before_max, after_max ) > 1e-9, "Update did not rebuild the surface"
- Parameters:
update_managers (boolean, optional) – bool Flag to indicate if managers should be updated
- openvsp.VSPExit(error_code)[source]¶
Exit the program with a specific error code
Update() # Shown rather than run: this ends the process, and would take the caller with it. # VSPExit( 0 )
- Parameters:
[in] – error_code int Error code
- openvsp.VSPCrash(crash_type)[source]¶
Cause OpenVSP to crash in a variety of ways.
Update() # Shown rather than run: this deliberately crashes the process, and is only for exercising # the crash handler. # VSPCrash( 0 )
- Parameters:
[in] – crash_type int Type of crash to attempt.
- openvsp.GetAndResetUpdateCount()[source]¶
Return the OpenVSP update count and also reset it to zero.
The OpenVSP update count tracks how many times the GUI has been told to update screens (set to dirty). It provides a simple means of testing whether the OpenVSP state has possibly changed (non-zero returned). Nothing marks a screen dirty when no GUI is running, so the count stays at zero in a plain script.
#==== Add Pod Geometry ====// pid = AddGeom( "POD" ) Update() # Reading the count clears it, so a second read with nothing in between # reports no change. GetAndResetUpdateCount() assert GetAndResetUpdateCount() == 0, "the update count did not reset" # The count is a GUI notion. A script with no GUI running never marks a # screen dirty, so the count stays where the read left it. SetParmValUpdate( pid, "Length", "Design", 10.0 ) Update() assert GetAndResetUpdateCount() >= 0, "the update count went negative"
- Return type:
int
- Returns:
int OpenVSP update count
- openvsp.GetVSPFileName()[source]¶
Get the file name of the current OpenVSP project
fid = AddGeom( "FUSELAGE", "" ) # Add Fuselage fname = "example_fuse.vsp3" SetVSP3FileName( fname ) # A relative name is resolved against the working directory, so ask for the # resolved name rather than assuming it comes back verbatim. full_name = GetVSPFileName() Update() #==== Save Vehicle to File ====// print( "\tSaving vehicle file to: ", False ) print( fname ) WriteVSPFile( GetVSPFileName(), SET_ALL ) assert GetVSPFileName() == full_name and full_name.endswith( fname ), "GetVSPFileName did not report the name that was set"
- Return type:
string
- Returns:
string File name for the current OpenVSP project