Python API Attributes

37 views
Skip to first unread message

Mike Kelly

unread,
Aug 14, 2026, 3:30:32 PM (3 days ago) Aug 14
to OpenVSP
I am trying to export my OpenVSP model to an external Python application. I have been successful with the exception of two attributes that are available in the GUI and apparently in the C++ API but not in the Python API:
First is the top-level component name called "Vehicle" by default but renamable in the GUI. I would like to import the name into my application. 
Second is the Vehicle Notes. In the Geom Browser this shows as AttrTree:Vehicle:Attributes:VSP::VehicleNotes, but I am unable to access the attributes tree via the Python API. I searched the docs but did not get an applicable result. Is this something I should file as a potential enhancement under the GitHub issues? Thx.

Rob McDonald

unread,
Aug 14, 2026, 3:47:26 PM (3 days ago) Aug 14
to OpenVSP
Both the AngelScript and Python API have a bunch of things for accessing Attributes


I know you're using Python, but the API Docs are better organized on the AngelScript side in my opinion.

Vehicle is just a ParmContainer, so things for working with it are often overlapped with the ParmContainer methods.  Since it is a special ParmContainer, there is a function to get its ID.


As noted a few days ago, the API is missing a routine to change the name of a pre-existing ParmContainer (Vehicle included).  That will be added in the next release.

I think you should be able to get to the Vehicle attributes using these methods.

Rob

Mike Kelly

unread,
Aug 14, 2026, 10:29:07 PM (3 days ago) Aug 14
to OpenVSP
Thanks for your reply, Rob. I was able to get the top-level container id through GetVehicleID() and then the name via GetContainerName(id). I was also able to get a list of the 171 parameters and their values for that container. The only parameter having to do with Vehicle Notes was ShowNotes(), which is just the boolean for whether to show the notes at startup. There doesn't seem to be a parameter that I can use to get the actual notes.
Mike

Rob McDonald

unread,
Aug 15, 2026, 12:06:26 AM (3 days ago) Aug 15
to OpenVSP
Check the example for:


//==== Attributes: FindAttributeNamesInCollection ====//
string VehID = GetVehicleID();
string CollID = GetChildCollection( VehID );
array < string > @AttrNames = FindAttributeNamesInCollection( CollID );
for ( int i = 0; i < int( AttrNames.size() ); ++i )
{
Print( AttrNames[i] );
}

Rob

Mike Kelly

unread,
Aug 15, 2026, 12:42:05 PM (3 days ago) Aug 15
to OpenVSP

Thanks Rob!
With my AI quintupling-down on "The Python API does not expose attribute value retrieval" your linked example allowed me to drag it kicking and screaming to the finish line. Here is my test code for the search engines:

import openvsp as vsp

# Get the Vehicle root container
root_id = vsp.GetVehicleID()

# Get the vehicle name from the root ID
vehicle_name = vsp.GetContainerName(root_id)

# Get its child attribute collection
col_id = vsp.GetChildCollection(root_id)

# Find attribute names
att_names = vsp.FindAttributeNamesInCollection(col_id)

# Get the attribute ID for Vehicle Notes
notes_attr_id = vsp.GetAttributeID(col_id, "VSP::VehicleNotes", 0)

# Retrieve the notes text
notes_tuple = vsp.GetAttributeStringVal(notes_attr_id)

# Extract the actual text
vehicle_notes = notes_tuple[0] if notes_tuple else ""

print("Vehicle Name:", vehicle_name)
print("Vehicle Notes:", vehicle_notes)

~Mike

Rob McDonald

unread,
Aug 15, 2026, 2:47:52 PM (2 days ago) Aug 15
to OpenVSP
Glad that you got it to work.

I won't say that we made it easy for you -- or for the AI.

But AI often does seem most confident when it is most wrong...

Rob
Reply all
Reply to author
Forward
0 new messages