Problem when adding Operators in code

Imbafestor
Imbafestor New Altair Community Member
edited November 5 in Community Q&A
Hey,

i am writing an extension in which i implement a own super operator. Now i want to fill a subprocess with an operator in code, but the problem is, that the operator keeps getting added two times (Even the constructor of my superoperator is called several times when adding only one instance in rm).

Here is my code:

public MySuperOperator(OperatorDescription description)
{
super(description, "SubProcess 0", "SubProcess 1");
createSubProcess();
}

private void createSubProcess()
{
ExecutionUnit sub = getSubprocess(0);

try {
if(sub.getOperators().size() < 1) // doesn't prevent adding two operators :/
{
sub.addOperator(OperatorService.createOperator(MultiplyLabelBy.class));
}
} catch (OperatorCreationException e) {
e.printStackTrace();
}
}
I found a topic with the same problem (https://rapid-i.com/rapidforum/index.php/topic,3549.0.html) but no answers. Is it a bug or am I missing something?

Best regards

Answers