mgriffith wrote

I'm not sure if this is possible, but I would like to have a .m file to handle setting up my geometry and boundary conditions and then switch to the GUI to handle meshing/solving and post. It seems like this should be possible, but I'm not sure how to do it. It seems like there should be some way to either pass the fea object to the GUI, or alternatively save an .fea file from a matlab script and then be able to load that into the GUI.

Dear Matt,

Yes, there are a few options to achieve this:

1) You can create your geometry in an .m script file or in the Matlab CLI, and then import it into the FEATool GUI using the

**"Import Geometry"** >

**"From MATLAB Workspace..."** option in the

**"Geometry"** menu

*(note that you can only import a geometry with the same space dimension as your model, that is you can't import a 3D geometry in to a 2D model etc.)*.

2) You can also save an inital ".fea" model (.fea model files are simply renamed .mat files), load it into your .m file script, change the geometry with something like

load( 'my_model_file.fea' ,'-mat' ); % load model data struct and assign to variable name "fea"
% (Re-)create geometry.
fea.geom = my_new_geometry;
save( 'my_new_model_file.fea', 'fea', '-v7' );

The new/modified model file can now be loaded into the FEATool GUI.

3) You can also save the model as a ".fes" script file and open, and edit it in a text editor. The .fes is just a JSON text file describing the GUI actions, so identifying and modifying the parameters should be quite simple.

If you also would like to automatcally/programatically import the geometry from the m-file script, that is also technically possible by "searching for and grabbing" the corresponding uicontrol GUI handles, and calling the callbacks, for example:

h_uimenu_imp_geom = findall( 0, 'Label', 'Import Geometry' );
h_uimenu_from_wsp = findall( h_uimenu_imp_geom, 'Label', 'From MATLAB Workspace...' );
c_cbf = get( h_uimenu_from_wsp, 'Callback' ); % Get callback function.
c_cbf{4}{1}( h_uimenu_from_wsp, [], c_cbf{4}{2:end} ) % Call callback function.