1
Automation Interface, Add-Ins and Tools / Re: TaggedValues : add value
« on: April 11, 2019, 10:54:36 pm »
It's work.
I didn't see this attribute.
Ty again.
I didn't see this attribute.
Ty again.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
EA.Method method = (EA.Method)currentMbdClass.Methods.GetAt(0);
foreach (EA.TaggedValue tag in method.TaggedValues)
{
//Do Something
}
and I have this error : "Unable to cast COM object of type'System_ComObject' to interface type 'EA.TaggedValue'"newAttribute.StereotypeEx = "University::New";
newAttribute.Update();
newAttribute.StereotypeEx = "University::Data";
newAttribute.Update();
//newAttribute.Stereotype = newAttribute.StereotypeEx;
Use StereotypeEx for every time you want to write a stereotype.
•Use HasStereotype() for every time you want to check a stereotype.
•Edge cases for appending a stereotype to the existing list or checking for any stereotype both use StereotypeEx.
•FQStereotype is read only. It allows you to see the profile the first stereotype applied comes from.
•MetaType allows you to get the Metatype defined for an applied stereotype. (It's not read only, but it ignores any assignment)
•SynchTaggedValues() should be automatic when assigning a stereotype. It's useful if the stereotype definition has been updated or tags accidentally deleted
attribute.Stereotype = "New";
//attribute.Stereotype = "enum"; will erase the old value and I want just add it
//EA.Element currentElement; // My component.
//EA.Element Elport; // My port.
//EA.Element myInterface;
EA.Element Elport = (EA.Element)currentElement.Elements.GetByName("Port2");
EA.Element myInterface = (EA.Element)currentPackage.Elements.GetByName("IMyMBD");
EA.Collection diagCollection = (EA.Collection)currentDiagram.DiagramObjects;
EA.DiagramObject DiagObj = (EA.DiagramObject)diagCollection.AddNew("", "Interface");
DiagObj.ElementID = Elport.ElementID;
DiagObj.Update();// triggers error
eARepository.ReloadDiagram(currentDiagram.DiagramID);
EA.Element item = (EA.Element)newPort1.EmbeddedElements.AddNew("", "ProvidedInterface");
item.Update();
var diagramItem = (EA.DiagramObject)currentCmpDiagram.DiagramObjects.AddNew("", "");
diagramItem.ElementID = item.ElementID;
diagramItem.Update();
newPort1.Update();
currentCmpDiagram.Update();
currentPackage.Update();
eARepository.ReloadDiagram(currentCmpDiagram.DiagramID);
EA.Diagram curentDiagram; // Diagram wich contains my component.
EA.Element currentElement; // My component.
EA.Element Elport; // My port.
EA.Element myInterface;
EA.Element myInterface = (EA.Element)currentPackage.Elements.GetByName("IMyMBD");
var DiagObj = (EA.DiagramObject)currentDiagram.DiagramObjects.AddNew("", "");
DiagObj.ElementID = port2.ElementID;
DiagObj.Update(); // this triggers an error : System.Runtime.InteropServices.COMException
EA.Element interface = (EA.Element)currentPackage.Elements.GetByName("IMyMBD");// I use GetByName just for the example
int potoid = interface.ElementID;
EA.Element port2 = (EA.Element)currentElement.Elements.GetByName("Port2");
EA.Element inter = (EA.Element)port2.Elements.AddNew("", "RequiredInterface");
inter.ClassfierID = potoid;
inter.Update();
inter.Refresh();
var oto = (EA.Element)port1.EmbeddedElements.AddNew("", "RequiredPort");
oto.ElementID = poto.ElementID;
EA.Element item = (EA.Element)currentPackage.Elements.AddNew("cmp1", "Component");
GetByName only works for a limited set of EA.Collections.
But I wouldn't use it anyway if I were you. It will only return the "first" element with the given name, but you don't know in which order that will be.
Better to pretend GetByName doesn't exist and always "for each" the collection and test for the name.
Geert
What is "the same problem"? Any error messages?
q.
if (element.Attributes.GetByName(o) != null)
if (element.Attributes.GetByName(o) != null)