Technologies:
Tolerim
a month ago
How can I access View stereotypes from a script as an Enterprise Architect?
As a JavaScript developer working on a bulk edit script for Enterprise Architect 16.1.1622, I aim to allow the user to select properties from all the common properties of the selected elements and display all possible predefined values (if available) for each selected property. Although I can easily retrieve the predefined values using Repository.GetReferenceList and Repository.PropertyTypes (via Detail Value=...), I am unable to find the inherited property values of a stereotype from a custom view. Is there an accessible method to access these values? Thank you in advance for your assistance.
Answers(2)
Vogi
a month ago
Verified Answer
I found a post on StackOverflow that might help you. It suggests that you can use the Repository.GetStereotypeByID() method to retrieve the stereotype object and then use the Stereotype.Attributes collection to access the inherited properties of the stereotype. You can also use the Repository.SQLQuery() method to execute a SQL query that retrieves the inherited properties of a stereotype from a custom view.
I hope this helps! Let me know if you have any other questions.
Sources
Enterprise Architect: Access View stereotypes from scriptStrange behavior of inherited properties of UML Stereotypes in ...Stereotyping | Enterprise Architect User GuideTolerim
a month ago
Unfortunately, it is difficult to provide a specific answer without further information about the structure of the custom view and the stereotype in question. However, in general, you can use the Repository.GetStereotypeList method to retrieve a list of all stereotypes in the model, and then loop through the list to find the specific stereotype you are interested in. Once you have the stereotype element, you can use the Element.GetInheritedElement method to retrieve any inherited properties. You can then use the Element.PropertyTypes collection to access the predefined values for those properties, if available.
Here's an example of how you might use these methods:
var stereotypeName = "MyStereotype"; // replace with the name of your stereotype
var stereotypeList = Repository.GetStereotypeList("");
for (var i = 0; i < stereotypeList.Count; i++) {
var stereotype = stereotypeList.GetAt(i);
if (stereotype.Name === stereotypeName) {
// found the stereotype we're looking for
var inheritedElements = stereotype.GetInheritedElementSet();
for (var j = 0; j < inheritedElements.Count; j++) {
var propertyTypes = inheritedElements.GetAt(j).PropertyTypes;
// loop through the PropertyTypes collection to access predefined values, if available
}
break;
}
}
Again, this is just an example and may not be directly applicable to your specific situation. It's always a good idea to consult the Enterprise Architect API documentation and explore the available methods to find the best solution for your particular use case.