Show Posts

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.


Messages - MalkContent

Pages: [1] 2
1
Hi.
After having some trouble deleting the new connector in it's OnPostNew Event (which is done by saving the diagram right after the deletion from its clients/suppliers Connectors collection - careful, you have to iterate through the clients/suppliers-package.diagrams and save all those, since connector.DiagramID is 0) - I still have trouble to modify the connectors direction.
The connector in question is a custom stereotype from a mdg technology which has .Direction = "Unspecified" by default. When I modify the direction in the OnPostNewConnector Event-Method I can see the chosen direction 'blink' up for a splitsecond and then it's set back to the default "Unspecified".
It really gives me some trouble since I can change stuff like name, stereotypes, etc. but not the direction (also deletion is a bit more troublesome than usual).

Any ideas would be appreciated =).

2
they already are set after using the element.diagrams.addnew(..) method
:/
also: they are set correclty ^^
Diagram.ParentID == ParentActivity.ElementID
Diagram.PackageID == ParenActivity.PackageID

both true

I have no idea what this is - I can add elements all I like without causing any trouble, but as soon as I add an element AND update it - BAM

EDIT:

I have the feeling it has to do with some complications between the Diagram Creation and the Method Creation process, but I am not sure.
When the Error occurs, the Element holding the new Operation does not refresh its Element.Methods collection by itself, the new Operation only appears in the treeview and cant be seen on the DiagramElement OR in the ElementOperationlist when rightclicking(in treeview or on diagram is irrelevant) and choosing "Operations".
Also the operations form is closed when the Error occurs.

Perhaps I am lucky enough to run into a bug again here ^^
Yay for me.
I am using EA v7.1.833

3
heres the whole method for you
I don't know whats left to try
The Problem still happens, even when I quote out everything after the diagram.update() (note that the code is fully functional, it just happens that EA crashes from time to time and always prompts the error; when it crashed, >every< changes I wanted to do are done and still there after restarting EA).

Code: [Select]
       public bool EA_OnPostNewMethod(EA.Repository Repository, EA.EventProperties Info)
        {
            EA.Method meth = Repository.GetMethodByID(int.Parse((string)Info.Get(0).Value));
            EA.Element methparent = Repository.GetElementByID(meth.ParentID);
            methparent.Refresh();
            if (methparent.Type.Equals("Class"))
            {
                EA.Package pack = Repository.GetPackageByID(methparent.PackageID);
                foreach (EA.Diagram diag in pack.Diagrams)
                    if(diag.MetaType.Equals("MOF Diagram::MOF Diagram"))
                    {
                        foreach(EA.DiagramObject diagobj in diag.DiagramObjects)
                            if (Repository.GetElementByID(diagobj.ElementID).ElementGUID.Equals(methparent.ElementGUID))
                            {
                                EA.Element fledgedDummy = (EA.Element)(methparent.Elements.AddNew(meth.Name, "Activity"));
                                fledgedDummy.Stereotype = "mofsdmDummyActivity";
                                fledgedDummy.StereotypeEx = "mofsdmDummyActivity";
                                fledgedDummy.Update();
                                EA.Diagram fledgedDiag = (EA.Diagram)(fledgedDummy.Diagrams.AddNew(meth.Name, "MOFSDM::mofsdmDiagram"));
                                fledgedDiag.ShowDetails = 0;
                                fledgedDiag.Update();
                                EA.Element fledgedStart = (EA.Element)fledgedDummy.Elements.AddNew("Start", "StateNode");
                                fledgedStart.Stereotype = "mofsdmStart";
                                fledgedStart.StereotypeEx = "mofsdmStart";
                                fledgedStart.Update();
                                EA.DiagramObject fledgedDObj = (EA.DiagramObject)fledgedDiag.DiagramObjects.AddNew("Start", null);
                                fledgedDObj.ElementID = fledgedStart.ElementID;
                                //fledgedDObj.left = 500;
                                //fledgedDObj.top = 100;
                                fledgedDObj.Update();
                                break;
                            }
                        return true;
                    }
            }
            return false;
        }

4
nope, still happens
tried it out with an "activity" type

5
hm, good point
I will look into that

6
Automation Interface, Add-Ins and Tools / Adding a diagram through code
« on: February 27, 2010, 04:28:46 am »
Hi.
I am having some problems adding a diagram to my model by code.
The diagram is added in the "EA_OnPostNewMethod" method and is added as a child of a class element.

This is my code:
Code: [Select]
                               EA.Diagram fledgedDiag = (EA.Diagram)(methparent.Diagrams.AddNew(meth.Name, "MOFSDM::mofsdmDiagram"));
                                fledgedDiag.Update();
                                methparent.Diagrams.Refresh();
                                methparent.Refresh();
                                package.Diagrams.Refresh();
                                package.Elements.Refresh();

methparent is the class element which the method is added to, meth is the new method and package is the package which methparent is located in.

Now to my problem:
It works - but it keeps stating the error "An invalid argument was encountered.".
The code which seems to be responsible for this error is "fledgedDiag.Update()" but the code doesn't work without it.

Did I mess up the order of refreshing/updating or did I forget something?

7
hooray ^^

8
that is my version exacly

but does this version already include EA_OnPostNewDiagram?

9
well seemingly this method doesn't exist OR I didn't find a way to get it called

here's my code example - c# in visual studio 2005 pe

Code: [Select]
       public bool EA_OnPostNewDiagram(EA.Repository Repository, EA.EventProperties Info)
        {
            MessageBox.Show("diagram created!");
            return true;
        }

I created a variation of diagrams AND I tried to get it called like the EA_OnPostNewDiagramObject method would which I also didn't succeed in.

also the help contents only list an entry for EA_OnPostNewDiagram (Object) which - in the details - is then titled EA_OnPostNewDiagram and has a description which makes it pretty much sound like EA_OnPostNewDiagramObject:

Quote
Details

EA_OnPostNewDiagram notifies Add-Ins that a new object has been created on a diagram. It enables Add-Ins to modify the object upon creation.

This event occurs after a user has dragged a new object from the Enterprise Architect Project Browser or Resources window onto a diagram. The notification is provided immediately after the object is added to the diagram. Set Repository.SuppressEADialogs to true to suppress Enterprise Architect from showing its default dialogs.

Also look at EA_OnPreNewDiagram.

I am using EA v7.1 Academic.

10
So is there no way to create a new element in the repository upon diagram creation? :(

11
I just realized that the EA_OnPostNewDiagramm event doesn't occur after a Diagram has been created, but an object within a diagram, so I am now without a clue how to add standard elements to a diagram on it's creation.
:(

12
I want to add a "ActivityInitial" with the stereotype "mofsdmStart".
It is part of a custom ToolBox I build.

I am not sure if this is what you mean :/

13
I want to create an instance of a certain element when I create the instance of a specific diagram.
I already have the creation event of the diagram.
Problem is, I have no idea which methods of the repository to use to create a new instance of an element.

14
Hi,
I am currently trying to get a self made diagram (done via diagram profile) to add an element to the repository when an instance of it is created.

Is there a possibility to make it happen via profile editing?
And if not:
-how do I create Elements in the Repository
-how do I add Elements to the Diagram

I honestly searched a lot for the element creation and adding to a diagram thing and I tried a few things, but so far no luck.

EA.Element doesn't seem to posess a visible creator so I guessed it only could be added by methods of the Repository.

And as for the adding it to the diagram part, I am guessing it's done via the elements taggedvalues attribute, but I am not sure and don't know how it would be done.

Help :(

15
yes it triggers the event, yes the parentID is not zero

still - it's not very satisfying ^^

Pages: [1] 2