Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: elr on October 12, 2024, 10:31:09 am
-
Hello all,
I created an MDG profile with several stereotyped elements.
One is 'Committee' : a stereotype of Actor metaclass with a dedicated shape (set with ShapeScript)
Once one is created in Browser, I can drag it drop as an Instance (Ctrl-DnD) in my diagram but then, visual aspect becomes again the Actor's stickman and not the shape I set up
:(
Ideally, I'd like to do as UML Profile: same shape with a different color and a underlined name.
Thank's for your recipe !
Eric
-
You have to make a stereotype for the instance as well.
In the classifier stereotype you can set which stereotype should be used for it's instances.
Geert
-
Hi Geert and (once again...) thx !
"Yes, I have added to my toolbox an element named 'committee instance', which is a stereotype of Object metaclass. This metaclass is connected (I logically used an 'instantiates' relationship) to the Committee stereotype of the Actor metaclass."
This approach seems to work. But then, I don't know how to retrieve the list of already defined committee names in order to specify which committee this newly created instance is of.
Hope to be clear... :-\ ( I don't know how to show my metamodel fragment...
Eric
-
I ususally don't put instances in a toolbox. It's much easier to drop the classifier on the diagram and create an instance that way.
Geert
-
to drop the classifier on the diagram...
Do you mean : Dropping a class onto diagram then selecting the element it's an instance of through Advanced/Instance Classifier ?
Eric
-
Guess no. You can make an instance stereotype than you can place in the toolbox. Creating that will make you link it to its classifier after creation (or it will stay an anonymous object). Depends on what you prefer or do the most.
q.
-
Yes,qwerty I configured it that way (as an object stereotype in my TB as Eve recently recommended me), but then...how can I access attributes of the metaclass and, even better, values of theses attributes that have been defined so far?
For example:
for: Committee.name='Steering committee'
being able to get: Committee instance.name =:Steering committee
by selecting in a listbox among all existing names
instead of simply getting : :Committee Instance
In metamodel, what should be the relation type between Committee stereotype that extend Actor metaclass and Committee Instance stereotype that extend Object metaclass to make Committee element attributes, TV accessible to Committee Instance element ?
:-\
Eric
-
The attributes are only available via the classifier (which you have ro set manually). However, you probably need to set runtime states via the context menu if I guess you intention correctly (which I'm nor sure about). So probably you should elborate a bit about your modeling goals.
q.
-
The attributes are only available via the classifier (which you have ro set manually)
Too bad...
And what about a code sequence being fired when TB element is dropped to diagram ? Is that possible ?
Eric
-
Yes sure. You have to subscribe to on_new_element in the add-in API to get a notice when the object (or anything else) is created.
IIRC Geert has some framework that would save you from writing all the sdd-in clutter, though that's not too difficult itself (see his write an add-in in 10 minutes post).
q.
-
OK, It requires an add-in setup. It's another step for me.
but I'll throw a look into Geert's work.
Thx for all, qwerty !
Eric
-
OK, It requires an add-in setup. It's another step for me.
but I'll throw a look into Geert's work.
Thx for all, qwerty !
Eric
I'm not convinced you need an add-in. I think you can use some of the properties of the classifier in a shapescript.
These are the properties that you can use from a shapescript:
classifier
classifier.actualname - same as 'classifier.name' except that it does not react to the 'Use Alias if Available' setting
classifier.alias
classifier.metatype
classifier.name
classifier.stereotype
classifier.type
Geert
-
Geert,
I just discovered your precision. Thank you !!
Any info or example how to use classifier with shapescript would enlight me.
BTW, Happy new year !
Eric
-
Something like this:
if(hasproperty("classifier",""))
{
{
println("#NAME# :#CLASSIFIER#");
}
}
Geert
-
Thx Geert !