JP

I would like to create a macro to apply in process models in order to change the default color of the objects present in the models based on the value of one attribute of these objects.

In the next example, in case the value of the Description attribute is 1, then the color of the object should be 'black'.

I executed the macro without errors but nothing has changed in the model, the objects still have the previous colors.

Could you help me and suggest what I'm doing wrong?

 

Thanks in advance a lot for your collaboration

 

Kind regards

 

 

function main() {      var selModels = Context.getSelectedModels();    var nLocale = Context.getSelectedLanguage();    var selobjs = Context.getSelectedObjects();                 for (var i = 0; i < selModels.length; i++) {              var oModel = oSelectedModels[i];             var oObjOccs = Designer.getOccs(oModel);       for ( rr = 0 ; rr < oObjOccs.length ; rr++ ) {                  var valuation = Designer.getAttribute(oObjOccs[rr], Constants.AT_DESC, nLocale);                       if (valuation == 0) {          Designer.setFillColor (oModel,oObjOccs[rr],java.awt.Color.BLACK)   }   }          } }
by Torsten Haase
Posted on Mon, 03/25/2013 - 10:31

Hi,

after making changes to a model in a macro using the Designer object, you have to save your changes by calling

Designer.Save(oModel)

BR, Torsten

0
by Jaime Pedros Author
Posted on Wed, 03/27/2013 - 12:22

Thanks Torsten for your comments, but still is not working the macro :(

I have introduced a couple of changes, but any progress on it.

 

Thanks for your support



function main()

{

   var selModels = Context.getSelectedModels();

   var nLocale = Context.getSelectedLanguage();

   var selobjs = Context.getSelectedObjects();

    

    

    for (var i = 0; i < selModels.length; i++) {

       

    var oModel = selModels[i];

     if (!Designer.isOpen(oModel)) {

        Designer.openModel(oModel,false,true,false);

       

     var oObjOccs = Designer.getOccs(oModel);

   // var oObjOccs = selobjs

      for ( rr = 0 ; rr < oObjOccs.length ; rr++ ) {

          

          

           // Constants.AT_NAME= 9

 var valuation = Designer.getAttribute(oObjOccs[rr], 9 , nLocale);

    

     

    

   if (valuation == 1) {

         Designer.setFillColor (oModel,oObjOccs[rr],java.awt.Color.BLACK)

  }

  }      

  }

}

Designer.Save(oModel)

}

 

0
by Stefan Geis
Posted on Wed, 07/17/2013 - 10:09

Hi there,

I am doing similar things as Jaime. However, for some object occurrences, calling  "Designer.setFillColor" leads to an unsupported exception.

Also, Designer.Save(...) throws an exception "TypeError: Cannot find function Save in object Designer@372db5."

Any help is highly appreciated!

Stefan

 

0
by Sofia Nobrega
Posted on Mon, 11/04/2013 - 11:51

Hi, Were you able to solve this issue? I have adapted the code but no refresh on colors occurs.

var valuation = Designer.getAttribute(oObjOccs[rr], Constants.AT_DESC, nLocale);
if (valuation == 0) {
Designer.setFillColor (oModel,oObjOccs[rr],java.awt.Color.BLACK);
}
else
Designer.setFillColor (oModel,oObjOccs[rr],java.awt.Color.RED);
}
Designer.refresh(oModel);
}
}
Designer.Save(oModel);

Could you please give me an hint how to solve it?
Thanks. Sofia

0
by Jaime Pedros Author
Posted on Mon, 11/04/2013 - 16:57

Hi Sofia

Please check with this code for the macro.

Regards

var selModels = Context.getSelectedModels();
var nLocale = Context.getSelectedLanguage();
var selobjs = Context.getSelectedObjects();

for (var i = 0; i selModels.length; i++) {

var oModel = selModels[i];

var oObjOccs = Designer.getAllOccs(oModel);

for ( rr = 0 ; rr oObjOccs.length ; rr++ ) {

var oOcc = oObjOccs[rr];

var oAttrDefObj = Designer.getDefinition(oOcc);

// attribute 9
var valuation = Designer.getAttributeWithFallback(oAttrDefObj, 9, null);

if (valuation == 0) {
Designer.setFillColor (oModel,oObjOccs[rr],java.awt.Color.RED)
}

if (valuation == 1) {
Designer.setFillColor (oModel,oObjOccs[rr],java.awt.Color.ORANGE)
}
if (valuation == 2) {
Designer.setFillColor (oModel,oObjOccs[rr],java.awt.Color(0.4,1,0))
}
if (valuation == 3) {
Designer.setFillColor (oModel,oObjOccs[rr],java.awt.Color(0,0.6,0))
}
if (valuation == 'n/a') {
Designer.setFillColor (oModel,oObjOccs[rr],java.awt.Color(1,1,1))
}

// }
}
}

0
by Krishna Kawade
Badge for 'Commentator' achievement
Posted on Wed, 08/11/2021 - 13:23

Its been too late but check this code

function main()
{
    var l_models = Context.getSelectedModels();
    for (var i=0;i<l_models.length;i++)
    {    
        var l_model_type = l_models[i];
        Designer.openModel(l_model_type,false,true,false);       
        var l_ObjOccs = Designer.getOccs(l_model_type);
        for(var j=0;j<l_ObjOccs.length;j++)
        {    
            var l_attribute = Designer.getAttribute(Designer.getDefinition(l_ObjOccs[j]),Constants.AT_HIER_NUM ,null);
            if(l_attribute==null)
            {
                  Designer.setFillColor(l_model_type,l_ObjOccs[j],java.awt.Color(254/255, 87/255, 64/255));
            }
            
        }      
    }
    Designer.Save(l_model_type)
}
main();

0
by Runé Becker
Badge for 'Mastermind' achievement
Posted on Thu, 08/26/2021 - 08:27

In reply to by Krishna Kawade

Thanks Krishna, for your contrubtion!

Yes, the question from seven years ago is hopefully resolved.

But if you'd like to share great ARIS script code snippets feel free to share them just as a new post, maybe not as a question but with something like "Did you know..." or "My tip for...".

Cheers
Rune

0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock