Geom Functions¶
This group of functions is available for adding, deleting, and modifying OpenVSP Geoms through the API.
|
Set the material a Geom is drawn with, by name. |
Get an array of all Geom types (i.e FUSELAGE, POD, etc.) |
|
|
Add a new Geom of given type as a child of the specified parent. |
|
Perform an update for the specified Geom. |
|
Delete a particular Geom. |
|
Delete multiple Geoms. |
|
Cut Geom from current location and store on clipboard. |
|
Copy Geom from current location and store on clipboard |
|
Paste Geom from clipboard into the model. |
|
Replace a Fuselage with a Stack of the same shape. |
Find and return all Geom IDs in the model |
|
|
Find and return all Geom IDs with the specified name |
|
Find and return the Geom ID with the specified name at given index. |
|
Set the name of the specified Geom. |
|
Get the name of a specific Geom |
|
Set which Geom a Clone Geom is a Clone of. |
|
Get the Geom a Clone Geom is a Clone of. |
|
Make a Clone Geom of each Geom in a group, keeping the hierarchy among them. |
|
Set the suffix automatic naming appends to the original's name. |
|
Get the suffix automatic naming appends to the original's name. |
|
Replace a Clone with a full copy of the Geom it shows. |
|
Find the Clones of a group of Geoms that are not in the group themselves -- the ones a delete or cut of the group would leave empty. |
|
Get all Parm IDs associated with this Geom Parm container |
|
Get the type name of specified Geom (i.e. FUSELAGE). |
|
Get the parent Geom ID for the input child Geom. |
|
Move a Geom within the list of its siblings, the way the move buttons beside the Geom browser do. |
|
Attach a texture image to a Geom, the way the Add button on the Texture screen does. |
|
Remove a texture from a Geom, the way the Delete button on the Texture screen does. |
|
Get the ParmContainer IDs of all the textures attached to a Geom, in the order they are drawn. |
|
Get the image file a texture was attached from. |
|
Get the parent Geom ID for the input child Geom. |
|
Get the ID of the Geom whose frame a Geom's symmetry is about, which its Sym_Ancestor Parm names by generation. |
|
Get the ID of the Geom whose Parasite Drag row a Geom is incorporated into, which its IncorporatedGen Parm names by generation. |
|
Set the Geom whose frame a Geom's symmetry is about, by ID, which sets its Sym_Ancestor Parm. |
|
Set the Geom whose Parasite Drag row a Geom is incorporated into, by ID, which sets its IncorporatedGen Parm. |
|
Get the IDs for each child of the input parent Geom. |
|
Get the number of main surfaces for the specified Geom. |
|
Get the total number of surfaces for the specified Geom. |
|
Get the VSP surface type of the specified Geom |
|
Get the VSP surface CFD type of the specified Geom |
|
Get the maximum coordinate of the bounding box of a Geom with given surface index. |
|
Get the minimum coordinate of the bounding box of a Geom with given surface index. |
|
Split a given wing section. |
|
Set the driver group for a wing section or a XSecCurve. |
|
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. |
|
Paste the airfoil clipboard onto a wing section |
|
Clear the skinning of one cross section, or of every cross section when the index is left at -1. |
|
Discard a Geom's pending scale and return it to its unscaled size. |
|
Turn a MeshGeom into a Point Cloud Geom made of its mesh nodes. |
|
Get the points of a Point Cloud Geom |
|
Turn a MeshGeom into an NGon Mesh Geom. |
|
Build the convex hull of a Point Cloud Geom. |
|
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.
Update() rebuilds the model from the top of the tree down and places each child Geom from its relative location, so a child stays attached when its parent moves. A child Geom in absolute mode ( Abs_Or_Relitive_flag set to ABS ) therefore loses an X_Location, Y_Location, Z_Location or X/Y/Z_Rotation set with SetParmVal when Update() runs. Call UpdateGeom on that Geom before Update(): it updates the Geom by itself and works out the relative location from the new absolute one. SetParmValUpdate does both in one call.
#==== 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(*args)[source]¶
Delete a particular Geom. clone_delete says what becomes of each Clone of it. By default each is left empty and VSP_CLONE_ORIGINAL_LOST is reported for it. FindGeomClones lists them beforehand.
#==== 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" #==== A Clone of a deleted Geom is left empty and reported ====# clone_id = CloneGeomVec( [ pod_id ] )[0] err_mgr = ErrorMgrSingleton.getInstance() while err_mgr.GetNumTotalErrors() > 0 : err = err_mgr.PopLastError() DeleteGeom( pod_id ) assert GetGeomCloneOriginal( clone_id ) == "", "DeleteGeom left the Clone an original" codes = [] while err_mgr.GetNumTotalErrors() > 0 : codes.append( err_mgr.PopLastError().GetErrorCode() ) assert VSP_CLONE_ORIGINAL_LOST in codes, "DeleteGeom did not report the emptied Clone"
See also: FindGeomClones, CLONE_DELETE_TYPE :param [in]: geom_id string Geom ID :param [in]: clone_delete int What becomes of each Clone of the Geom (CLONE_DELETE_TYPE)
- openvsp.DeleteGeomVec(*args)[source]¶
Delete multiple Geoms. clone_delete applies to each Clone of them that is not itself being deleted, as for DeleteGeom.
#==== 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" #==== Delete a Geom and its Clones together ====# clone_id = CloneGeomVec( [ pid ] )[0] DeleteGeomVec( [ pid ], CLONE_DELETE_WITH_ORIGINAL ) assert clone_id not in FindGeoms(), "DeleteGeomVec left the Clone behind"
See also: FindGeomClones, CLONE_DELETE_TYPE :param [in]: del_vec vector<string> Vector of Geom IDs :param [in]: clone_delete int What becomes of each Clone of those Geoms (CLONE_DELETE_TYPE)
- openvsp.CutGeomToClipboard(*args)[source]¶
Cut Geom from current location and store on clipboard. A pasted Geom is a new Geom, so clone_delete applies to each Clone of the cut Geom, as for DeleteGeom. A Clone cut along with it is pasted as a Clone of the pasted Geom.
#==== 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" #==== Cutting a Geom replaces its Clone with a real Geom ====# pid3 = AddGeom( "POD", "" ) clone_id = CloneGeomVec( [ pid3 ] )[0] CutGeomToClipboard( pid3, CLONE_DELETE_REPLACE ) assert GetGeomTypeName( clone_id ) == "Pod", "CutGeomToClipboard did not replace the Clone"
See also: PasteGeomClipboard, FindGeomClones, CLONE_DELETE_TYPE :param [in]: geom_id string Geom ID :param [in]: clone_delete int What becomes of each Clone of the Geom (CLONE_DELETE_TYPE)
- 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.ConvertFuselageToStack(geom_id)[source]¶
Replace a Fuselage with a Stack of the same shape. Each cross section is placed where the Fuselage put it, and its skinning is carried across, so the surface is unchanged. The Stack goes in the Fuselage’s place in the model, under its name, with its children, subsurfaces, structures, mesh sources, textures and attributes.
The Stack takes over the Fuselage’s identity: its Geom ID, the IDs of the Parms the two have in common, and the IDs of each cross section and its Parms. A link, a design variable or an advanced link on one of those Parms goes on naming the same thing, and the ID this returns is the ID that was passed in. Some Parms are paired with a counterpart that means something different: a cross section’s rotation, which in a Stack is relative to the section before it, and its location fractions, which become the Stack’s X, Y and Z deltas – lengths, and relative ones. Only the Fuselage’s length has no counterpart at all; attributes on it, or on a cross section’s copy of it, move to the Stack itself. Attributes elsewhere – on the Geom, a cross section, a subsurface, a Parm – stay with the ID they were on.
CompareGeomSurfaces measures how closely the Stack’s surfaces match a copy of the Fuselage kept for the purpose.
#==== A Fuselage rotated about a point along its length, with a Pod hung off it ====# fid = AddGeom( "FUSELAGE" ) SetParmVal( FindParm( fid, "Origin", "XForm" ), 0.4 ) SetParmVal( FindParm( fid, "Y_Rel_Rotation", "XForm" ), 8.0 ) pid = AddGeom( "POD", fid ) SetParmVal( FindParm( pid, "X_Rel_Location", "XForm" ), 6.0 ) Update() before = CompPnt01( fid, 0, 0.3, 0.2 ) pod_before = CompPnt01( pid, 0, 0.5, 0.5 ) #==== Convert it ====# sid = ConvertFuselageToStack( fid ) assert not ErrorMgrSingleton.getInstance().GetErrorLastCallFlag(), "---> Error: API ConvertFuselageToStack reported an error" Update() assert sid == fid, "---> Error: API ConvertFuselageToStack did not keep the ID" assert GetGeomTypeName( sid ) == "Stack", "---> Error: API ConvertFuselageToStack did not make a Stack" #==== The surface is where it was, and so is the Pod ====# assert dist( before, CompPnt01( sid, 0, 0.3, 0.2 ) ) < 1e-9, "---> Error: API ConvertFuselageToStack moved the surface" assert dist( pod_before, CompPnt01( pid, 0, 0.5, 0.5 ) ) < 1e-9, "---> Error: API ConvertFuselageToStack moved a child"
- Parameters:
[in] – geom_id string Fuselage Geom ID
- Return type:
string
- Returns:
string ID of the Stack, which is the Fuselage’s own ID
- 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. A Geom that names itself, such as a Clone with its AutoName Parm (group Behavior) on, refuses the name with an error; turn AutoName off first.
#==== 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" #==== A Clone names itself until AutoName is turned off ====# clone_id = CloneGeomVec( [ pid ] )[0] SetGeomName( clone_id, "MyClone" ) assert GetGeomName( clone_id ) != "MyClone", "SetGeomName renamed a Clone that names itself" err_mgr = ErrorMgrSingleton.getInstance() while err_mgr.GetNumTotalErrors() > 0 : err = err_mgr.PopLastError() SetParmVal( clone_id, "AutoName", "Behavior", 0.0 ) SetGeomName( clone_id, "MyClone" ) Update() assert GetGeomName( clone_id ) == "MyClone", "SetGeomName did not rename the Clone"
- 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.SetGeomCloneOriginal(clone_id, original_id)[source]¶
Set which Geom a Clone Geom is a Clone of. A Clone shows the original’s surfaces while keeping its own place in the model. What else it takes from the original – symmetry, Set membership, placement, attachment, colour, subsurfaces and the rest – is controlled by the Parms in its Behavior group. Passing an empty original_id leaves the Clone showing nothing and turns its AutoName off, so its name is the user’s.
A Clone’s Flip_Flag (group Sym) is its own. With CloneSym on, the Clone also shows its original’s flip: the planes are combined, and a plane set on both cancels.
pod = AddGeom( "POD", "" ) clone = AddGeom( "CLONE", "" ) SetGeomCloneOriginal( clone, pod ) assert GetGeomCloneOriginal( clone ) == pod, "SetGeomCloneOriginal did not take" # A Clone cannot be its own original; refused, original unchanged. SetGeomCloneOriginal( clone, clone ) assert GetGeomCloneOriginal( clone ) == pod, "SetGeomCloneOriginal accepted the Clone as its own original" # Clear that error before the next check. err_mgr = ErrorMgrSingleton.getInstance() while err_mgr.GetNumTotalErrors() > 0 : err = err_mgr.PopLastError() # Asking a Geom that is not a Clone is an error. GetGeomCloneOriginal( pod ) assert err_mgr.GetNumTotalErrors() > 0, "GetGeomCloneOriginal accepted a Geom that is not a Clone" # That error was raised deliberately, so take it back off the queue. while err_mgr.GetNumTotalErrors() > 0 : err = err_mgr.PopLastError() #==== The original's flip and the Clone's own combine ====# SetParmVal( pod, "Y_Rel_Location", "XForm", 3.0 ) SetParmVal( clone, "Y_Rel_Location", "XForm", 3.0 ) Update() plain = CompPnt01( clone, 0, 0.5, 0.25 ) SetParmVal( pod, "Flip_Flag", "Sym", SYM_XZ ) Update() one_plane = CompPnt01( clone, 0, 0.5, 0.25 ) assert abs( ( one_plane.y() - 3.0 ) + ( plain.y() - 3.0 ) ) < 1e-9, "the Clone did not show its original's flip" SetParmVal( clone, "Flip_Flag", "Sym", SYM_XZ ) Update() assert dist( plain, CompPnt01( clone, 0, 0.5, 0.25 ) ) < 1e-9, "the same plane on both did not cancel" #==== Clearing the original hands the name back ====# SetGeomCloneOriginal( clone, "" ) assert GetParmVal( FindParm( clone, "AutoName", "Behavior" ) ) == 0.0, "clearing the original left AutoName on"
See also: GetGeomCloneOriginal, SYM_FLAG :param [in]: clone_id string Clone Geom ID :param [in]: original_id string ID of the Geom to be cloned
- openvsp.GetGeomCloneOriginal(clone_id)[source]¶
Get the Geom a Clone Geom is a Clone of. An empty string means the Clone has not been given one, or has been cleared.
#==== Add Pod Geom and a Clone of it, made under the Pod ====# pod = AddGeom( "POD" ) clone = AddGeom( "CLONE", pod ) #==== A Clone with no original set takes its parent ====# Update() assert GetGeomCloneOriginal( clone ) == pod, "a Clone made under a Geom did not take it as its original" #==== Once cleared, it does not take the parent again ====# SetGeomCloneOriginal( clone, "" ) Update() assert GetGeomCloneOriginal( clone ) == "", "GetGeomCloneOriginal answered for a Clone that has none" #==== Reports the original that was set ====# SetGeomCloneOriginal( clone, pod ) Update() assert GetGeomCloneOriginal( clone ) == pod, "GetGeomCloneOriginal did not report the Geom that was set" #==== A Geom that is not a Clone is rejected; clear the queue first ====# err_mgr = ErrorMgrSingleton.getInstance() while err_mgr.GetNumTotalErrors() > 0 : drained = err_mgr.PopLastError() GetGeomCloneOriginal( pod ) assert err_mgr.GetNumTotalErrors() > 0, "GetGeomCloneOriginal answered for a Geom that is not a Clone" # That error was raised deliberately, so take it back off the queue. while err_mgr.GetNumTotalErrors() > 0 : err = err_mgr.PopLastError()
See also: SetGeomCloneOriginal :param [in]: clone_id string Clone Geom ID :rtype: string :return: string ID of the Geom being cloned, or an empty string if there is none
- openvsp.CloneGeomVec(*args)[source]¶
Make a Clone Geom of each Geom in a group, keeping the hierarchy among them. The top Clone of each hierarchy is a sibling of its original, starts at the original’s placement, and has CloneXForm off so it can be moved. The Clones below it have CloneXForm on, so they keep their originals’ relative placement. The Clones are returned in model hierarchy order, not the order passed in; use GetGeomCloneOriginal to match them up.
pod = AddGeom( "POD" ) wing = AddGeom( "WING", pod ) Update() #==== Clone both at once ====# clones = CloneGeomVec( [pod, wing] ) assert len( clones ) == 2, "CloneGeomVec did not make a Clone of each Geom" #==== Match each Clone to its original ====# by_original = { GetGeomCloneOriginal( c ) : c for c in clones } assert pod in by_original and wing in by_original, "CloneGeomVec did not make a Clone of each Geom" #==== The hierarchy is kept ====# assert GetGeomParent( by_original[wing] ) == by_original[pod], "CloneGeomVec did not keep the hierarchy" #==== The pod's Clone sits beside the pod, not under it ====# assert GetGeomParent( by_original[pod] ) == GetGeomParent( pod ), "CloneGeomVec did not put the top of the group beside the original" #==== Only the top Clone places itself ====# assert GetParmVal( FindParm( by_original[pod], "CloneXForm", "Behavior" ) ) == 0.0, "CloneGeomVec did not leave the top of the group free to be placed" assert GetParmVal( FindParm( by_original[wing], "CloneXForm", "Behavior" ) ) == 1.0, "CloneGeomVec did not have the rest of the group copy its placement"
See also: SetGeomCloneOriginal, SetGeomCloneNameSuffix :param [in]: geom_id_vec vector<string> Vector of Geom IDs to clone :param [in]: name_suffix string Suffix automatic naming appends to each original’s name :rtype: std::vector< std::string,std::allocator< std::string > > :return: vector<string> Vector of the new Clone Geom IDs
- openvsp.SetGeomCloneNameSuffix(clone_id, name_suffix)[source]¶
Set the suffix automatic naming appends to the original’s name. With AutoName on, the Clone is renamed on the next update. The suffix is saved with the model.
#==== Add Pod Geom and a Clone of it ====# pod = AddGeom( "POD" ) clone = AddGeom( "CLONE" ) SetGeomCloneOriginal( clone, pod ) Update() SetGeomCloneNameSuffix( clone, "_Left" ) Update() assert GetGeomName( clone ) == GetGeomName( pod ) + "_Left", "SetGeomCloneNameSuffix did not rename the Clone" assert GetGeomCloneNameSuffix( clone ) == "_Left", "GetGeomCloneNameSuffix did not report the suffix that was set"
See also: GetGeomCloneNameSuffix, CloneGeomVec :param [in]: clone_id string Clone Geom ID :param [in]: name_suffix string Suffix to append to the original’s name
- openvsp.GetGeomCloneNameSuffix(clone_id)[source]¶
Get the suffix automatic naming appends to the original’s name. A new Clone starts with “_Clone”.
#==== Add Pod Geom and a Clone of it ====# pod = AddGeom( "POD" ) clone = AddGeom( "CLONE" ) SetGeomCloneOriginal( clone, pod ) Update() #==== A new Clone starts with the default suffix ====# assert GetGeomCloneNameSuffix( clone ) == "_Clone", "GetGeomCloneNameSuffix did not report the default suffix"
See also: SetGeomCloneNameSuffix, CloneGeomVec :param [in]: clone_id string Clone Geom ID :rtype: string :return: string Suffix appended to the original’s name
- openvsp.ReplaceCloneGeom(clone_id)[source]¶
Replace a Clone with a full copy of the Geom it shows. The copy takes the Clone’s place, name and children, the Clone’s own Parm values (any whose Copy From Original switch is off) are written onto it, and the Clone is deleted.
The replacement takes the Clone’s Geom ID, the IDs of the Parms they share, and its subsurfaces with their IDs, so attached Geoms, design variables, links and VSPAERO control surface groups keep working. The returned ID is the one passed in.
The replacement’s Flip_Flag holds every plane the Clone showed its shape reflected about.
A Clone of a polygon mesh is not replaced, because a polygon mesh cannot be copied.
#==== A Pod and a Clone of it, placed separately ====# pod = AddGeom( "POD" ) clone = AddGeom( "CLONE" ) SetGeomCloneOriginal( clone, pod ) SetParmVal( FindParm( clone, "Y_Rel_Location", "XForm" ), 4.0 ) #==== Flipped: the original about XZ, the Clone's own about XY ====# SetParmVal( FindParm( pod, "Flip_Flag", "Sym" ), SYM_XZ ) SetParmVal( FindParm( clone, "Flip_Flag", "Sym" ), SYM_XY ) Update() name = GetGeomName( clone ) shown = CompPnt01( clone, 0, 0.3, 0.2 ) #==== Replace the Clone ====# real = ReplaceCloneGeom( clone ) Update() #==== A Pod, under the Clone's name ====# assert GetGeomTypeName( real ) == "Pod", "the replacement is not the original's type" assert GetGeomName( real ) == name, "the replacement did not take the Clone's name" #==== With the Clone's own placement ====# assert abs( GetParmVal( FindParm( real, "Y_Rel_Location", "XForm" ) ) - 4.0 ) < 1e-6, \ "the replacement did not take the position the Clone held of its own" #==== With the same flip planes, so the surface is unchanged ====# assert int( GetParmVal( FindParm( real, "Flip_Flag", "Sym" ) ) + 0.5 ) == ( SYM_XZ | SYM_XY ), \ "the replacement did not take the planes the Clone showed" assert dist( shown, CompPnt01( real, 0, 0.3, 0.2 ) ) < 1e-9, "the replacement does not stand where the Clone stood" #==== The replacement answers to the Clone's own ID ====# assert real == clone, "the replacement did not take the Clone's ID" #==== It is no longer a Clone; clear the queue first ====# err_mgr = ErrorMgrSingleton.getInstance() while err_mgr.GetNumTotalErrors() > 0 : drained = err_mgr.PopLastError() GetGeomCloneOriginal( clone ) assert err_mgr.GetNumTotalErrors() > 0, "what took the Clone's ID is still a Clone" # That error was raised deliberately, so take it back off the queue. while err_mgr.GetNumTotalErrors() > 0 : err = err_mgr.PopLastError()
See also: SetGeomCloneOriginal, CloneGeomVec :param [in]: clone_id string Clone Geom ID :rtype: string :return: string ID of the Geom that replaced it – the Clone’s own ID – or an empty string on failure
- openvsp.FindGeomClones(geom_id_vec)[source]¶
Find the Clones of a group of Geoms that are not in the group themselves – the ones a delete or cut of the group would leave empty. Clones of these Clones are not returned, though CLONE_DELETE_WITH_ORIGINAL deletes them too.
pod = AddGeom( "POD" ) Update() clones = CloneGeomVec( [pod] ) #==== The pod's Clone is found ====# found = FindGeomClones( [pod] ) assert list( found ) == [clones[0]], "FindGeomClones did not find the Clone of the pod" #==== A Clone in the group is not returned ====# assert len( FindGeomClones( [pod, clones[0]] ) ) == 0, "FindGeomClones found a Clone that is going too" #==== Delete the pod, replacing its Clone ====# DeleteGeom( pod, CLONE_DELETE_REPLACE ) assert GetGeomTypeName( clones[0] ) == "Pod", "DeleteGeom did not replace the Clone"
See also: DeleteGeom, DeleteGeomVec, CutGeomToClipboard, CLONE_DELETE_TYPE :param [in]: geom_id_vec vector<string> Vector of Geom IDs :rtype: std::vector< std::string,std::allocator< std::string > > :return: vector<string> IDs of the Clones of those Geoms that are not among them
- 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.GetGeomSymAncestorID(geom_id)[source]¶
Get the ID of the Geom whose frame a Geom’s symmetry is about, which its Sym_Ancestor Parm names by generation. An empty string means the global origin.
parent_id = AddGeom( "POD" ) child_id = AddGeom( "POD", parent_id ) SetParmVal( child_id, "Sym_Ancestor", "Sym", 2 ) assert GetGeomSymAncestorID( child_id ) == parent_id, "GetGeomSymAncestorID did not return the parent"
See also: GetGeomParent :param [in]: geom_id string Geom ID :rtype: string :return: string Geom ID, or an empty string for the global origin
- openvsp.GetGeomIncorporatedAncestorID(geom_id)[source]¶
Get the ID of the Geom whose Parasite Drag row a Geom is incorporated into, which its IncorporatedGen Parm names by generation.
parent_id = AddGeom( "POD" ) child_id = AddGeom( "POD", parent_id ) SetParmVal( child_id, "IncorporatedGen", "ParasiteDragProps", 1 ) assert GetGeomIncorporatedAncestorID( child_id ) == parent_id, "GetGeomIncorporatedAncestorID did not return the parent"
See also: GetGeomParent :param [in]: geom_id string Geom ID :rtype: string :return: string Geom ID
- openvsp.SetGeomSymAncestorID(geom_id, ancestor_id)[source]¶
Set the Geom whose frame a Geom’s symmetry is about, by ID, which sets its Sym_Ancestor Parm. The Geom must be the Geom itself or one of its ancestors; an empty string means the global origin.
parent_id = AddGeom( "POD" ) child_id = AddGeom( "POD", parent_id ) SetGeomSymAncestorID( child_id, parent_id ) assert GetGeomSymAncestorID( child_id ) == parent_id, "SetGeomSymAncestorID did not set the parent"
See also: GetGeomSymAncestorID :param [in]: geom_id string Geom ID :param [in]: ancestor_id string ID of the Geom or one of its ancestors, or an empty string
- openvsp.SetGeomIncorporatedAncestorID(geom_id, ancestor_id)[source]¶
Set the Geom whose Parasite Drag row a Geom is incorporated into, by ID, which sets its IncorporatedGen Parm. The Geom must be the Geom itself or one of its ancestors.
parent_id = AddGeom( "POD" ) child_id = AddGeom( "POD", parent_id ) SetGeomIncorporatedAncestorID( child_id, parent_id ) assert GetGeomIncorporatedAncestorID( child_id ) == parent_id, "SetGeomIncorporatedAncestorID did not set the parent"
See also: GetGeomIncorporatedAncestorID :param [in]: geom_id string Geom ID :param [in]: ancestor_id string ID of the Geom or one of its ancestors
- 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), or -1 if the Geom or index is invalid
- 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), or -1 if the Geom or index is invalid
- openvsp.GetGeomBBoxMax(geom_id, main_surf_ind=0, ref_frame_is_absolute=True)[source]¶
Get the maximum coordinate of the bounding box of a Geom with given 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 Index of the surface of that Geom, counting symmetric copies, from 0 to GetTotalNumSurfs() - 1 (the name is kept for scripts that pass it by keyword) :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 minimum coordinate of the bounding box of a Geom with given 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 Index of the surface of that Geom, counting symmetric copies, from 0 to GetTotalNumSurfs() - 1 (the name is kept for scripts that pass it by keyword) :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, SplitWingXSecByID :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, GetDriverGroupByID :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, PasteAirfoilByID :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. A Geom whose cross sections are not skinned, or an index past the last cross section, is an error.
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, ClearSkinningByID :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)