Problem on funtion memberremove()

Problem on funtion memberremove()

wooram_kim
Participant Participant
14 Views
1 Reply
Message 1 of 2

Problem on funtion memberremove()

wooram_kim
Participant
Participant

[ FlexSim 24.1.0 ]

I have two machines. The machines have the same name, but they are on different planes. They are members of an MTBFMTTR object. I want to remove the red machine from the object with “memberremove(Model.find("Plane2/Processor"), "MTBFMTTR1", 2)”. But the machine is not removed, and the green machine is removed instead. I attahced the file and chapter image. Please help me.

memberremove.fsm

화면-캡처-2024-11-13-150508.png

0 Likes
Accepted solutions (1)
15 Views
1 Reply
Reply (1)
Message 2 of 2

philboboADSK
Autodesk
Autodesk
Accepted solution

This is a bug with the memberremove() command. It is searching for the coupling node by the object's name. Because both of your objects are named "Processor", it isn't working properly.

I'll add a case to the development list.

In the meantime, you can work around the issue by finding the coupling by value. Attached is your model with a MemberRemove user command that does this.

treenode child = param(1);
string parentname = param(2);
int type = param(3);

treenode members;
if (type==1) {
    members = Model.find("/Tools/TimeTables/"+parentname+">variables/members");
} else if (type==2) {
    members = Model.find("/Tools/MTBFMTTR/"+parentname+">variables/members");
}
treenode childcoupling;
for (int r = 1; r <= members.subnodes.length; r++) {
    treenode membercoupling = members.subnodes;
    if (ownerobject(membercoupling.value) == child)
        childcoupling = membercoupling;
}
if (objectexists(childcoupling))
    destroyobject(childcoupling);

memberremove_1.fsm



Phil BoBo
Sr. Manager, Software Development
0 Likes