Problem with saving table in a method

Please login with a confirmed email address before reporting spam

Hi everyone, I'm currently working on creating small scripts using methods in the Application Builder to simplify the export of data in the Model Builder. I call the equivalent method in the Model Builder to get it running.

Right now, I'm trying to save a table using the following script and ran into two issues:

model.result().evaluationGroup().create("eg10", "EvaluationGroup"); model.result().evaluationGroup("eg10").set("data", "dset1"); model.result().evaluationGroup("eg10").label("Iron Losses"); model.result().evaluationGroup("eg10").create("int1", "IntSurface"); model.result().evaluationGroup("eg10").feature("int1").label("Surface Iron Losses"); model.result().evaluationGroup("eg10").feature("int1").set("intvolume", true); model.result().evaluationGroup("eg10").feature("int1").selection().named("sel15"); model.result().evaluationGroup("eg10").feature("int1").set("expr", new String[]{"rmm.Qh"}); model.result().evaluationGroup("eg10").feature("int1").set("descr", new String[]{"Volumetric loss density, electromagnetic"}); model.result().evaluationGroup("eg10").feature("int1").set("unit", new String[]{"W/m"}); model.result().evaluationGroup("eg10").feature("int1").setIndex("expr", "rmm.Qh*L", 0); model.result().evaluationGroup("eg10").feature("int1").setIndex("descr", "P_iron_MOD", 0); model.result().evaluationGroup("eg10").run();
//model.result().evaluationGroup("eg10").save("Z:\Simulationsergebnisse\Iron_losses.txt");
//model.result().evaluationGroup("eg10").save("C:\Users\kzt\Documents\Iron_losses.txt");
//model.result().evaluationGroup("eg10").save("C:\Temp\Iron_losses.txt");

1.) Everything works fine up to the last commented-out line. Unfortunately, I can’t save to any of the specified directories and I always get the following error:

"Cannot open file for writing. - Filename: Z:\Simulationsergebnisse\Iron_losses.txt (with all the other paths as well) - Table: Iron Losses"

However, I can manually save to the paths via mouse click.

2.) Is there an alternative to the following line?

"model.result().evaluationGroup("eg10").feature("int1").selection().named("sel15");"

I’d like to use the name of the selection instead of the index number 15. When I add or remove selections, the index changes, so "15" may no longer refer to the correct selection.

Best regards and many thanks in advance for your help!

Tobias Zeller


Reply

Please read the discussion forum rules before posting.

Please log in to post a reply.

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.