Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Using Java to execute 'macros' in a model

Please login with a confirmed email address before reporting spam

Hello,
I have been using the Java API extensively so far to construct models from scratcn and automate complex tasks. I have set up the code development/compilation environment quite some time ago, so I am not anymore familiar with the technicalities. The code I used always created a new model from scratch, and did some complex analysis.
I am wondering if it is possible to use Java code as a 'macro', i.e. execute a certain sequence of operations in an *existing* model, and if yes, how to do it.
For example if I run the code below when working on an existing model, I get the pop-up message 'Model1' or something similar, and then an empty model, i.e. the code has cleared what I had before.
What I would like is for example get the actual model and make some modifications to it (for example add some geometry which is easier to code in Java than in the GUI).
Thank you
Daniel

import com.comsol.model.*;
import com.comsol.model.util.*;
import javax.swing.JOptionPane;
import java.awt.Font;
import javax.swing.*;

/** Model exported on Aug 11 2015, 10:49 by COMSOL 5.0.0.244. */
public class test
{
public static void main(String[] args)
{
String[] tags = ModelUtil.tags();
for(int i=0; i<tags.length; ++i)
JOptionPane.showMessageDialog(null,tags[i]);
}
}

0 Replies Last Post 11.08.2015, 05:02 GMT-4
COMSOL Moderator

Hello

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.

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.