Sub-Surface Functions

Functions related to Sub-Surfaces are defined in this group.

AddSubSurf(geom_id, type[, surfindex])

Add a sub-surface to the specified Geom

GetSubSurf(*args)

Overload 1:

DeleteSubSurf(*args)

Overload 1:

ReorderSubSurf(geom_id, sub_id, reorder_type)

Move a sub-surface within its parent Geom's sub-surface list, the way the move buttons on the Sub-Surface tab do.

SetSubSurfName(*args)

Overload 1:

GetSubSurfName(*args)

Overload 1:

GetSubSurfIndex(sub_id)

Get the index of the specified sub-surface in its parent Geom's sub-surface vector

GetSubSurfIDVec(geom_id)

Get a vector of all sub-surface IDs for the specified geometry

GetAllSubSurfIDs()

Get a vector of all sub-surface IDs for the entire model

GetNumSubSurf(geom_id)

Get the number of sub-surfaces for the specified Geom

GetSubSurfType(sub_id)

Get the type for the specified sub-surface (i.e. SS_RECTANGLE).

GetSubSurfParmIDs(sub_id)

Get the vector of Parm IDs for specified sub-surface

IntersectSubSurf(sub_id)

Trigger intersection for SS_INTERSECT type subsurfaces

GetIntersectSubSurfGeomID(sub_id)

Set Geom ID to intersect parent with to create intersection SS_INTERSECT type subsurfaces

SetIntersectSubSurfGeomID(sub_id, geom_id)

Say which Geom a sub-surface belongs to for intersection purposes.

Details

openvsp.AddSubSurf(geom_id, type, surfindex=0)[source]

Add a sub-surface to the specified Geom

wid = AddGeom( "WING", "" )                             # Add Wing

# Note: Parm Group for SubSurfaces in the form: "SS_" + type + "_" + count (initialized at 1)
ss_line_id = AddSubSurf( wid, SS_LINE )                      # Add Sub Surface Line

SetParmVal( wid, "Const_Line_Value", "SubSurface_1", 0.4 )     # Change Location

See also: SUBSURF_TYPE :param [in]: geom_id string Geom ID :param [in]: type int Sub-surface type enum (i.e. SS_RECTANGLE) :param [in]: surfindex int Main surface index (default: 0) :rtype: string :return: string Sub-surface ID

openvsp.GetSubSurf(*args)[source]

Overload 1:

Get the ID of the specified sub-surface

wid = AddGeom( "WING", "" ) # Add Wing

ss_rec_1 = AddSubSurf( wid, SS_RECTANGLE ) # Add Sub Surface Rectangle #1

ss_rec_2 = AddSubSurf( wid, SS_RECTANGLE ) # Add Sub Surface Rectangle #2

print( ss_rec_2, False )

print( " = ", False )

print( GetSubSurf( wid, 1 ) )

# Sub-surfaces come back in the order they were added.
assert GetSubSurf( wid, 0 ) == ss_rec_1, "GetSubSurf did not report the sub-surfaces in order"
assert GetSubSurf( wid, 1 ) == ss_rec_2, "GetSubSurf did not report the sub-surfaces in order"

# The index form and the ID vector have to agree.
id_vec = GetSubSurfIDVec( wid )

assert len( id_vec ) == 2, "GetSubSurf disagrees with GetSubSurfIDVec"
assert id_vec[1] == GetSubSurf( wid, 1 ), "GetSubSurf disagrees with GetSubSurfIDVec"

# An index past the end has to be rejected.  The error queue is reached
# through the error manager singleton in Python.
err_mgr = ErrorMgrSingleton.getInstance()

GetSubSurf( wid, 2 )

assert err_mgr.GetNumTotalErrors() > 0, "GetSubSurf accepted an index past the end"

# That error was raised deliberately, so take it back off the queue.
while err_mgr.GetNumTotalErrors() > 0 :
    err = err_mgr.PopLastError()
Parameters:
  • [in] – geom_id string Geom ID

  • [in] – index int Sub-surface index

Return type:

string

Returns:

string Sub-surface ID


Overload 2:

Get the ID of the specified sub-surface

wid = AddGeom( "WING", "" ) # Add Wing

ss_rec_1 = AddSubSurf( wid, SS_RECTANGLE ) # Add Sub Surface Rectangle #1

ss_rec_2 = AddSubSurf( wid, SS_RECTANGLE ) # Add Sub Surface Rectangle #2

print( ss_rec_2, False )

print( " = ", False )

print( GetSubSurf( wid, 1 ) )

# Sub-surfaces come back in the order they were added.
assert GetSubSurf( wid, 0 ) == ss_rec_1, "GetSubSurf did not report the sub-surfaces in order"
assert GetSubSurf( wid, 1 ) == ss_rec_2, "GetSubSurf did not report the sub-surfaces in order"

# The index form and the ID vector have to agree.
id_vec = GetSubSurfIDVec( wid )

assert len( id_vec ) == 2, "GetSubSurf disagrees with GetSubSurfIDVec"
assert id_vec[1] == GetSubSurf( wid, 1 ), "GetSubSurf disagrees with GetSubSurfIDVec"

# An index past the end has to be rejected.  The error queue is reached
# through the error manager singleton in Python.
err_mgr = ErrorMgrSingleton.getInstance()

GetSubSurf( wid, 2 )

assert err_mgr.GetNumTotalErrors() > 0, "GetSubSurf accepted an index past the end"

# That error was raised deliberately, so take it back off the queue.
while err_mgr.GetNumTotalErrors() > 0 :
    err = err_mgr.PopLastError()
Parameters:
  • [in] – geom_id string Geom ID

  • [in] – name string Sub surface name

Return type:

std::vector< std::string,std::allocator< std::string > >

Returns:

vector<string> Vector of sub-surface ID

openvsp.DeleteSubSurf(*args)[source]

Overload 1:

Delete the specified sub-surface

wid = AddGeom( "WING", "" )                             # Add Wing

ss_line_id = AddSubSurf( wid, SS_LINE )                      # Add Sub Surface Line
ss_rec_id = AddSubSurf( wid, SS_RECTANGLE )                        # Add Sub Surface Rectangle

print("Delete SS_Line\n")

num_before_del = GetNumSubSurf( wid )
DeleteSubSurf( wid, ss_line_id )
assert GetNumSubSurf( wid ) < num_before_del, "DeleteSubSurf removed nothing"


num_ss = GetNumSubSurf( wid )

num_str = f"Number of SubSurfaces: {num_ss}\n"

print( num_str )
Parameters:
  • [in] – geom_id string Geom ID

  • [in] – sub_id string Sub-surface ID


Overload 2:

Delete the specified sub-surface

wid = AddGeom( "WING", "" )                             # Add Wing

ss_line_id = AddSubSurf( wid, SS_LINE )                      # Add Sub Surface Line
ss_rec_id = AddSubSurf( wid, SS_RECTANGLE )                        # Add Sub Surface Rectangle

print("Delete SS_Line\n")

num_before_del = GetNumSubSurf( wid )
DeleteSubSurf( ss_line_id )
assert GetNumSubSurf( wid ) < num_before_del, "DeleteSubSurf removed nothing"


num_ss = GetNumSubSurf( wid )

num_str = f"Number of SubSurfaces: {num_ss}\n"

print( num_str )
Parameters:

[in] – sub_id string Sub-surface ID

openvsp.ReorderSubSurf(geom_id, sub_id, reorder_type)[source]

Move a sub-surface within its parent Geom’s sub-surface list, the way the move buttons on the Sub-Surface tab do. Sub-surfaces are applied in list order, so where one sits decides which of two overlapping sub-surfaces tags a given piece of the surface.

wing_id = AddGeom( "WING", "" )

ss_line = AddSubSurf( wing_id, SS_LINE )
ss_rect = AddSubSurf( wing_id, SS_RECTANGLE )

assert GetSubSurf( wing_id, 0 ) == ss_line, "the sub-surfaces did not start in creation order"

ReorderSubSurf( wing_id, ss_rect, REORDER_MOVE_TOP )

assert GetSubSurf( wing_id, 0 ) == ss_rect, "ReorderSubSurf did not move the sub-surface"

See also: AddSubSurf, DeleteSubSurf :param [in]: geom_id string Geom ID :param [in]: sub_id string Sub-surface ID :param [in]: reorder_type int Reorder type enum (see REORDER_TYPE)

openvsp.SetSubSurfName(*args)[source]

Overload 1:

Set the name of the specified sub-surface

wid = AddGeom( "WING", "" )                             # Add Wing

ss_rec_id = AddSubSurf( wid, SS_RECTANGLE )                        # Add Sub Surface Rectangle

new_name = "New_SS_Rec_Name"

SetSubSurfName( wid, ss_rec_id, new_name )
assert GetSubSurfName( wid, ss_rec_id ) == new_name, "SetSubSurfName did not take"
Parameters:
  • [in] – geom_id string Geom ID

  • [in] – sub_id string Sub-surface ID

  • [in] – name string Sub-surface name


Overload 2:

Set the name of the specified sub-surface

wid = AddGeom( "WING", "" )                             # Add Wing

ss_rec_id = AddSubSurf( wid, SS_RECTANGLE )                        # Add Sub Surface Rectangle

new_name = "New_SS_Rec_Name"

SetSubSurfName( ss_rec_id, new_name )
assert GetSubSurfName( ss_rec_id ) == new_name, "SetSubSurfName did not take"
Parameters:
  • [in] – sub_id string Sub-surface ID

  • [in] – name string Sub-surface name

openvsp.GetSubSurfName(*args)[source]

Overload 1:

Get the name of the specified sub-surface

wid = AddGeom( "WING", "" )                             # Add Wing

ss_rec_id = AddSubSurf( wid, SS_RECTANGLE )                        # Add Sub Surface Rectangle

rec_name = GetSubSurfName( wid, ss_rec_id )
assert len( rec_name ) > 0, "GetSubSurfName returned nothing"

name_str = "Current Name of SS_Rectangle: " + rec_name + "\n"

print( name_str )
Parameters:
  • [in] – geom_id string Geom ID

  • [in] – sub_id string Sub-surface ID

Return type:

string

Returns:

string Sub-surface name


Overload 2:

Get the name of the specified sub-surface

wid = AddGeom( "WING", "" )                             # Add Wing

ss_rec_id = AddSubSurf( wid, SS_RECTANGLE )                        # Add Sub Surface Rectangle

rec_name = GetSubSurfName( wid, ss_rec_id )
assert len( rec_name ) > 0, "GetSubSurfName returned nothing"

name_str = "Current Name of SS_Rectangle: " + rec_name + "\n"

print( name_str )
Parameters:

[in] – sub_id string Sub-surface ID

Return type:

string

Returns:

string Sub-surface name

openvsp.GetSubSurfIndex(sub_id)[source]

Get the index of the specified sub-surface in its parent Geom’s sub-surface vector

wid = AddGeom( "WING", "" )                             # Add Wing

ss_line_id = AddSubSurf( wid, SS_LINE )                      # Add Sub Surface Line
ss_rec_id = AddSubSurf( wid, SS_RECTANGLE )                        # Add Sub Surface Rectangle

ind = GetSubSurfIndex( ss_rec_id )

ind_str = f"Index of SS_Rectangle: {ind}"

print( ind_str )

# The rectangle was added second, so it sits at index 1.
assert ind == 1, "GetSubSurfIndex did not report the order they were added"
assert GetSubSurfIndex( ss_line_id ) == 0, "GetSubSurfIndex did not report the order they were added"

# The index has to lead back to the same sub-surface.
assert GetSubSurf( wid, ind ) == ss_rec_id, "GetSubSurfIndex disagrees with GetSubSurf"
Parameters:

[in] – sub_id string Sub-surface ID

Return type:

int

Returns:

int Sub-surface index

openvsp.GetSubSurfIDVec(geom_id)[source]

Get a vector of all sub-surface IDs for the specified geometry

wid = AddGeom( "WING", "" )                             # Add Wing

ss_line_id = AddSubSurf( wid, SS_LINE )                      # Add Sub Surface Line
ss_rec_id = AddSubSurf( wid, SS_RECTANGLE )                        # Add Sub Surface Rectangle

id_vec = GetSubSurfIDVec( wid )
assert len( id_vec ) > 0, "GetSubSurfIDVec returned nothing"

id_type_str = "SubSurface IDs and Type Indexes -> "

for i in range(len(id_vec)):

    id_type_str += id_vec[i]

    id_type_str += ": "

    id_type_str += f'{GetSubSurfType(id_vec[i])}'

    id_type_str += "\t"

id_type_str += "\n"

print( id_type_str )
Parameters:

[in] – geom_id string Geom ID

Return type:

std::vector< std::string,std::allocator< std::string > >

Returns:

vector<int> Array of sub-surface IDs

openvsp.GetAllSubSurfIDs()[source]

Get a vector of all sub-surface IDs for the entire model

pid = AddGeom( "POD" )

AddSubSurf( pid, SS_RECTANGLE )

Update()

assert len( GetAllSubSurfIDs() ) == 1, "GetAllSubSurfIDs did not report the sub-surface"
Return type:

std::vector< std::string,std::allocator< std::string > >

Returns:

vector<string> Array of sub-surface IDs

openvsp.GetNumSubSurf(geom_id)[source]

Get the number of sub-surfaces for the specified Geom

wid = AddGeom( "WING", "" )                             # Add Wing

ss_line_id = AddSubSurf( wid, SS_LINE )                      # Add Sub Surface Line
ss_rec_id = AddSubSurf( wid, SS_RECTANGLE )                        # Add Sub Surface Rectangle

num_ss = GetNumSubSurf( wid )

assert num_ss == 2, "GetNumSubSurf, two were added"

num_str = "Number of SubSurfaces: {num_ss}"

print( num_str )
Parameters:

[in] – geom_id string Geom ID

Return type:

int

Returns:

int Number of Sub-surfaces

openvsp.GetSubSurfType(sub_id)[source]

Get the type for the specified sub-surface (i.e. SS_RECTANGLE)

wid = AddGeom( "WING", "" )                             # Add Wing

ss_line_id = AddSubSurf( wid, SS_LINE )                      # Add Sub Surface Line
ss_rec_id = AddSubSurf( wid, SS_RECTANGLE )                        # Add Sub Surface Rectangle

id_vec = GetSubSurfIDVec( wid )

# Each sub-surface has to report the type it was created as.
assert GetSubSurfType( ss_line_id ) == SS_LINE, "GetSubSurfType did not report the type that was added"
assert GetSubSurfType( ss_rec_id ) == SS_RECTANGLE, "GetSubSurfType did not report the type that was added"

id_type_str = "SubSurface IDs and Type Indexes -> "

for i in range(len(id_vec)):

    id_type_str += id_vec[i]

    id_type_str += ": "

    id_type_str += f'{GetSubSurfType(id_vec[i])}'

    id_type_str += "\t"

id_type_str += "\n"

print( id_type_str )

See also: SUBSURF_TYPE :param [in]: sub_id string Sub-surface ID :rtype: int :return: int Sub-surface type enum (i.e. SS_RECTANGLE)

openvsp.GetSubSurfParmIDs(sub_id)[source]

Get the vector of Parm IDs for specified sub-surface

wid = AddGeom( "WING", "" )                             # Add Wing

ss_line_id = AddSubSurf( wid, SS_LINE )                      # Add Sub Surface Line

# Get and list all Parm info for SS_Line
parm_id_vec = GetSubSurfParmIDs( ss_line_id )
assert len( parm_id_vec ) > 0, "GetSubSurfParmIDs returned nothing"

for i in range(len(parm_id_vec)):

    id_name_str = "\tName: " + GetParmName(parm_id_vec[i]) + ", Group: " + GetParmDisplayGroupName(parm_id_vec[i]) + ", ID: " + str(parm_id_vec[i]) + "\n"


    print( id_name_str )
Parameters:

[in] – sub_id string Sub-surface ID

Return type:

std::vector< std::string,std::allocator< std::string > >

Returns:

vector<string> Vector of Parm IDs

openvsp.IntersectSubSurf(sub_id)[source]

Trigger intersection for SS_INTERSECT type subsurfaces

pid = AddGeom( "POD", "" )
p2id = AddGeom( "POD", "" )

xpod2 = GetParm( p2id, "X_Rel_Location", "XForm" )
SetParmVal( xpod2, 4.0 )

zrotpod2 = GetParm( p2id, "Z_Rel_Rotation", "XForm" )
SetParmVal( zrotpod2, 60.0 )

sub_id = AddSubSurf( pid, SS_INTERSECT )

Update()

SetIntersectSubSurfGeomID( sub_id, p2id )

IntersectSubSurf( sub_id )

Update()

# The sub-surface is an intersection of the two Pods, and it belongs to the
# first one.
assert GetSubSurfType( sub_id ) == SS_INTERSECT, "the sub-surface is not an intersection"

sub_ids = GetSubSurfIDVec( pid )

assert len( sub_ids ) == 1, "the intersection sub-surface is not on the Geom it was added to"
assert sub_ids[0] == sub_id, "the intersection sub-surface is not on the Geom it was added to"

# Naming a Geom that does not exist has to be rejected.  The error queue is
# reached through the error manager singleton in Python.
err_mgr = ErrorMgrSingleton.getInstance()

SetIntersectSubSurfGeomID( sub_id, "NOSUCHGEOM" )

IntersectSubSurf( sub_id )

assert err_mgr.GetNumTotalErrors() > 0, "a bad Geom ID was accepted for the intersection"

# That error was raised deliberately, so take it back off the queue.
while err_mgr.GetNumTotalErrors() > 0 :
    err = err_mgr.PopLastError()
Parameters:

[in] – sub_id string Sub-surface ID

openvsp.GetIntersectSubSurfGeomID(sub_id)[source]

Set Geom ID to intersect parent with to create intersection SS_INTERSECT type subsurfaces

pid = AddGeom( "POD", "" )
p2id = AddGeom( "POD", "" )

xpod2 = GetParm( p2id, "X_Rel_Location", "XForm" )
SetParmVal( xpod2, 4.0 )

zrotpod2 = GetParm( p2id, "Z_Rel_Rotation", "XForm" )
SetParmVal( zrotpod2, 60.0 )

sub_id = AddSubSurf( pid, SS_INTERSECT )

Update()

SetIntersectSubSurfGeomID( sub_id, p2id )

IntersectSubSurf( sub_id )

Update()

# The sub-surface is an intersection of the two Pods, and it belongs to the
# first one.
assert GetSubSurfType( sub_id ) == SS_INTERSECT, "the sub-surface is not an intersection"

sub_ids = GetSubSurfIDVec( pid )

assert len( sub_ids ) == 1, "the intersection sub-surface is not on the Geom it was added to"
assert sub_ids[0] == sub_id, "the intersection sub-surface is not on the Geom it was added to"

# Naming a Geom that does not exist has to be rejected.  The error queue is
# reached through the error manager singleton in Python.
err_mgr = ErrorMgrSingleton.getInstance()

SetIntersectSubSurfGeomID( sub_id, "NOSUCHGEOM" )

IntersectSubSurf( sub_id )

assert err_mgr.GetNumTotalErrors() > 0, "a bad Geom ID was accepted for the intersection"

# That error was raised deliberately, so take it back off the queue.
while err_mgr.GetNumTotalErrors() > 0 :
    err = err_mgr.PopLastError()
Parameters:
  • [in] – sub_id string Sub-surface ID

  • [in] – geom_id string Geom ID to intersect with parent to create subsurface

Get the Geom ID that an SS_INTERSECT type sub-surface intersects its parent with

pid = AddGeom( "POD", "" )
p2id = AddGeom( "POD", "" )

sub_id = AddSubSurf( pid, SS_INTERSECT )

Update()

SetIntersectSubSurfGeomID( sub_id, p2id )

assert GetIntersectSubSurfGeomID( sub_id ) == p2id, "GetIntersectSubSurfGeomID did not report the Geom that was set"

# A sub-surface of the wrong type has to be rejected.  The error queue is
# reached through the error manager singleton in Python.
err_mgr = ErrorMgrSingleton.getInstance()

line_id = AddSubSurf( pid, SS_LINE )

GetIntersectSubSurfGeomID( line_id )

assert err_mgr.GetNumTotalErrors() > 0, "GetIntersectSubSurfGeomID accepted a sub-surface of the wrong type"

# That error was raised deliberately, so take it back off the queue.
while err_mgr.GetNumTotalErrors() > 0 :
    err = err_mgr.PopLastError()

See also: SetIntersectSubSurfGeomID, IntersectSubSurf :param [in]: sub_id string Sub-surface ID :rtype: string :return: string Geom ID the sub-surface intersects with

openvsp.SetIntersectSubSurfGeomID(sub_id, geom_id)[source]

Say which Geom a sub-surface belongs to for intersection purposes.

pid = AddGeom( "POD" )

ssid = AddSubSurf( pid, SS_INTERSECT )

Update()

SetIntersectSubSurfGeomID( ssid, pid )

See also: AddSubSurf :param [in]: sub_id string Sub-surface ID :param [in]: geom_id string Geom ID the sub-surface belongs to