« Back to AAU Project

How to prevent adding a new graphical element to the current model

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
I am trying to prevent adding a new element of class "Behavioral Unit" to the current model after having a specific number of Behavioral Units, I am using
ON_EVENT "AfterCreateModelingNode" it works well and shows the error message, my problem that although I am exiting the event using the variable "nExitValue1", the new added element is created, what it should not happen.

My script is:

SET nExitValue1:0
CC "Modeling" GET_ACT_MODEL
SET idCrtModelID: ( modelid )
CC "Core" GET_MODEL_INFO modelid: (idCrtModelID)


    IF (modeltype="Task Context")
    {
    
SET aqlGetPredecessorsForObj: ("(<\"Behavioral Unit\">)")
  CC "AQL" EVAL_AQL_EXPRESSION expr: (aqlGetPredecessorsForObj) modelid: (idCrtModelID)
  SETL bUNodeIDs: (objids)
  SET i:0
    FOR bIDs in: (bUNodeIDs) {
    SET i: (i+1)
      
    }
    #CC "AdoScript" INFOBOX ("num   " + STR i)
    IF (i > 1)
    {
    CC "AdoScript" ERRORBOX ("Adding a new Behavioral Unit is not allowed")
    SET nExitValue1: (-1)
    
    }
    }


and in External Coupling I have:

ON_EVENT "AfterCreateModelingNode" {
EXECUTE file: ("Z:\\AfterCreateModelingNode.asc") scope:same
EXIT (nExitValue1)
}

RE: How to prevent adding a new graphical element to the current model
delete_objs aftercreatemodelingnode
Answer
18/08/15 12:38 as a reply to Fadi Al Machot.
Hi, Fadi.

As described in the ADOxx Documentation, the event "AfterCreateModelingNode" has no exit value.

I would suggest trying the DELETE_OBJS command call, as described here. Just add it right after the command call ERRORBOX or instead of the command EXIT (nExitValue1).

Hope it helps.
Sabin