Have you tried calling 'ImportFile' from the API to import you STL file?
/*!
Import a file into OpenVSP. Many formats are available, such as NASCART, V2, and BEM). The imported Geom, mesh, or other object is inserted
as a child of the specified parent. If no parent or an invalid parent is given, the import will be done at the top level.
\sa IMPORT_TYPE
\param [in] file_name Import file name
\param [in] file_type File type enum (i.e. IMPORT_PTS)
\param [in] parent Parent Geom ID (ignored with empty string)
*/
extern std::string ImportFile( const std::string & file_name, int file_type, const std::string & parent );
The file_type value you want is vsp::IMPORT_STL
That should read in a STL file just like you do from the GUI. Then, you should be able to use any of the analysis tools just like from the GUI.
Instead of using the direct ComputePlaneSlice API call, I suggest you become familiar with using the Analysis Manager. In this case, you'll want to use the 'PlanarSlice' analysis.
Before the introduction of the Analysis Manager, every analysis tool had its own API call (like ComputePlaneSlice). As more analysis tools were added (with more options and more complex options), this became chaotic. To help this situation, the Analysis Manager was added to provide a consistent interface for analyses and their results (via the Results Manager).
Rob