« Back to University of Vienna - OMILAB

How can I get modelids of imported models?

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Dear ADOxx.org Team,
I wonder if it is possible to retrieve the modelids of imported models with ADOxx.I am currently listening to the event "EndADLImport", however 'modelids' is undefined and I can't find information in the help or the forum.
Thank you very much in advance.

RE: How can I get modelids of imported models?
Answer
5/22/15 10:11 AM as a reply to Anonymous.
Hi,

Thank you for your question. The event "EndADLImport" has only a Boolean output-parameter "successful". To solve your issue you would need the combination of the following three event listeners:

  1. CreateModel
    During the import of models ADOxx handles the import of each model as creating a new one. In this event we collect the modelids of the imported/created models. Here we have to distinguish if the modelids really created or imported. Therefore we define a global Boolean variable (See example below bCollectModelIDs).
  2. StartADLImport
    We set here the Boolean value to “true”. So we can start to collect the ids.
  3. EndADLImport
    If the import ends we set again the Boolean value to “false” and end the collection.
 
The implementation for the approach above is as follows:

#Define a global Boolean variable bCollectModelIDs if the app is initialized
1ON_EVENT "AppInitialized" {
2SETG bCollectModelIDs:0
3}

#In the event CreateModel we differ the two cases of the Boolean variable bCollectModelIDs (The value is set in the EndADLImport and StartADLImport events)
1ON_EVENT "CreateModel" {
2SETG nModelId: (modelid)
3  #Collect the Ids of the models which are imported
4  IF (bCollectModelIDs) {
5  SETG lImportedModelIDs: (tokunion(lImportedModelIDs, STR nModelId))
6  }
7}

#Set the Boolean variable bCollectModelIDs to “True” (-> Start collecting ids in the CreateModel event).
1ON_EVENT "StartADLImport" {
2SETG lImportedModelIDs:""
3SETG bCollectModelIDs:1
4}

#Display the collected Modelids and stop collecting by setting bCollectModelIDs to “false”.
1ON_EVENT "EndADLImport" {
2CC "AdoScript" INFOBOX ("The following modelids have been imported: " + lImportedModelIDs)
3SETG bCollectModelIDs:0
4SETG lImportedModelIDs:"" # not needed since reset when you start a new ADL import.
5}