Cancel
Showing results for 
Search instead for 
Did you mean: 

How to run a macro command multiple times

Valued Contributor
Valued Contributor

Hello.

In femap created Program File "Macro A" how to automatically run it N times?
1  Start "Macro A" - Analysis - Load Results - Output Set 1.
2  Start "Macro A" - Analysis - Load Results - Output Set 2.
...
N  Start "Macro A" - Analysis - Load Results - Output Set N. 

5 REPLIES

Re: How to run a macro command multiple times

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor

For the simple Program File macro, you would use the #DELAY(time) command to make the macro wait for a time which exceeds the maximum likely runtime of the analysis.

Then you would have a #GOTO command which sends the macros back to its own beginning to start again (and have another #DELAY() command to speed up the execution again).

A bit of a rough method, but it works.

Re: How to run a macro command multiple times

Valued Contributor
Valued Contributor

EnDuraSim thank you for reply. I could not do in the macro cycle, show how to extend this macro to use them repeatedly?

$ ========================================
$ Activates this Group
{~2805}
$ ========================================
$ Delete Mesh
{~1637}
$ ----- Entity Selection - Select Element(s) to Delete Mesh
<@19503>5..Rigit-temp<OK>
#OPT(Y)
$ ========================================
$ Element Rotate By
{~1434}
$ ----- Entity Selection - Select Element(s) to Rotate To Coordinates
<@19503>2..Povorot<OK>
$ ----- Vector Global Axis - Select Axis of Rotation
<A-M>G<@10011>0<@10012>0<@10013>0<A-Z><OK>
$ ----- Rotation and Translation
<@10501>0.5<OK>
$ ========================================
$ Surface Rotate By
{~1431}
$ ----- Entity Selection - Select Surface(s) to Rotate To Coordinates
<@19503>2..Povorot<OK>
$ ----- Vector Global Axis - Select Axis of Rotation
<A-M>G<@10011>0<@10012>0<@10013>0<A-Z><OK>
$ ----- Rotation and Translation
<@10501>0.5<OK>
$ ========================================
$ Automatic Associativity
{~1647}
$ ----- Entity Selection - Select Elements to Automatically Associate to Solids
<@19503>3..Vnutr-nakat<A-M><@19503>4..Vnes-nakat<OK>
$ ----- Entity Selection - Select Solids to Automatically Associate
<@19503>2..Povorot<OK>
$ ----- Automatic Geometry Associativity
<@10501>15<OK>
$ ========================================
$ Create Element
{~1221}
$ ----- Define RIGID Element - Enter Nodes or Select with Cursor
$ ----- RBE3 ( Interpolation )
<@15201><T2~11101>1<@15201><T2~13001><PUSH><@15201><T2~13002><PUSH><@15201><T2~13011><PUSH>
<@15201><T2~13012><PUSH><@15201><T2~13013><PUSH><@15201><T2~13016><PUSH><@15201><T2~13015><PUSH>
<@15201><T2~13014><PUSH><@15201><T2~12001><PUSH>
$ ----- Entity Selection - Select Master Node(s)
<@12501><PUSH>f
$ ----- Entity Selection - Select Master Node(s)  ( On Surfaces )
$ ----- Entity Selection - Select Master Node(s)  ( On Surfaces )
<@11701>1
<A-M><OK>
<OK>
$ ----- Define RIGID Element - Enter Nodes or Select with Cursor
<Esc>
$ ========================================
$ Create Element
{~1221}
$ ----- Define RIGID Element - Enter Nodes or Select with Cursor
$ ----- RBE3 ( Interpolation )
<@15201><T2~11101>2<@15201><T2~13011><PUSH><@15201><T2~13012><PUSH><@15201><T2~13013><PUSH>
<@15201><T2~13016><PUSH><@15201><T2~13015><PUSH><@15201><T2~13014><PUSH><@15201><T2~12001><PUSH>
$ ----- Entity Selection - Select Master Node(s)
<@12501><PUSH>f
$ ----- Entity Selection - Select Master Node(s)  ( On Surfaces )
$ ----- Entity Selection - Select Master Node(s)  ( On Surfaces )
<@11701>2
<A-M><OK>
<OK>
$ ----- Define RIGID Element - Enter Nodes or Select with Cursor
<Esc>
$ ========================================
$ Create Element
{~1221}
$ ----- Define RIGID Element - Enter Nodes or Select with Cursor
$ ----- RBE3 ( Interpolation )
<@15201><T2~11101>3<@15201><T2~13011><PUSH><@15201><T2~13012><PUSH><@15201><T2~13013><PUSH>
<@15201><T2~13016><PUSH><@15201><T2~13015><PUSH><@15201><T2~13014><PUSH><@15201><T2~12001><PUSH>
$ ----- Entity Selection - Select Master Node(s)
<@12501><PUSH>f
$ ----- Entity Selection - Select Master Node(s)  ( On Surfaces )
$ ----- Entity Selection - Select Master Node(s)  ( On Surfaces )
<@11701>3
<A-M><OK>
<OK>
$ ----- Define RIGID Element - Enter Nodes or Select with Cursor
<Esc>
$ ========================================
$ Create Element
{~1221}
$ ----- Define RIGID Element - Enter Nodes or Select with Cursor
$ ----- RBE3 ( Interpolation )
<@15201><T2~11101>4<@15201><T2~13011><PUSH><@15201><T2~13012><PUSH><@15201><T2~13013><PUSH>
<@15201><T2~13016><PUSH><@15201><T2~13015><PUSH><@15201><T2~13014><PUSH><@15201><T2~12001><PUSH>
$ ----- Entity Selection - Select Master Node(s)
<@12501><PUSH>f
$ ----- Entity Selection - Select Master Node(s)  ( On Surfaces )
$ ----- Entity Selection - Select Master Node(s)  ( On Surfaces )
<@11701>4
<A-M><OK>
<OK>
$ ----- Define RIGID Element - Enter Nodes or Select with Cursor
<Esc>
$ ========================================
$ Create Element
{~1221}
$ ----- Define RIGID Element - Enter Nodes or Select with Cursor
$ ----- RBE3 ( Interpolation )
<@15201><T2~11101>5<@15201><T2~13001><PUSH><@15201><T2~13002><PUSH><@15201><T2~13011><PUSH>
<@15201><T2~13012><PUSH><@15201><T2~13013><PUSH><@15201><T2~13016><PUSH><@15201><T2~13015><PUSH>
<@15201><T2~13014><PUSH><@15201><T2~12001><PUSH>
$ ----- Entity Selection - Select Master Node(s)
<@12501><PUSH>f
$ ----- Entity Selection - Select Master Node(s)  ( On Surfaces )
$ ----- Entity Selection - Select Master Node(s)  ( On Surfaces )
<@11701>5
<A-M><OK>
<OK>
$ ----- Define RIGID Element - Enter Nodes or Select with Cursor
<Esc>
$ ========================================
$ Analyze Model
{~1017}

 

Re: How to run a macro command multiple times

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor

It's best to have a look at the docs via Help | Help Topics.  Then do a search for DELAY, and choose the topic: Tools, Programming, Program File.

 

You need, eg.

 

$ at the point in your macro where you want the repeat to start.

#(10) 

$ to return the macro speed to default speed of 25ms per keystroke:

#DELAY(25)

 

$ Then at the end of the macro, you need the following... where "big number" in ms is longer than the analysis runtime + time for the results to auto-load.

#DELAY(big number)

$ Analyze Model

{~1017}

$ Then send macro execution back to the point where you want the macro to start repeating.

#GOTO(10)

 

You may need to to do a few tests to confirm the optimum place to put the DELAY() lines.

Re: How to run a macro command multiple times

Valued Contributor
Valued Contributor

EnDuraSim

Thanks, it worked out!
In another topic you said-"Use # SILENT and # DELAY to speed the process and not see the dialog boxes."
Please show an example of how to hide the macro selection dialog elements.

#(10)
#DELAY(25) 
$ ========================================
$ Element Rotate By
{~1434}
$ ----- Entity Selection - Select Element(s) to Rotate To Coordinates
<@11701>1
<A-M><@11701>2
<A-M><@11701>3
<A-M><@11701>4
<A-M><@11701>5
<A-M><@11701>6
<A-M><@11701>7
<A-M><@11701>8
<A-M><@11701>9
<A-M><OK>
$ ----- Vector Global Axis - Select Axis of Rotation
<A-Z><@10011>0<@10012>0<@10013>0<OK>
$ ----- Rotation and Translation
<@10501>5<OK>
$ ========================================
#DELAY(10000)
$ Analyze Model
{~1017}
#GOTO(10)

 

Re: How to run a macro command multiple times

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor

To get the best out of the macro language, Use Help | Dockable Panes | Program File.

 This describes all the excellent and easy-to-learn commands... like creating a quick dialog prompt to get some variable user input using #ASK; pausing the macro anywhere to wait for some user input with <USER>; creating a simple branch test with #IF and #ENDIF.  It also describes #DELAY, and also how #SILENT works to switch on (default) or off the display of dialogs as the macro runs.  You have already used #DELAY.  #DELAY(0) will make the macro run as fast as it can, but be careful as this setting may be too fast for your computer's response time, particularly if the dialogs are displayed.  Which is why the default DELAY is 25ms if it is not otherwise set in your macro.