#----------------------------------------------- ITEM "Set Annotation" acquisition:"Extras" modeling:"Extras" analysis:"Extras" simulation:"Extras" evaluation:"Extras" importexport:"Extras" #----------------------------------------------- #identify the objects of class "Note" in the active model CC "Modeling" GET_ACT_MODEL # --> modelid: intValue. CC "Core" GET_ALL_OBJS modelid: (modelid) # --> RESULT ecode: intValue objids: strValue . SET str_objids: (objids) SET id_noteid: (-1) FOR id_objectid in: (str_objids) { CC "Core" GET_CLASS_NAME classid: (VAL(id_objectid)) # --> RESULT ecode: intValue classname: strValue isrel: intValue . IF (classname = "Note") { SET id_noteid: (VAL(id_objectid)) CC "Core" GET_ATTR_VAL objid: (id_noteid) attrname: "Annotated" # --> RESULT ecode: intValue val: anyValue . IF ( (val) = "no") { #get position of Note CC "Core" GET_CLASS_ID objid: (id_noteid) # --> RESULT ecode: intValue classid: intValue isrel: intValue . CC "Core" GET_ATTR_ID classid: (classid) attrname: "Position" # --> RESULT ecode: intValue attrid: id . CC "Core" GET_ATTR_VAL objid: (id_noteid) attrid: (attrid) # --> RESULT ecode: intValue val: anyValue . SET str_notePosition: (val) SET n_xnote:0 GET_PARAM_VAL main_string:(str_notePosition) idx_param:1 param_val:n_xnote SET n_ynote:0 GET_PARAM_VAL main_string:(str_notePosition) idx_param:2 param_val:n_ynote SET n_wnote:0 GET_PARAM_VAL main_string:(str_notePosition) idx_param:3 param_val:n_wnote SET n_hnote:0 GET_PARAM_VAL main_string:(str_notePosition) idx_param:4 param_val:n_hnote SET n_cxnote: (n_xnote + n_wnote/2) SET n_cynote: (n_ynote + n_hnote/2) #find another object at that position, of class "Customization Feature" SET id_newobjid: (-1) FOR id_objectid2 in: (str_objids) { CC "Core" GET_CLASS_ID objid: (VAL(id_objectid2)) # --> RESULT ecode: intValue classid: intValue isrel: intValue . CC "Core" GET_CLASS_NAME classid: (classid) # --> RESULT ecode: intValue classname: strValue isrel: intValue . IF (classname = "Customization Feature") { CC "Core" GET_CLASS_ID objid: (VAL(id_objectid2)) # --> RESULT ecode: intValue classid: intValue isrel: intValue . CC "Core" GET_ATTR_ID classid: (classid) attrname: "Position" # --> RESULT ecode: intValue attrid: id . CC "Core" GET_ATTR_VAL objid: (VAL(id_objectid2)) attrid: (attrid) # --> RESULT ecode: intValue val: anyValue . SET str_objPosition: (val) SET n_xobj:0 GET_PARAM_VAL main_string:(str_objPosition) idx_param:1 param_val:n_xobj SET n_yobj:0 GET_PARAM_VAL main_string:(str_objPosition) idx_param:2 param_val:n_yobj SET n_wobj:0 GET_PARAM_VAL main_string:(str_objPosition) idx_param:3 param_val:n_wobj SET n_hobj:0 GET_PARAM_VAL main_string:(str_objPosition) idx_param:4 param_val:n_hobj IF ((n_cxnote > n_xobj - n_wobj/2) AND (n_cxnote < (n_xobj + n_wobj/2)) AND (n_cynote > n_yobj - n_hobj/2) AND (n_cynote < (n_yobj + n_hobj/2))) { SET id_newobjid: (VAL(id_objectid2)) #change the attribute of the other class CC "Core" GET_CLASS_ID objid: (id_newobjid) # --> RESULT ecode: intValue classid: intValue isrel: intValue . CC "Core" GET_CLASS_NAME classid: (classid) # --> RESULT ecode: intValue classname: strValue isrel: intValue . CC "Core" GET_ATTR_VAL objid: (id_noteid) attrname:"Note" # --> RESULT ecode: intValue val: anyValue . SET str_noteValue: (val) CC "Core" GET_ATTR_ID classid: (classid) attrname: "Annotation" # --> RESULT ecode: intValue attrid: id . CC "Core" GET_ATTR_VAL objid: (id_newobjid) attrname: ("Annotation") as-string # --> RESULT ecode: intValue val: anyValue . SET str_oldValue: (val) CC "Core" SET_ATTR_VAL objid: (id_newobjid) attrid: (attrid) val: ((str_oldValue) + (str_noteValue) + "\n********\n") # --> RESULT ecode: intValue . CC "Core" GET_OBJ_NAME objid: (id_newobjid) # --> RESULT ecode: intValue objname: strValue . CC "AdoScript" INFOBOX ("Attribute \"Annotation\" changed for object \"" + objname + "\" !") CC "Core" SET_ATTR_VAL objid: (id_noteid) attrname: ("Annotated") val: ("yes") # --> RESULT ecode: intValue . } } } } } } IF (id_noteid = -1) { CC "AdoScript" INFOBOX "No Note available in this model" #if no "Note" available, display an error message } PROCEDURE GET_PARAM_VAL main_string: string idx_param: integer param_val: reference { SETL str_param: (token(main_string, idx_param, " " )) SETL str_paramValue: (token(str_param, 1, ":")) SETL param_val: (VAL (token(str_paramValue, 0, "c"))) }