Hi
We have a lot of Function Allocation Diagram. And for now, we want to place an UD-Attribute on each function-occurance within these diagrams.
All around the report works fine. And now I have an occurcance. But how can I set the attributes displayed for that occurance?
Kind regards,
Dominik
Hi Dominik - Do you not want to use a template for this? You could create a template just for FADs that has the attribute placements you want and create a simple macro that would set and/or reapply the template every time a user opens a FAD to ensure that the attribute placements you want are shown.
Hi Ellen,
Thanks for your tip. My manual work was something like this. And I have some strange effects.
I have the attribute placed in the template. When you create a new diagram, all works. When I open an old one, and reapply the template, the most of the settings were applyed. The Icon, the colors etc., but not the attribute placement. When I add the same object again, all is finde - but this is to much of work. So I like to do it by macro.
Or do I have somewhere else any missconfiguration?
Hi Dominik - sometimes you must clear the current template and then reapply it before it will show the attribute placement.
You could create a simple macro that runs when a model is opened and reapplies the template for you:
main(); function main() { var eventType = Context.getProperty("event.id"); if (eventType == Constants.EVENTID_MODEL_OPENED) { var oModels = Context.getSelectedModels(); for (var i in oModels) { var template = Designer.getTemplate(oModels[i]); if (template != null) Designer.applyTemplate(oModels[i], template); } } return; }
If you want to use the template to add those attribute occurrences directly, you could do something like this:
main(); function main() { var attrType = Constants.AT_DESC; var assignedModel = null; var eventType = Context.getProperty("event.id"); if (eventType == Constants.EVENTID_MODEL_OPENED) { var oModels = Context.getSelectedModels(); for (var i in oModels) { var oObjOccs = Designer.getOccs(oModels[i]); for (var oi in oObjOccs) { var addAttrOcc = true; if (oObjOccs[oi].getItemKind() != Constants.CID_OBJOCC) { addAttrOcc = false; } else { var attrOccs = Designer.getAttrOccs(oModels[i], oObjOccs[oi]); for (var ai in attrOccs) { if (Designer.getAttrTypeNum(oModels[i], attrOccs[ai]) == attrType) addAttrOcc = false; } } if (addAttrOcc) var newAttrOcc = Designer.createAttrOcc(oModels[i], oObjOccs[oi], Constants.ATTROCC_CENTERBOTTOM, attrType, Constants.ATTROCC_ALIGN_CENTER, Constants.ATTROCC_TEXT); var stop = 1; } } } return; }
In this example, I am setting the Description attribute to the center bottom of the object. You would obviously need to change the attribute type, port, alignment, etc. accordingly.
- Ellen