Geom Functions

This group of functions is available for adding, deleting, and modifying OpenVSP Geoms through the API.

SetGeomMaterialName(geom_id, name)

Set the material a Geom is drawn with, by name.

GetGeomTypes()

Get an array of all Geom types (i.e FUSELAGE, POD, etc.)

AddGeom(*args)

Add a new Geom of given type as a child of the specified parent.

UpdateGeom(geom_id)

Perform an update for the specified Geom

DeleteGeom(geom_id)

Delete a particular Geom

DeleteGeomVec(del_vec)

Delete multiple Geoms

CutGeomToClipboard(geom_id)

Cut Geom from current location and store on clipboard

CopyGeomToClipboard(geom_id)

Copy Geom from current location and store on clipboard

PasteGeomClipboard(*args)

Paste Geom from clipboard into the model.

FindGeoms()

Find and return all Geom IDs in the model

FindGeomsWithName(name)

Find and return all Geom IDs with the specified name

FindGeom(name, index)

Find and return the Geom ID with the specified name at given index.

SetGeomName(geom_id, name)

Set the name of the specified Geom

GetGeomName(geom_id)

Get the name of a specific Geom

GetGeomParmIDs(geom_id)

Get all Parm IDs associated with this Geom Parm container

GetGeomTypeName(geom_id)

Get the type name of specified Geom (i.e. FUSELAGE).

SetGeomParent(geom_id, parent_id)

Get the parent Geom ID for the input child Geom.

ReorderGeom(geom_id, reorder_type)

Move a Geom within the list of its siblings, the way the move buttons beside the Geom browser do.

AttachGeomTexture(geom_id, file_name)

Attach a texture image to a Geom, the way the Add button on the Texture screen does.

RemoveGeomTexture(geom_id, texture_id)

Remove a texture from a Geom, the way the Delete button on the Texture screen does.

GetGeomTextureIDVec(geom_id)

Get the ParmContainer IDs of all the textures attached to a Geom, in the order they are drawn.

GetGeomTextureFileName(geom_id, texture_id)

Get the image file a texture was attached from.

GetGeomParent(geom_id)

Get the parent Geom ID for the input child Geom.

GetGeomChildren(geom_id)

Get the IDs for each child of the input parent Geom.

GetNumMainSurfs(geom_id)

Get the number of main surfaces for the specified Geom.

GetTotalNumSurfs(geom_id)

Get the total number of surfaces for the specified Geom.

GetGeomVSPSurfType(geom_id[, main_surf_ind])

Get the VSP surface type of the specified Geom

GetGeomVSPSurfCfdType(geom_id[, main_surf_ind])

Get the VSP surface CFD type of the specified Geom

GetGeomBBoxMax(geom_id[, main_surf_ind, ...])

Get the the maximum coordinate of the bounding box of a Geom with given main surface index.

GetGeomBBoxMin(geom_id[, main_surf_ind, ...])

Get the the minimum coordinate of the bounding box of a Geom with given main surface index.

SplitWingXSec(wing_id, section_index)

Split a given wing section.

GetDriverGroup(geom_id, section_index)

Set the driver group for a wing section or a XSecCurve.

ResetPropellerThickness(geom_id)

Rebuild a propeller's thickness curve from the airfoils actually on its cross sections, the way the Reset Thickness button on the Prop screen does.

PasteAirfoil(geom_id, index)

Paste the airfoil clipboard onto a wing section

ClearSkinning(geom_id[, index])

Clear the skinning of one cross section, or of every cross section when the index is left at -1.

ResetGeomScale(geom_id)

Discard a Geom's pending scale and return it to its unscaled size.

AcceptGeomScale(geom_id)

Turn a MeshGeom into a Point Cloud Geom made of its mesh nodes.

GetPtCloudPnts(geom_id)

Get the points of a Point Cloud Geom

CreateNGonMeshGeom(geom_id)

Turn a MeshGeom into an NGon Mesh Geom.

CreateConvexHull(geom_id)

Build the convex hull of a Point Cloud Geom.

ProjectPtCloudPts(geom_id, target_geom_id, ...)

Project the points of a point cloud onto a surface of another Geom, the way the Project button on the Point Cloud screen does.

Details

openvsp.SetGeomMaterialName(geom_id, name)[source]

Set the material a Geom is drawn with, by name. The name must be one of the materials in the material library.

pid = AddGeom( "POD" )

Update()

SetGeomMaterialName( pid, "Aluminum" )

See also: AddMaterial :param [in]: geom_id string Geom ID :param [in]: name string Material name

openvsp.GetGeomTypes()[source]

Get an array of all Geom types (i.e FUSELAGE, POD, etc.)

#==== Add Pod Geometries ====//
pod1 = AddGeom( "POD", "" )
pod2 = AddGeom( "POD", "" )

type_array = GetGeomTypes()

if ( type_array[0] != "POD" ):
    print( "---> Error: API GetGeomTypes  " )
    assert False, "---> Error: API GetGeomTypes"
Return type:

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

Returns:

vector<string> Array of Geom type names

openvsp.AddGeom(*args)[source]

Add a new Geom of given type as a child of the specified parent. If no parent or an invalid parent is given, the Geom is placed at the top level

#==== Add Wing Geometry ====//
wing_id = AddGeom( "WING" )
Parameters:
  • [in] – type string Geom type (i.e FUSELAGE, POD, etc.)

  • [in] – parent string Parent Geom ID

Return type:

string

Returns:

string Geom ID

openvsp.UpdateGeom(geom_id)[source]

Perform an update for the specified Geom

#==== Add Wing Geometry ====//
wing_id = AddGeom( "WING" )

#==== Add Pod Geometry ====//
pod_id = AddGeom( "POD" )

Update()

before_min = GetGeomBBoxMin( pod_id, 0, True )

SetParmVal( pod_id, "X_Rel_Location", "XForm", 5.0 )

UpdateGeom( pod_id ) # Faster than updating the whole vehicle

# Updating just this Geom has to move it, the same as a full Update would.
after_min = GetGeomBBoxMin( pod_id, 0, True )

assert abs( ( after_min.x() - before_min.x() ) - 5.0 ) < 1e-6, "UpdateGeom did not rebuild the Geom"

See also: Update() :param [in]: geom_id string Geom ID

openvsp.DeleteGeom(geom_id)[source]

Delete a particular Geom

#==== Add Wing Geometry ====//
wing_id = AddGeom( "WING" )

#==== Add Pod Geometry ====//
pod_id = AddGeom( "POD" )

num_before_del = len( FindGeoms() )
DeleteGeom( wing_id )
assert len( FindGeoms() ) < num_before_del, "DeleteGeom removed nothing"
Parameters:

[in] – geom_id string Geom ID

openvsp.DeleteGeomVec(del_vec)[source]

Delete multiple Geoms

#==== Add Pod Geometry ====//
pid = AddGeom( "POD", "" )

rid = ExecAnalysis( "CompGeom" )

mesh_id_vec = GetStringResults( rid, "Mesh_GeomID" )

num_before_del = len( FindGeoms() )
DeleteGeomVec( mesh_id_vec )
assert len( FindGeoms() ) < num_before_del, "DeleteGeomVec removed nothing"
Parameters:

[in] – del_vec vector<string> Vector of Geom IDs

openvsp.CutGeomToClipboard(geom_id)[source]

Cut Geom from current location and store on clipboard

#==== Add Pod Geometries ====//
pid1 = AddGeom( "POD", "" )
pid2 = AddGeom( "POD", "" )

CutGeomToClipboard( pid1 )

PasteGeomClipboard( pid2 ) # Paste Pod 1 as child of Pod 2

geom_ids = FindGeoms()

if  len(geom_ids) != 2 :
    print( "---> Error: API Cut/Paste Geom  " )
    assert False, "---> Error: API Cut/Paste Geom"

See also: PasteGeomClipboard :param [in]: geom_id string Geom ID

openvsp.CopyGeomToClipboard(geom_id)[source]

Copy Geom from current location and store on clipboard

#==== Add Pod Geometries ====//
pid1 = AddGeom( "POD", "" )
pid2 = AddGeom( "POD", "" )

CopyGeomToClipboard( pid1 )

PasteGeomClipboard( pid2 ) # Paste Pod 1 as child of Pod 2

geom_ids = FindGeoms()

if  len(geom_ids) != 3 :
    print( "---> Error: API Copy/Paste Geom  " )
    assert False, "---> Error: API Copy/Paste Geom"

See also: PasteGeomClipboard :param [in]: geom_id string Geom ID

openvsp.PasteGeomClipboard(*args)[source]

Paste Geom from clipboard into the model. The Geom is pasted as a child of the specified parent, but will be placed at top level if no parent or an invalid one is provided.

#==== Add Pod Geometries ====//
pid1 = AddGeom( "POD", "" )
pid2 = AddGeom( "POD", "" )

CutGeomToClipboard( pid1 )

PasteGeomClipboard( pid2 ) # Paste Pod 1 as child of Pod 2

geom_ids = FindGeoms()

if  len(geom_ids) != 2 :
    print( "---> Error: API Cut/Paste Geom  " )
    assert False, "---> Error: API Cut/Paste Geom"
Parameters:

[in] – parent string Parent Geom ID

Return type:

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

Returns:

vector<string> Vector of pasted Geom IDs

openvsp.FindGeoms()[source]

Find and return all Geom IDs in the model

#==== Add Pod Geometries ====//
pod1 = AddGeom( "POD", "" )
pod2 = AddGeom( "POD", "" )

#==== There Should Be Two Geoms =====//
geom_ids = FindGeoms()

if  len(geom_ids) != 2 :
    print( "---> Error: API FindGeoms " )
    assert False, "---> Error: API FindGeoms"
Return type:

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

Returns:

vector<string> Array of all Geom IDs

openvsp.FindGeomsWithName(name)[source]

Find and return all Geom IDs with the specified name

#==== Add Pod Geometry ====//
pid = AddGeom( "POD", "" )

SetGeomName( pid, "ExamplePodName" )

geom_ids = FindGeomsWithName( "ExamplePodName" )

if  len(geom_ids) != 1 :
    print( "---> Error: API FindGeomsWithName " )
    assert False, "---> Error: API FindGeomsWithName"

See also: FindGeom :param [in]: name string Geom name :rtype: std::vector< std::string,std::allocator< std::string > > :return: vector<string> Array of Geom IDs

openvsp.FindGeom(name, index)[source]

Find and return the Geom ID with the specified name at given index. Equivalent to FindGeomsWithName( name )[index].

#==== Add Pod Geometry ====//
pid = AddGeom( "POD", "" )

SetGeomName( pid, "ExamplePodName" )

geom_id = FindGeom( "ExamplePodName", 0 )

geom_ids = FindGeomsWithName( "ExamplePodName" )

if  geom_ids[0] != geom_id :
    print( "---> Error: API FindGeom & FindGeomsWithName" )
    assert False, "---> Error: API FindGeom & FindGeomsWithName"

See also: FindGeomsWithName :param [in]: name string Geom name :param [in]: index :rtype: string :return: string Geom ID with name at specified index

openvsp.SetGeomName(geom_id, name)[source]

Set the name of the specified Geom

#==== Add Pod Geometry ====//
pid = AddGeom( "POD", "" )

SetGeomName( pid, "ExamplePodName" )

geom_ids = FindGeomsWithName( "ExamplePodName" )

if  len(geom_ids) != 1 :
    print( "---> Error: API FindGeomsWithName " )
    assert False, "---> Error: API FindGeomsWithName"
Parameters:
  • [in] – geom_id string Geom ID

  • [in] – name string Geom name

openvsp.GetGeomName(geom_id)[source]

Get the name of a specific Geom

#==== Add Pod Geometry ====//
pid = AddGeom( "POD", "" )

SetGeomName( pid, "ExamplePodName" )

name_str = "Geom Name: " + GetGeomName( pid )

print( name_str )

assert GetGeomName( pid ) == "ExamplePodName", "GetGeomName did not report the name that was set"

# The name is how FindGeomsWithName looks Geoms up.
found = FindGeomsWithName( "ExamplePodName" )

assert len( found ) == 1, "GetGeomName disagrees with FindGeomsWithName"
assert found[0] == pid, "GetGeomName disagrees with FindGeomsWithName"
Parameters:

[in] – geom_id string Geom ID

Return type:

string

Returns:

string Geom name

openvsp.GetGeomParmIDs(geom_id)[source]

Get all Parm IDs associated with this Geom Parm container

#==== Add Pod Geometry ====//
pid = AddGeom( "POD", "" )

print( "---> Test Get Parm Arrays" )

parm_array = GetGeomParmIDs( pid )

if  len(parm_array) < 1 :
    print( "---> Error: API GetGeomParmIDs " )
    assert False, "---> Error: API GetGeomParmIDs"
Parameters:

[in] – geom_id string Geom ID

Return type:

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

Returns:

vector<string> Array of Parm IDs

openvsp.GetGeomTypeName(geom_id)[source]

Get the type name of specified Geom (i.e. FUSELAGE)

#==== Add Wing Geometry ====//
wing_id = AddGeom( "WING" )

print( "Geom Type Name: ", False )

print( GetGeomTypeName( wing_id ) )

assert GetGeomTypeName( wing_id ) == "Wing", "GetGeomTypeName did not report the type that was added"

# A Geom of a different type has to report a different name.
pod_id = AddGeom( "POD" )

assert GetGeomTypeName( pod_id ) != GetGeomTypeName( wing_id ), "GetGeomTypeName gave two types the same name"
Parameters:

[in] – geom_id string Geom ID

Return type:

string

Returns:

string Geom type name

openvsp.SetGeomParent(geom_id, parent_id)[source]

Get the parent Geom ID for the input child Geom. “NONE” is returned if the Geom has no parent.

#==== Reparent two PodGeoms ====#
pod1 = AddGeom( "POD" )
pod2 = AddGeom( "POD", pod1 )
pod3 = AddGeom ("POD" )

veh_id = GetVehicleID()

SetGeomParent( pod2, veh_id )
SetGeomParent( pod3, pod1 )

pod2_parent = GetGeomParent( pod2 )
pod3_parent = GetGeomParent( pod3 )

if ( pod2_parent != "NONE" or pod3_parent != pod1 ):
    print( "SetGeomParent error!" )
    assert False, "SetGeomParent error!"
Parameters:
  • [in] – geom_id string Geom ID

  • [in] – parent_id string Parent Geom ID

openvsp.ReorderGeom(geom_id, reorder_type)[source]

Move a Geom within the list of its siblings, the way the move buttons beside the Geom browser do. A Geom’s position among its siblings sets the order it is written, exported and drawn in; it does not change the Geom’s parent or its geometry.

pod1 = AddGeom( "POD", "" )
pod2 = AddGeom( "POD", "" )

# Both Pods sit at the top level, in the order they were added.
assert FindGeoms()[0] == pod1, "the Geoms did not start in creation order"

ReorderGeom( pod2, REORDER_MOVE_UP )

assert FindGeoms()[0] == pod2, "ReorderGeom did not move the Geom"

ReorderGeom( pod2, REORDER_MOVE_BOTTOM )

assert FindGeoms()[0] == pod1, "ReorderGeom did not move the Geom back"

See also: SetGeomParent :param [in]: geom_id string Geom ID :param [in]: reorder_type int Reorder type enum (see REORDER_TYPE)

openvsp.AttachGeomTexture(geom_id, file_name)[source]

Attach a texture image to a Geom, the way the Add button on the Texture screen does. A texture is drawn on the Geom’s surface at a placement given by its Parms; the returned ID is a ParmContainer ID, so U, W, U_Scale, W_Scale, Transparency, U_Flip and W_Flip in the “Texture_Parm” group are reached the usual way.

pod_id = AddGeom( "POD", "" )

tex_id = AttachGeomTexture( pod_id, "textures/nasa-logo.tga" )

assert len( tex_id ) > 0, "AttachGeomTexture attached nothing"

# Place the logo on the upper surface, at half size.
SetParmVal( tex_id, "U", "Texture_Parm", 0.35 )
SetParmVal( tex_id, "W", "Texture_Parm", 0.25 )
SetParmVal( tex_id, "U_Scale", "Texture_Parm", 0.5 )
SetParmVal( tex_id, "W_Scale", "Texture_Parm", 0.5 )

Update()

tex_ids = GetGeomTextureIDVec( pod_id )

assert len( tex_ids ) == 1, "the texture is not in the texture list"
assert tex_ids[0] == tex_id, "the texture is not in the texture list"

See also: RemoveGeomTexture, GetGeomTextureIDVec, GetGeomTextureFileName :param [in]: geom_id string Geom ID :param [in]: file_name string Name of the texture image file :rtype: string :return: string ParmContainer ID for the attached texture

openvsp.RemoveGeomTexture(geom_id, texture_id)[source]

Remove a texture from a Geom, the way the Delete button on the Texture screen does.

pod_id = AddGeom( "POD", "" )

tex_id = AttachGeomTexture( pod_id, "textures/nasa-logo.tga" )

RemoveGeomTexture( pod_id, tex_id )

assert len( GetGeomTextureIDVec( pod_id ) ) == 0, "RemoveGeomTexture left the texture behind"

See also: AttachGeomTexture, GetGeomTextureIDVec :param [in]: geom_id string Geom ID :param [in]: texture_id string Texture ParmContainer ID

openvsp.GetGeomTextureIDVec(geom_id)[source]

Get the ParmContainer IDs of all the textures attached to a Geom, in the order they are drawn.

pod_id = AddGeom( "POD", "" )

# A fresh Geom carries no textures.
assert len( GetGeomTextureIDVec( pod_id ) ) == 0, "a new Geom already carries textures"

AttachGeomTexture( pod_id, "textures/nasa-logo.tga" )
AttachGeomTexture( pod_id, "textures/window.tga" )

assert len( GetGeomTextureIDVec( pod_id ) ) == 2, "GetGeomTextureIDVec, two were attached"

See also: AttachGeomTexture, RemoveGeomTexture :param [in]: geom_id string Geom ID :rtype: std::vector< std::string,std::allocator< std::string > > :return: vector<string> Vector of texture ParmContainer IDs

openvsp.GetGeomTextureFileName(geom_id, texture_id)[source]

Get the image file a texture was attached from.

pod_id = AddGeom( "POD", "" )

tex_id = AttachGeomTexture( pod_id, "textures/nasa-logo.tga" )

assert GetGeomTextureFileName( pod_id, tex_id ) == "textures/nasa-logo.tga", "GetGeomTextureFileName did not report the file"

See also: AttachGeomTexture :param [in]: geom_id string Geom ID :param [in]: texture_id string Texture ParmContainer ID :rtype: string :return: string Name of the texture image file

openvsp.GetGeomParent(geom_id)[source]

Get the parent Geom ID for the input child Geom. “NONE” is returned if the Geom has no parent.

#==== Add Parent and Child Geometry ====//
pod1 = AddGeom( "POD" )

pod2 = AddGeom( "POD", pod1 )

print( "Parent ID of Pod #2: ", False )

print( GetGeomParent( pod2 ) )

assert GetGeomParent( pod2 ) == pod1, "GetGeomParent did not report the parent it was given"

# The relationship has to read the same from the other end.
children = GetGeomChildren( pod1 )

assert len( children ) == 1, "GetGeomParent disagrees with GetGeomChildren"
assert children[0] == pod2, "GetGeomParent disagrees with GetGeomChildren"

# A Geom added with no parent sits at the top level.
assert GetGeomParent( pod1 ) == "NONE", "GetGeomParent did not report NONE for a top level Geom"
Parameters:

[in] – geom_id string Geom ID

Return type:

string

Returns:

string Parent Geom ID

openvsp.GetGeomChildren(geom_id)[source]

Get the IDs for each child of the input parent Geom.

#==== Add Parent and Child Geometry ====//
pod1 = AddGeom( "POD" )

pod2 = AddGeom( "POD", pod1 )

pod3 = AddGeom( "POD", pod2 )

print( "Children of Pod #1: " )

children = GetGeomChildren( pod1 )
assert len( children ) > 0, "GetGeomChildren returned nothing"

for i in range(int( len(children) )):

    print( "\t", False )
    print( children[i] )
Parameters:

[in] – geom_id string Geom ID

Return type:

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

Returns:

vector<string> Vector of child Geom IDs

openvsp.GetNumMainSurfs(geom_id)[source]

Get the number of main surfaces for the specified Geom. Multiple main surfaces may exist for CustoGeoms, propellors, etc., but does not include surfaces created due to symmetry.

#==== Add Prop Geometry ====//
prop_id = AddGeom( "PROP" )

num_surf = 0

num_surf = GetNumMainSurfs( prop_id ) # Should be the same as the number of blades

assert num_surf == GetIntParmVal( FindParm( prop_id, "NumBlade", "Design" ) ), "GetNumMainSurfs does not match the blade count"

print( "Number of Propeller Surfaces: ", False )

print( num_surf )
Parameters:

[in] – geom_id string Geom ID

Return type:

int

Returns:

int Number of main surfaces

openvsp.GetTotalNumSurfs(geom_id)[source]

Get the total number of surfaces for the specified Geom. This is equivalent to the number of main surface multiplied by the number of symmetric copies.

#==== Add Wing Geometry ====//
wing_id = AddGeom( "WING" )

num_surf = 0

num_surf = GetTotalNumSurfs( wing_id ) # Wings default with XZ symmetry on -> 2 surfaces

assert num_surf == 2, "GetTotalNumSurfs, expected 2 for a symmetric wing"

print( "Total Number of Wing Surfaces: ", False )

print( num_surf )
Parameters:

[in] – geom_id string Geom ID

Return type:

int

Returns:

int Number of main surfaces

openvsp.GetGeomVSPSurfType(geom_id, main_surf_ind=0)[source]

Get the VSP surface type of the specified Geom

#==== Add Wing Geometry ====//
wing_id = AddGeom( "WING" )

if  GetGeomVSPSurfType( wing_id ) != WING_SURF :
    print( "---> Error: API GetGeomVSPSurfType " )
    assert False, "---> Error: API GetGeomVSPSurfType"

See also: VSP_SURF_TYPE :param [in]: geom_id string Geom ID :param [in]: main_surf_ind int Main surface index :rtype: int :return: int VSP surface type enum (i.e. DISK_SURF)

openvsp.GetGeomVSPSurfCfdType(geom_id, main_surf_ind=0)[source]

Get the VSP surface CFD type of the specified Geom

#==== Add Wing Geometry ====//
wing_id = AddGeom( "WING" )

if  GetGeomVSPSurfCfdType( wing_id ) != CFD_NORMAL :
    print( "---> Error: API GetGeomVSPSurfCfdType " )
    assert False, "---> Error: API GetGeomVSPSurfCfdType"

See also: VSP_SURF_CFD_TYPE :param [in]: geom_id string Geom ID :param [in]: main_surf_ind int Main surface index :rtype: int :return: int VSP surface CFD type enum (i.e. CFD_TRANSPARENT)

openvsp.GetGeomBBoxMax(geom_id, main_surf_ind=0, ref_frame_is_absolute=True)[source]

Get the the maximum coordinate of the bounding box of a Geom with given main surface index. The Geom bounding box may be specified in absolute or body reference frame.

A Geom with no surfaces – a mesh, a point cloud, a wireframe – answers out of its own bounding box, and main_surf_ind does not apply. That box is built in absolute coordinates, so the body reference frame answer is the absolute box turned back through the model matrix, which contains the geometry but is not as tight as the box a surface gives.

#==== Add Pod Geometry ====//
pid = AddGeom( "POD" )

SetParmVal( FindParm( pid, "Y_Rotation", "XForm" ), 45 )
SetParmVal( FindParm( pid, "Z_Rotation", "XForm" ), 25 )

Update()

max_pnt = GetGeomBBoxMax( pid, 0, False )

min_pnt = GetGeomBBoxMin( pid, 0, False )

assert max_pnt.x() > min_pnt.x() and max_pnt.y() > min_pnt.y() and max_pnt.z() > min_pnt.z(), "GetGeomBBoxMax is not above the minimum corner"

See also: GetGeomBBoxMin :param [in]: geom_id string Geom ID :param [in]: main_surf_ind int Main surface index :param [in]: ref_frame_is_absolute bool Flag to specify absolute or body reference frame :rtype: vec3d :return: vec3d Maximum coordinate of the bounding box

openvsp.GetGeomBBoxMin(geom_id, main_surf_ind=0, ref_frame_is_absolute=True)[source]

Get the the minimum coordinate of the bounding box of a Geom with given main surface index. The Geom bounding box may be specified in absolute or body reference frame.

A Geom with no surfaces – a mesh, a point cloud, a wireframe – answers out of its own bounding box, and main_surf_ind does not apply. That box is built in absolute coordinates, so the body reference frame answer is the absolute box turned back through the model matrix, which contains the geometry but is not as tight as the box a surface gives.

#==== Add Pod Geometry ====//
pid = AddGeom( "POD" )

SetParmVal( FindParm( pid, "Y_Rotation", "XForm" ), 45 )
SetParmVal( FindParm( pid, "Z_Rotation", "XForm" ), 25 )

Update()

min_pnt = GetGeomBBoxMin( pid, 0, False )

max_pnt = GetGeomBBoxMax( pid, 0, False )

assert min_pnt.x() < max_pnt.x() and min_pnt.y() < max_pnt.y() and min_pnt.z() < max_pnt.z(), "GetGeomBBoxMin is not below the maximum corner"

See also: GetGeomBBoxMax :param [in]: geom_id string Geom ID :param [in]: main_surf_ind int Main surface index :param [in]: ref_frame_is_absolute bool Flag to specify absolute or body reference frame :rtype: vec3d :return: vec3d Minimum coordinate of the bounding box

openvsp.SplitWingXSec(wing_id, section_index)[source]

Split a given wing section.

wing_id = AddGeom( "WING", "" )

xsec_surf = GetXSecSurf( wing_id, 0 )

num_start = GetNumXSec( xsec_surf )

span_start = GetParmVal( wing_id, "Span", "XSec_1" )

#==== Set Wing Section Controls ====//
SplitWingXSec( wing_id, 1 )

Update()

# Splitting a section turns one section into two, and the two halves span
# what the one section spanned.
assert GetNumXSec( xsec_surf ) == num_start + 1, "SplitWingXSec did not split the section"

span_1 = GetParmVal( wing_id, "Span", "XSec_1" )
span_2 = GetParmVal( wing_id, "Span", "XSec_2" )

assert abs( ( span_1 + span_2 ) - span_start ) < 1e-6, "SplitWingXSec changed the span of the wing"

See also: WING_DRIVERS, XSEC_DRIVERS :param [in]: wing_id string Geom ID :param [in]: section_index int Wing section index

openvsp.GetDriverGroup(geom_id, section_index)[source]

Set the driver group for a wing section or a XSecCurve. Care has to be taken when setting these driver groups to ensure a valid combination.

#==== Add Wing Geometry and Set Parms ====//
wing_id = AddGeom( "WING", "" )

#==== Set Wing Section Controls ====//
SetDriverGroup( wing_id, 1, AR_WSECT_DRIVER, ROOTC_WSECT_DRIVER, TIPC_WSECT_DRIVER )

Update()

#==== Set Parms ====//
SetParmVal( wing_id, "Root_Chord", "XSec_1", 2 )
SetParmVal( wing_id, "Tip_Chord", "XSec_1", 1 )

Update()

# The three chosen drivers are the values that hold; span is now solved for
# from the aspect ratio and the two chords.
ar = GetParmVal( wing_id, "Aspect", "XSec_1" )
span = GetParmVal( wing_id, "Span", "XSec_1" )

assert abs( GetParmVal( wing_id, "Root_Chord", "XSec_1" ) - 2.0 ) < 1e-6, "the driving Parms did not hold their values"
assert abs( GetParmVal( wing_id, "Tip_Chord", "XSec_1" ) - 1.0 ) < 1e-6, "the driving Parms did not hold their values"

# A section of this planform has area span * ( root + tip ) / 2, and aspect
# ratio span * span / area.
area = span * ( 2.0 + 1.0 ) * 0.5

assert abs( ar - span * span / area ) < 1e-6, "SetDriverGroup left the section inconsistent"

See also: WING_DRIVERS, XSEC_DRIVERS :param [in]: geom_id string Geom ID :param [in]: section_index int Wing section index :param [in]: driver_0 int First driver enum (i.e. SPAN_WSECT_DRIVER) :param [in]: driver_1 int Second driver enum (i.e. ROOTC_WSECT_DRIVER) :param [in]: driver_2 int Third driver enum (i.e. TIPC_WSECT_DRIVER)

Get the driver group for a wing section or an XSec. A wing section reports three drivers; an XSecCurve reports the drivers of its own driver group.

#==== Add Wing Geometry ====//
wing_id = AddGeom( "WING", "" )

SetDriverGroup( wing_id, 1, AR_WSECT_DRIVER, ROOTC_WSECT_DRIVER, TIPC_WSECT_DRIVER )

Update()

drivers = GetDriverGroup( wing_id, 1 )

# The drivers come back in the order they were set.
assert len( drivers ) == 3, "GetDriverGroup did not report three wing drivers"
assert drivers[0] == AR_WSECT_DRIVER, "GetDriverGroup did not report the drivers that were set"
assert drivers[1] == ROOTC_WSECT_DRIVER, "GetDriverGroup did not report the drivers that were set"
assert drivers[2] == TIPC_WSECT_DRIVER, "GetDriverGroup did not report the drivers that were set"

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

GetDriverGroup( wing_id, 100 )

assert err_mgr.GetNumTotalErrors() > 0, "GetDriverGroup accepted a section 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()

See also: WING_DRIVERS, XSEC_DRIVERS, SetDriverGroup :param [in]: geom_id string Geom ID :param [in]: section_index int Wing section or XSec index :rtype: std::vector< int,std::allocator< int > > :return: vector<int> Array of driver enums

openvsp.ResetPropellerThickness(geom_id)[source]

Rebuild a propeller’s thickness curve from the airfoils actually on its cross sections, the way the Reset Thickness button on the Prop screen does. The thickness curve normally drives the sections; this runs the relationship the other way once, so a blade built up section by section gets a thickness curve that matches what it already is.

prop_id = AddGeom( "PROP", "" )

Update()

ResetPropellerThickness( prop_id )

# The thickness curve now carries one point per cross section.
tvec = PCurveGetTVec( prop_id, PROP_THICK )

xsec_surf = GetXSecSurf( prop_id, 0 )

assert len( tvec ) == GetNumXSec( xsec_surf ), "ResetPropellerThickness did not rebuild the curve"

See also: ApproximateAllPropellerPCurves, PCurveGetTVec :param [in]: geom_id string Propeller Geom ID

openvsp.PasteAirfoil(geom_id, index)[source]

Paste the airfoil clipboard onto a wing section

wid = AddGeom( "WING" )

Update()

CopyAirfoil( wid, 1 )

# A default wing has two sections, so there is nowhere past 1 to paste to.
PasteAirfoil( wid, 1 )

Update()

See also: CopyAirfoil, PasteXSec :param [in]: geom_id string Wing Geom ID :param [in]: index int Wing section index

openvsp.ClearSkinning(geom_id, index=-1)[source]

Clear the skinning of one cross section, or of every cross section when the index is left at -1. This is the Skinning tab’s Clear and Clear All buttons.

sid = AddGeom( "STACK", "" )

xsec_surf = GetXSecSurf( sid, 0 )

xsec = GetXSec( xsec_surf, 1 )

SetXSecTanAngles( xsec, XSEC_BOTH_SIDES, 15.0, -1.0e12, -1.0e12, -1.0e12 )

Update()

assert abs( GetParmVal( GetXSecParm( xsec, "TopLAngleSet" ) ) - 1.0 ) < 1e-12, "the skinning was never set"

ClearSkinning( sid, 1 )

Update()

# Clearing releases the section's skinning controls and puts symmetry back
# on; the angle itself becomes whatever the skin solves for.
assert abs( GetParmVal( GetXSecParm( xsec, "TopLAngleSet" ) ) ) < 1e-12, "ClearSkinning did not release the section"
assert abs( GetParmVal( GetXSecParm( xsec, "AllSym" ) ) - 1.0 ) < 1e-12, "ClearSkinning did not release the section"

# A Geom with no cross sections has to be rejected.
err_mgr = ErrorMgrSingleton.getInstance()

pid = AddGeom( "POD" )

ClearSkinning( pid )

assert err_mgr.GetNumTotalErrors() > 0, "ClearSkinning accepted a Geom with no cross sections"

while err_mgr.GetNumTotalErrors() > 0 :
    err = err_mgr.PopLastError()

See also: ResetXSecSkinParms :param [in]: geom_id string Geom ID :param [in]: index int Cross section index, or -1 for every section

openvsp.ResetGeomScale(geom_id)[source]

Discard a Geom’s pending scale and return it to its unscaled size. This is the Scale tab’s Reset button. Use AcceptGeomScale to keep the scaled size instead.

pid = AddGeom( "POD" )

Update()

before_max = GetGeomBBoxMax( pid, 0, False )

SetParmValUpdate( pid, "Scale", "XForm", 2.0 )

Update()

scaled_max = GetGeomBBoxMax( pid, 0, False )

assert abs( scaled_max.x() - 2.0 * before_max.x() ) < 1e-6, "the Geom was never scaled"

ResetGeomScale( pid )

Update()

# The scale factor comes back to one and the Geom returns to its base size.
assert abs( GetParmVal( pid, "Scale", "XForm" ) - 1.0 ) < 1e-9, "ResetGeomScale did not reset the scale factor"

after_max = GetGeomBBoxMax( pid, 0, False )

assert abs( after_max.x() - before_max.x() ) < 1e-6, "ResetGeomScale did not undo the scaling"
Parameters:

[in] – geom_id string Geom ID

openvsp.AcceptGeomScale(geom_id)[source]

Turn a MeshGeom into a Point Cloud Geom made of its mesh nodes. This is the Mesh screen’s Convert to Point Cloud button.

pid = AddGeom( "POD" )

mesh_id = ExportFile( "Example_Mesh.msh", SET_ALL, EXPORT_GMSH )

cloud_id = CreatePtCloudGeom( mesh_id )

assert len( cloud_id ) > 0, "CreatePtCloudGeom did not make a point cloud"
assert GetGeomTypeName( cloud_id ) == "PtCloud", "CreatePtCloudGeom did not make a point cloud"

# A Geom that is not a mesh has to be rejected.
err_mgr = ErrorMgrSingleton.getInstance()

CreatePtCloudGeom( pid )

assert err_mgr.GetNumTotalErrors() > 0, "CreatePtCloudGeom accepted a Geom that is not a mesh"

while err_mgr.GetNumTotalErrors() > 0 :
    err = err_mgr.PopLastError()

See also: CreateNGonMeshGeom, CreateConvexHull :param [in]: geom_id string MeshGeom ID :rtype: void :return: string Point Cloud Geom ID

Keep a Geom’s scaled size and reset the scale factor to one, folding the scaling into the Geom’s own dimensions. This is the Scale tab’s Accept button.

pid = AddGeom( "POD" )

Update()

before_max = GetGeomBBoxMax( pid, 0, False )

SetParmValUpdate( pid, "Scale", "XForm", 2.0 )

Update()

AcceptGeomScale( pid )

Update()

# The scale factor comes back to one but the size it produced is kept.
assert abs( GetParmVal( pid, "Scale", "XForm" ) - 1.0 ) < 1e-9, "AcceptGeomScale did not reset the scale factor"

after_max = GetGeomBBoxMax( pid, 0, False )

assert abs( after_max.x() - 2.0 * before_max.x() ) < 1e-6, "AcceptGeomScale did not keep the scaled size"

See also: ResetGeomScale :param [in]: geom_id string Geom ID

openvsp.GetPtCloudPnts(geom_id)[source]

Get the points of a Point Cloud Geom

pid = AddGeom( "POD" )

mesh_id = ExportFile( "Example_Mesh.msh", SET_ALL, EXPORT_GMSH )

cloud_id = CreatePtCloudGeom( mesh_id )

pnts = GetPtCloudPnts( cloud_id )

assert len( pnts ) > 0, "GetPtCloudPnts returned nothing"

# A Geom that is not a point cloud has to be rejected.
err_mgr = ErrorMgrSingleton.getInstance()

GetPtCloudPnts( pid )

assert err_mgr.GetNumTotalErrors() > 0, "GetPtCloudPnts accepted a Geom that is not a point cloud"

while err_mgr.GetNumTotalErrors() > 0 :
    err = err_mgr.PopLastError()

See also: CreatePtCloudGeom, CreateConvexHull :param [in]: geom_id string Point Cloud Geom ID :rtype: std::vector< vec3d,std::allocator< vec3d > > :return: vector<vec3d> Array of point cloud points

openvsp.CreateNGonMeshGeom(geom_id)[source]

Turn a MeshGeom into an NGon Mesh Geom. This is the Mesh screen’s Convert to NGon Mesh button.

pid = AddGeom( "POD" )

mesh_id = ExportFile( "Example_Mesh.msh", SET_ALL, EXPORT_GMSH )

ngon_id = CreateNGonMeshGeom( mesh_id )

assert len( ngon_id ) > 0, "CreateNGonMeshGeom did not make an NGon mesh"
assert GetGeomTypeName( ngon_id ) == "NGonMesh", "CreateNGonMeshGeom did not make an NGon mesh"

# A Geom that is not a mesh has to be rejected.
err_mgr = ErrorMgrSingleton.getInstance()

CreateNGonMeshGeom( pid )

assert err_mgr.GetNumTotalErrors() > 0, "CreateNGonMeshGeom accepted a Geom that is not a mesh"

while err_mgr.GetNumTotalErrors() > 0 :
    err = err_mgr.PopLastError()

See also: CreatePtCloudGeom :param [in]: geom_id string MeshGeom ID :rtype: string :return: string NGon Mesh Geom ID

openvsp.CreateConvexHull(geom_id)[source]

Build the convex hull of a Point Cloud Geom. The hull arrives as a new MeshGeom; the point cloud itself is left alone. This is the Point Cloud screen’s Convex Hull button.

pid = AddGeom( "POD" )

mesh_id = ExportFile( "Example_Mesh.msh", SET_ALL, EXPORT_GMSH )

cloud_id = CreatePtCloudGeom( mesh_id )

num_pnts = len( GetPtCloudPnts( cloud_id ) )

hull_id = CreateConvexHull( cloud_id )

Update()

# The hull is a mesh of its own, and the cloud it came from is untouched.
assert len( hull_id ) > 0, "CreateConvexHull did not make a hull mesh"
assert GetGeomTypeName( hull_id ) == "Mesh", "CreateConvexHull did not make a hull mesh"
assert len( GetPtCloudPnts( cloud_id ) ) == num_pnts, "CreateConvexHull disturbed the point cloud"

# A Geom that is not a point cloud has to be rejected.
err_mgr = ErrorMgrSingleton.getInstance()

CreateConvexHull( pid )

assert err_mgr.GetNumTotalErrors() > 0, "CreateConvexHull accepted a Geom that is not a point cloud"

while err_mgr.GetNumTotalErrors() > 0 :
    err = err_mgr.PopLastError()

See also: CreatePtCloudGeom, GetPtCloudPnts :param [in]: geom_id string Point Cloud Geom ID :rtype: string :return: string MeshGeom ID of the hull

openvsp.ProjectPtCloudPts(geom_id, target_geom_id, surf_index, dir_index)[source]

Project the points of a point cloud onto a surface of another Geom, the way the Project button on the Point Cloud screen does. Each point is moved along the chosen axis until it lands on the target surface; a point that does not hit the surface is left where it is.

pid = AddGeom( "POD" )

# Mesh the Pod, then make a point cloud out of the mesh vertices.
mesh_id = ExportFile( "ProjectExample.msh", SET_ALL, EXPORT_GMSH )

cloud_id = CreatePtCloudGeom( mesh_id )

# Lift the cloud above the Pod so the points have somewhere to fall from.
SetParmVal( cloud_id, "Z_Rel_Location", "XForm", 5.0 )

Update()

before = GetPtCloudPnts( cloud_id )

ProjectPtCloudPts( cloud_id, pid, 0, Z_DIR )

Update()

after = GetPtCloudPnts( cloud_id )

# Projection moves points; it never adds or removes any.
assert len( after ) == len( before ), "ProjectPtCloudPts changed the point count"

See also: CreatePtCloudGeom, CreateConvexHull :param [in]: geom_id string Point cloud Geom ID :param [in]: target_geom_id string Geom ID of the Geom to project onto :param [in]: surf_index int Surface index on the target Geom :param [in]: dir_index int Direction to project along, X_DIR, Y_DIR or Z_DIR (see DIR_INDEX)