Document Viewer
Hands-On: Visualisation AdoScript
VISUALISATION AdoScript
Sample on Visualisation with ADOscript
- Count how many objects of class E have been modelled in actual model
- Create a new model in a selected modelgroup with Target-Result as an object
- The radius of the target result is the count of modelled Es. --> The more Es have been modelled, the bigger is the resulting circle.
## Get active Model
CC "Modeling" GET_ACT_MODEL
SETL idStartModel: (modelid)
# make an info box for debugging reasons - convert value of idStartModel into a string
CC "AdoScript" INFOBOX ("Hello " + STR idStartModel + "!") title:"Start model id!"
## count how many objects of class "E" have been modelled in that model
# get the id of class "E"
CC "Core" debug GET_CLASS_ID classname: "E"
SETL idClass: ( classid )
#This GET_CLASS_ID sets following global variables: [ecode:intValue] [classid:intValue]
# get all objectss of class "E"
CC "Core" debug GET_ALL_OBJS_OF_CLASSID modelid: (idStartModel) classid:(idClass)
IF ( LEN ( objids ) = 0) {
CC "AdoScript" ERRORBOX ("You have no instances of class 'E'!")
EXIT
}
SETL nCountOfObjects: ( tokcnt ( objids ))
CC "AdoScript" INFOBOX ("There are " + STR nCountOfObjects + " instances of class E!")
title: "Count of objects of class E!"
## Creating a new model
CC "CoreUI" MODEL_SELECT_BOX mgroup-sel without-models title: "Target Model Group"
boxtext: "Please select the model group where to save the result: "
#This MODEL_SELECT_BOX sets several global variables:
# [modelids: idList | threadids: idList ] [ mgroupids: idList ]
# [appmodelids:idList ] [ extraValues ]
#The global variable mgroupids is used in CREATE_MODEL
CC "Core" CREATE_MODEL modeltype: "Result-Type"
modelname: "My Count Result"
version: "1.0"
mgroups: ( mgroupids )
# open the new created model AND make the new model ACTIVE
IF (ecode = 0) {
CC "Modeling" CREATE_WINDOW_FOR_LOADED_MODEL modelid: ( modelid )
}
## Create objects in the new model
# get the model id of the new model
CC "Modeling" GET_ACT_MODEL
SETL idResultModel: ( modelid )
# make an info box for debuggin reasons - convert value of id_actmodel into a string
CC "AdoScript" INFOBOX ("Hello " + STR idResultModel + "!")
title:"Result model id!"
# get the id of class "Result-of-Count"
CC "Core" debug GET_CLASS_ID classname: "Result-of-Count"
SETL idClassResult: ( classid )
# create the object
CC "Core" debug CREATE_OBJ modelid: (idResultModel)
classid: (idClassResult)
objname: "A new Result-of-Count"
SETL idObject: ( objid )
IF (ecode != 0) {
CC "AdoScript" ERRORBOX ("The object could not be created. \n"+
"Maybe a model having the same name already exists?")
}
# get the attribute "number of counts" of the class
CC "Core" GET_ATTR_ID classid:(idClassResult) attrname: "number of counts"
SETL idAttribute: ( attrid )
IF (ecode !=0) {
CC "AdoScript" ERRORBOX "The selected object does not contain" +
" an attribute called \"number of counts\" !"
EXIT
}
# set the name of the selected object
CC "Core" debug SET_ATTR_VAL objid: (idObject) attrid: (idAttribute) val: (nCountOfObjects)
IF (ecode != 0) {
CC "AdoScript" ERRORBOX "Could not set the attribute value!"
EXIT
}