Just to be clear, did you create those object occurrences with a script and those empty ones are the final result, or do you just happen to have one or more models which look like ones shown above for whatever reason and are now tasked with fixing them?
If it's the former, I assume you've used
Model.createObjOcc ( int SymbolNum, ObjDef objDef, int X, int Y )
to create the object occurrences. Don't use that method. Instead use
Model.createObjOcc ( int SymbolNum, ObjDef objDef, int X, int Y, boolean bCreateAttrPlacements )
and let the bCreateAttrPlacements be true. The description of the second method I mentioned says in the ARIS Script documentation that the last parameter is "false" by default, which is why if the parameter is omitted you wouldn't get any attribute placements (such as the name).
If it's the latter, and you were just given the models to fix them, you can either do it with a script, or maybe the format template already does the trick for you too (if the template is correctly set up, with the "Name" attribute occurrence set as a default). Just open the model, select all the occurrences for which you want to apply the template, and then in the tab "Format", there is a box where you can set the template.
You (or one of your colleagues if you don't have the permission) can check if the template is correctly set up beforehand, by going to ARIS > Administration > [tenant name] > Configuration > Conventions > Templates > right click [Template name] > Edit > click next until you reach the assistant step "Place symbol attributes" > in the list of symbols look for and select the symbol type you want to check/fix > in the lower field "Placed attributes" it should say "Name".
Hi Kay, thanks for your answer
I have a model with objects on it and my task is printing them with using script. Your script is about creating new object occurrences I guess, but they are existing, I just need to take them and print in order.
As you see, I have problem to print names on graphic. Is there a known way to do it?
Does the original model (the one on which you invoke Model.Graphic ( boolean CutObjects, boolean BlackWhite, int localeId ) to get the graphic that you can add to the output) contain object occurrences with placed attribute occurrences (with the name shown)?
Edit: aditonal question: do you use an evaluation filter?
Hi Kay, thanks for your answer,
I used Model.Graphic() function to take model's picture, but I need to take all object's picture separately.
I used filter like shown below,
<pre class="brush: jscript">
var filter = ArisData.ActiveFilter( );
var connTargetGraphic = filter.SymbolGraphic( connTargetSymbolNum );
var connSourceGraphic = filterSymbolGraphic( connSourceSymbolNum );
</pre>
Also, I uploaded my script, I will be glad if you check it
Thank you
Arda
I think you need some code like this:
var lAttr = lObjOcc.ObjDef().Attribute(Constants.AT_NAME, -1) if (lAttr.IsMaintained()){ var lAttrOcc = lObjOcc.AttrOcc(Constants.AT_NAME) var lPort = Constants.ATTROCC_CENTER var lFontStyleSheet = GetDefaultStyleSheet() lAttrOcc.Create(lPort, lFontStyleSheet)) } function GetDefaultStyleSheet(){ var lDefaultFontStyleSheet = null var lFontStyleSheets = ArisData.getActiveDatabase().FontStyleList() for (var i in lFontStyleSheets){ var lFontStyle = lFontStyleSheets[i] if (lFontStyle.IsDefaultFontStyle()){ lDefaultFontStyleSheet = lFontStyle }break } return lDefaultFontStyleSheet }
Regards, Ariene