XSecSurf Functions

This group of API functions provides capabilities related to the XSecSurf class in OpenVSP.

GetNumXSecSurfs(geom_id)

Get the number of XSecSurfs for the specified Geom

GetXSecSurf(geom_id, index)

Get the XSecSurf ID for a particular Geom and XSecSurf index

GetXSecSurfIDVec(geom_id)

Get the IDs of the XSecSurfs of a Geom, in the order of their indexes.

GetNumXSec(xsec_surf_id)

Get number of XSecs in an XSecSurf

GetXSec(xsec_surf_id, xsec_index)

Get Xsec ID for a particular XSecSurf at given index

GetXSecIDVec(xsec_surf_id)

Get the IDs of the XSecs of an XSecSurf, in the order of their indexes.

ChangeXSecShape(xsec_surf_id, xsec_index, type)

Change the shape of a particular XSec, identified by an XSecSurf ID and XSec index

SetXSecSurfGlobalXForm(xsec_surf_id, mat)

Set the global surface transform matrix for given XSecSurf

GetXSecSurfGlobalXForm(xsec_surf_id)

Get the global surface transform matrix for given XSecSurf

Details

openvsp.GetNumXSecSurfs(geom_id)[source]

Get the number of XSecSurfs for the specified Geom

#==== Add Fuselage Geometry ====//
fuseid = AddGeom( "FUSELAGE", "" )

num_xsec_surfs = GetNumXSecSurfs( fuseid )

if  num_xsec_surfs != 1 :
    print( "---> Error: API GetNumXSecSurfs  " )
    assert False, "---> Error: API GetNumXSecSurfs"
Parameters:

[in] – geom_id string Geom ID

Return type:

int

Returns:

int Number of XSecSurfs

openvsp.GetXSecSurf(geom_id, index)[source]

Get the XSecSurf ID for a particular Geom and XSecSurf index

# Add Stack
sid = AddGeom( "STACK", "" )

# Get First (and Only) XSec Surf
xsec_surf = GetXSecSurf( sid, 0 )
assert len( xsec_surf ) > 0, "GetXSecSurf returned nothing"
Parameters:
  • [in] – geom_id string Geom ID

  • [in] – index int XSecSurf index

Return type:

string

Returns:

string XSecSurf ID

openvsp.GetXSecSurfIDVec(geom_id)[source]

Get the IDs of the XSecSurfs of a Geom, in the order of their indexes.

gid = AddGeom( "FUSELAGE" )

xsec_surf = GetXSecSurf( gid, 0 )

assert list( GetXSecSurfIDVec( gid ) ) == [ xsec_surf ], "GetXSecSurfIDVec did not return the XSecSurf"

See also: GetXSecSurf, GetNumXSecSurfs :param [in]: geom_id string Geom ID :rtype: std::vector< std::string,std::allocator< std::string > > :return: array<string> Array of XSecSurf IDs

openvsp.GetNumXSec(xsec_surf_id)[source]

Get number of XSecs in an XSecSurf

# Add Stack
sid = AddGeom( "STACK", "" )

# Get First (and Only) XSec Surf
xsec_surf = GetXSecSurf( sid, 0 )

# Flatten ends
num_xsecs = GetNumXSec( xsec_surf )

# A Stack starts with five sections, and every index below the count has to
# name a real XSec.
assert num_xsecs == 5, "GetNumXSec did not report the sections of a new Stack"

for i in range(num_xsecs):

    xsec = GetXSec( xsec_surf, i )

    assert len( xsec ) > 0, "GetNumXSec counted a section that GetXSec cannot find"

    SetXSecTanAngles( xsec, XSEC_BOTH_SIDES, 0, -1.0e12, -1.0e12, -1.0e12 )       # Set Tangent Angles At Cross Section

    SetXSecTanStrengths( xsec, XSEC_BOTH_SIDES, 0.0, -1.0e12, -1.0e12, -1.0e12 )  # Set Tangent Strengths At Cross Section

# Inserting a section has to move the count.
InsertXSec( sid, 1, XS_ROUNDED_RECTANGLE )

assert GetNumXSec( xsec_surf ) == num_xsecs + 1, "GetNumXSec did not follow InsertXSec"
Parameters:

[in] – xsec_surf_id string XSecSurf ID

Return type:

int

Returns:

int Number of XSecs

openvsp.GetXSec(xsec_surf_id, xsec_index)[source]

Get Xsec ID for a particular XSecSurf at given index

# Add Stack
sid = AddGeom( "STACK", "" )

# Get First (and Only) XSec Surf
xsec_surf = GetXSecSurf( sid, 0 )

# Identify XSec 1
xsec_1 = GetXSec( xsec_surf, 1 )
assert len( xsec_1 ) > 0, "GetXSec returned nothing"
Parameters:
  • [in] – xsec_surf_id string XSecSurf ID

  • [in] – xsec_index int Xsec index

Return type:

string

Returns:

string Xsec ID

openvsp.GetXSecIDVec(xsec_surf_id)[source]

Get the IDs of the XSecs of an XSecSurf, in the order of their indexes.

gid = AddGeom( "FUSELAGE" )

xsec_surf = GetXSecSurf( gid, 0 )

xsec_1 = GetXSec( xsec_surf, 1 )

ids = GetXSecIDVec( xsec_surf )

assert len( ids ) == GetNumXSec( xsec_surf ) and ids[1] == xsec_1, "GetXSecIDVec did not return the XSecs in order"

See also: GetXSec, GetNumXSec :param [in]: xsec_surf_id string XSecSurf ID :rtype: std::vector< std::string,std::allocator< std::string > > :return: array<string> Array of XSec IDs

openvsp.ChangeXSecShape(xsec_surf_id, xsec_index, type)[source]

Change the shape of a particular XSec, identified by an XSecSurf ID and XSec index

# Add Stack
sid = AddGeom( "STACK", "" )

# Get First (and Only) XSec Surf
xsec_surf = GetXSecSurf( sid, 0 )

# Set XSec 1 & 2 to Edit Curve type
ChangeXSecShape( xsec_surf, 1, XS_EDIT_CURVE )
ChangeXSecShape( xsec_surf, 2, XS_EDIT_CURVE )

xsec_2 = GetXSec( xsec_surf, 2 )

if  GetXSecShape( xsec_2 ) != XS_EDIT_CURVE :
    print( "Error: ChangeXSecShape" )
    assert False, "Error: ChangeXSecShape"

See also: XSEC_CRV_TYPE, ChangeXSecShapeByID :param [in]: xsec_surf_id string XSecSurf ID :param [in]: xsec_index int Xsec index :param [in]: type int Xsec type enum (i.e. XS_ELLIPSE)

openvsp.SetXSecSurfGlobalXForm(xsec_surf_id, mat)[source]

Set the global surface transform matrix for given XSecSurf

sid = AddGeom( "STACK", "" )

xsec_surf = GetXSecSurf( sid, 0 )

mat = Matrix4d()
mat.loadIdentity()
mat.translatef( 1.0, 2.0, 3.0 )

SetXSecSurfGlobalXForm( xsec_surf, mat )
Parameters:
  • [in] – xsec_surf_id string XSecSurf ID

  • [in] – mat Matrix4d Transformation matrix

openvsp.GetXSecSurfGlobalXForm(xsec_surf_id)[source]

Get the global surface transform matrix for given XSecSurf

sid = AddGeom( "STACK", "" )

xsec_surf = GetXSecSurf( sid, 0 )

mat = GetXSecSurfGlobalXForm( xsec_surf )
Parameters:

[in] – xsec_surf_id string XSecSurf ID

Return type:

Matrix4d

Returns:

Matrix4d Transformation matrix