To add a new MTBF object to the toolbox you can use this line of FlexScript
treenode table = applicationcommand("addmtbfmttr");
If you want to configure the tool at all it gets a little more tricky. We don't currently have a nice API for configuring the MTBF, although we are hoping to add one down the road. You can still do everything through FlexScript, but nothings documented or very discoverable at the moment.
If you want to add new members to the tool you would use code like this:
treenode obj = model().find("Processor1"); treenode members = getvarnode(table, "members"); treenode timetables = getvarnode(obj,"timetables"); createcoupling(members, timetables); members.last.name = obj.name; timetables.last.name = table.name;
If there are any other things you want to configure through code we can help you find the needed code.
Thanks,
A follow up question :
treenode table = applicationcommand("addmtbfmttr");
opens up the pop up window. How do I close it using flex script?
Add a 1 as a second parameter if you don't want the properties window to open:
applicationcommand("addmtbfmttr", 1)
The code to add the coupling gives me an error on the last two lines
exception: FlexScript exception: Property "last" accessed on invalid node. at MODEL:/Tools/UserCommands/addBreakDowns/code
exception: FlexScript exception: Property "last" accessed on invalid node. at MODEL:/Tools/UserCommands/addBreakDowns/code
exception: FlexScript exception: Property "last" accessed on invalid node. at MODEL:/Tools/UserCommands/addBreakDowns/code
exception: FlexScript exception: Property "name" accessed on invalid node. at MODEL:/Tools/UserCommands/addBreakDowns/code
how do I resolve this?
Can you post the code you're using? And do you have an object called Processor1 in the model? That line should be changed to the object you actually want to add.
Here is my code:
basically, I changed a few variable names and changed the "Processor1" string that you mentioned earlier @Matthew Gillespie
breakdown = applicationcommand("addmtbfmttr",1);
treenode mtbf = getvarnode(breakdown, "mtbf");
treenode mttr = getvarnode(breakdown, "mttr");
treenode firstmtbf = getvarnode(breakdown, "firstmtbf");
treenode proc = model().find(gettablestr(procInfoTable,i,col_proc_name));
treenode members = getvarnode(breakdown, "members");
treenode timetables = getvarnode(proc,"timetables");
createcoupling(members, timetables);
members.last.name = proc.name;
timetables.last.name = breakdown.name;
Edit: I did a bit of debugging and found that the 1 in, applicationcommand("addmtbfmttr", 1)
was causing the error. (obviously withoutthe 1 the application just opensup a bunch of unwanted mttr windows.
Huh, it no longer returns the created node if you pass in the 1. That looks like a bug.
Here are two workarounds:
applicationcommand("addmtbfmttr", 1); treenode table = model().find("MTBFMTTR").last;
OR
treenode mtbfmttr = applicationcommand("addtool", "MTBFMTTR", library().find("MTBFMTTR"));