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

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

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.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.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 :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