Enterprise Architect - SysML Diagram Heading - enterprise-architect

I hope this is an easy question - how do I get the SysML Diagram Header to display the correct model element type (the information in the first set of square brackets)? My diagrams all display as [package].
I'm using Sparx Enterprise Architect Version 13.5.
Thanks

The "correct model element type" is the type of the model element containing the diagram. The Diagram Frame represents the model element in which the diagram is contained and therefore the model element type is frequently, for many BDDs, the name of the package containing the diagram. Suggest reading OMG SysML specification v1.5 Annex A: Diagrams for details. It is free.

Thanks for your comments. I have resolved this issue by stereotyping the parent element (package) in the project tree to the model element type I need. This results in the appropriate model element type information appearing in the diagram frame.

Related

How to inherit attributes in class/block diagram using Eclipse Papyrus?

I'm creating a very simple class diagram using the Eclipse Papyrus but I'm not able to represent instances correctly.
First of all, I'm using the SysML 1.6 profile, so my classes are actually represented in a Block Diagram instead of classes, but I believe that this does not change anything in my problem.
After creating a simple class/block in my block definition diagram (bdd) I defined some attributes for my block like the example below:
When I tried to create some instances of my block ("parts" in SysML naming convention) using an "Instance Specification" I'm not able to inherit these attributes and fill them with actual information like the "name" and "quantity" in this example.
It's possible to see that my classifier is correctly set as "My component".
The Papyrus documentation for the Object diagram is clear and says that these Instance Specification should include my attributes so I don't know what I'm doing wrong.
I've tried since now:
Create instances in the same block diagram (bdd);
Create instances in another dedicated diagram of the type internal block definition (ibd);
Use the Papyrus context menu to show/hide all my compartments. Any of them works to show my attributes.
Apparently, the same problem occurs without any SysML profile and using pure UML like this question here (from 2016!!)
Papyrus version: 6.1.0

step by step solution needed for the txtUML diagram

I am a novice to txtUML. I tried to follow the tutorial and youtube link on txtUML to run the below code, but didn't understand how they add txtUML diagram from nowhere? Please Help me to understand the code and any step by step procedure to run this code will be helpful.enter image description here
The diagram generation feature of txtUML was built to be able to create fully user customizable diagrams. Hence the development team introduced a diagram description language. With this language the user can give constraints to the elements on the diagram.
To be able to create a diagram you'll need to have model of cousre.
The diagram description is a Java class, the constraints can be defined through java annotations. An empty description of Class Diagram looks like the following:
class MicrowaveClasses extends ClassDiagram {
class MicrowaveLayout extends Layout {}
}
In case of Class Diagrams the description class have to extend hu.elte.txtuml.api.layout.ClassDiagram
The Layout inner class has to be annotated with the constraints. For example #TopMost(MicrowaveOven.class) will place the MicrowaveOven ModelClass to the top of the class diagram. Further reading
After you're done with the diagram description you can choose diagram generation option from the menu: txtUML->Generate diagrams from txtUML. On the wizard page you should browse the project where your model is to be found, the java package which represents your model (the package where the model-info.xtxtuml file is to found), and at least one diagram description (in this case MicrowaveClasses).
A Papyrus model will be created with as many diagrams as you selected on the wizard page. To each diagram description there will be a Papyrus diagram generated. The process is clearly to be seen in the Youtube video that you mentioned.

Enterprise Architect: Change diagram type (MetaType) by script

i have to change the diagram type of a lot of diagrams within my Enterprise Architect model. The change can be made manually using following option (that works as expected):
Select diagram - Diagram - Advanced - Change Type...
As I have to change a lot of diagrams I have created a script which searches for all concerned diagrams and change the type automatically. I wrote already a lot of JScript EA scripts for changing some modeling elements. Unfortunately, this feature seems not be available over the scripting interface.
I have to change the "MetaType" of the the diagram object. But this is read-only (see http://www.sparxsystems.com/enterprise_architect_user_guide/12/automation_and_scripting/diagram2.html). Therefore, I got an error.
var currentDiagram as EA.Diagram
currentDiagram = theDiagram
currentDiagram.MetaType = MY_DIAGRAM_METATYPE // ERROR
In the next step I searched for appropriate functionalities in the Repository interface (http://www.sparxsystems.com/enterprise_architect_user_guide/12/automation_and_scripting/repository3.html) and in the project interface. But I found nothing appropiate.
I am using Enterprise Architect 12.0.1215 and I used JScript.
Has anyone already tried this by script?
Have I missed something?
Is there another approach to achieve the diagram type change by script?
Thanks in advance!
You have to do that in two steps (if you change to different MDG diagram types). E.g. to change a Class diagram to a BPMN2.0::BPEL you first change Diagram_Type from Logical to Analysis. Additionally you need to add MDGDgm=BPMN2.0::BPEL; to StyleEx. In case your old diagram is from another MDG you need to modify the existing MDGDgm attribute in StyleEx.
As Uffe noted, the diagram type in the API is r/o. So if you need to change that you would need to do something like
Repository.Execute("UPDATE t_diagram SET Diagram_Type='Analysis' WHERE Diagram_ID=<theId>")
where <theId> would be the correct diagram ID.

Display Notes of Custom Stereotypes in Enterprise Architect

I want to create my own custom toolbox. Therefore I created a metaclass and a stereotype. In the stereotype I wrote a note that gives some instructions about how to populate the object.
Problem is, when I create my MDG Technology, the Notes won't display in the objects I create in my diagram..
How can I fix this and display the Notes for every object I create?
You can either
Write and MDG-Addin to populate the notes for your elements.
Add an element with your stereotype to the template package and add the required notes there. This will have to be done on each model that uses your MDG.
Firstly I'm assuming that you can see the notes you seek on the Properties page of an element you create using your toolbox i.e. the notes field is populated.
If it is, check that notes visibility is turned on by doing these two things:
1) Select the element and go to Element->Feature and Compartment Visibility. Check the Show Notes box. Hit OK
2) Right click on an element and choose Advanced->Use Rectangle Notation

Default diagram for Toolbox

I have a custom toolbox with a foo element.
I would like the foo to be green on an class diagram and red on flow chart diagram by default.
Adding more than one stereotype to non- UML type is impossible (as far as I know).
Is it possible to create 2 toolboxes- one for class diagrams and one for flow charts, specifying the default diagram for each toolbox in the profile?
Not quite the way you describe it.
Toolboxes don't specify which diagram they open, it's the other way around: you create a custom diagram type and associate it with a toolbox. Different custom diagrams may use the same custom toolbox.
You can create two custom diagram types, one for class ("Logical") and one for flow chart ("Activity"), but if you're only after getting the same stereotyped element (foo) to display differently in the diagrams, you don't need to.
The solution is to create a shape script for the stereotype, which checks the diagram type and changes the color accordingly. The diagram type can be queried from the shape script using the diagram.type property (for the base UML diagram type), or diagram.mdgtype (for the custom diagram type, if you've defined one). There is no need to create an Add-In, as another answer suggests, at least not in EA 11.
Check the help file under Extending UML Models -- MDG Technology SDK -- Shape Scripts -- Write Scripts -- Display Element/Connector Properties.
A simple script might look like this:
shape main {
if (hasproperty("diagram.type", "Logical")) {
setfillcolor(0, 255, 70);
} else if (hasproperty("diagram.type", "Activity")) {
setfillcolor(255, 87, 87);
}
drawnativeshape();
};
No. You need to have two different stereotypes. The target diagram is independent of the element. If you want the element appear different on the type of the diagram where you use it you need to adapt the shape script so it calls an add-in which detects the diagram type.
Well, writing the last sentence I would not know how to detect the diagram where the element in question is in. Needs investigation. But other than that - no solution I know of.
Edit: Since the add-in just receives the element GUID it has no way to figure out the diagram from where the call is made. Probably worth a feature request. But the time where we saw those realized in the next build are gone (since more than 10 years).
A last though: template packages. I almost never used them. Maybe they offer coloring depending on diagram/element.
Edit2: Last resort EA_OnPostNewDiagramObject. Catch that and you can get all information you need to apply the color.