Create *vspscript file

575 views
Skip to first unread message

Johannes

unread,
Dec 16, 2020, 1:15:56 PM12/16/20
to OpenVSP
Hello,

in the 'scripts' folder of OpenVSP are some *vspscript files. I want to change some parameters in the script code and save it as a *vspscript file. My Problem is that i can open the files only with an editor program to see and change the program code. When i want to save the changed document it isn`t saved as a *vspscript file.

Is there a different program by which i can create *vspscript files? 

At first i wanted to create the files with the 'vspscript' application from the OpenVSP folder, but if i open the application a black window appears on my screen and disappears immediately.

I hope you can help me.

Brandon Litherland

unread,
Dec 16, 2020, 1:43:07 PM12/16/20
to OpenVSP
You can run *.vspscript files using the command line or by choosing File > Run Script... from the main window.
I generally use Notepad++ for scripts but you can use any editor.  The trick is that you sometimes have to use Save As... then pick All File Types (*.*) and manually type the extension into the filename.  So "MyScript.vspscript" instead of "MyScript".
Let us know if this sorts out the issues.

The vspscript.exe isn't a script writer.  That is a non-GUI version of VSP intended for running scripts from the command line.  You can also run scripts using the command line by "vsp -script myscript.vspscript" or have it execute on a particular model by "vsp -script myscript.vspscript mymodel.vsp3"

Johannes

unread,
Dec 16, 2020, 4:03:55 PM12/16/20
to OpenVSP
Perfect, that solves my Problem. Thanks 

damien archambaud

unread,
May 16, 2022, 6:33:43 AM5/16/22
to OpenVSP
Hello,

I tried to run my script from File>Run Script from the main window and it worked.
However, when I try to run it with the command line it doesn't work.
This is what I get when I try.
ERROR.PNG

Is there something wrong with the script or with my way to use the command line?


Kind regards

Rob McDonald

unread,
May 16, 2022, 12:02:23 PM5/16/22
to OpenVSP
When you run vsp or vspscript with a single parameter, OpenVSP assumes it is a *.vsp3 file (which is in XML format).

To run a script, you need to run...

vsp -script Wing.vspscript

or

vspscript -script Wing.vspscript

To get a list of all the command line options (there aren't very many), you can run

vsp -help

Rob

Brandon Litherland

unread,
May 16, 2022, 1:49:40 PM5/16/22
to OpenVSP
From above...
 You can also run scripts using the command line by "vsp -script myscript.vspscript" or have it execute on a particular model by "vsp -script myscript.vspscript mymodel.vsp3"

damien archambaud

unread,
May 17, 2022, 8:04:59 AM5/17/22
to OpenVSP
Yes I actually tried it but when I run with the command "vsp -script Wing.vspscript" or "vspscript -script Wing.vspscript", there is no error displayed but the model doesn't appear in openvsp. It is the same when I try with the command   "vsp -script myscript.vspscript mymodel.vsp3".

TEST.PNG

Did I do something wrong?

Damien

Brandon Litherland

unread,
May 17, 2022, 10:33:55 AM5/17/22
to OpenVSP
Ah.  If you open the Wing.vspscript file and look at the code, at no point does the script actually save the model.  This script is intended as a test from the OpenVSP window/GUI.  It is building the wing just fine and then exiting exactly as the script tells it to. 

To write the model to file, you'll want something like the TestSaveLoad.vspscript file distributed with VSP in the scripts directory.

void main()
{
    Print( string( "Begin Save and Load Test" ) );
    Print( string( "" ) );
    TestSaveLoad();
    Print( string( "End Save and Load Test" ) );
}

void TestSaveLoad()
{
    Print( string( "--> Generating Geometries and Testing Save and Load Code" ) );
    Print( string( "" ) );

    //==== Add Wing Geom and set some parameters =====//
    string wing_id = AddGeom( "WING" );
    SetParmVal(  wing_id, "TotalSpan", "WingGeom", 30.0 );
    SetParmVal(  wing_id, "LECluster", "WingGeom", 0.0 );
    SetParmVal(  wing_id, "TECluster", "WingGeom", 2.0 );
    Update();

    //==== Add Fuselage Geom and set some parameters =====//
    string fus_id = AddGeom( "FUSELAGE" );
    SetParmVal(  fus_id, "X_Rel_Location", "XForm", -9.0 );
    SetParmVal(  fus_id, "Z_Rel_Location", "XForm", -1.0 );
    Update();

    //==== Save Vehicle to File ====//
    Print( string( "--->Saving VSP model\n" ) );
    string fname = "TestSaveLoad.vsp3";
    WriteVSPFile( fname, SET_ALL );


    //==== Reset Geometry ====//
    Print( string( "--->Resetting VSP model to blank slate\n" ) );
    ClearVSPModel();

    //==== Read Geometry From File ====//
    Print( string( "--->Reading model from: " ) + fname + string( "\n" ) );
    ReadVSPFile( fname );

}


damien archambaud

unread,
May 18, 2022, 4:08:16 AM5/18/22
to OpenVSP
Thank you very much, it works exactly as I want!

Damien
Reply all
Reply to author
Forward
0 new messages