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.


Topics - Ribeye

Pages: [1]
1
My C# plugin is using EA_OnPostNewConnector to trap when the user creates a new connection, obviously.

One of the nice features of EA is that it allows the user to create a connection from an Attribute of a Class, not just a Class. You select the Attribute and drag from the { that pops up to the target Class.

From within EA_OnPostNewConnector I get the Connection that has been created by the user from the EA.EventProperties eventProperties parameter of EA_OnPostNewConnector.

     repository.GetConnectorByID(eventProperty.value) does the trick.

To test if the Connection is from an Attribute, I am expecting newConnector.StyleEx to have the Attribute details.

But I am seeing ""

I am seeing only one EventProperty in EventProperties, so the Attribute details are not there.

Question: within EA_OnPostNewConnector, how do I find the Attribute end, if the Connection has an Attribute end, not a Class end?


2
Normally I would use Visual Studio IDE to write C# plugins. Works well.

But being behind someone's firewall means I don't have access to Visual Studio IDE. They do have Visual Studio Code.

I see elsewhere https://sparxsystems.com/forums/smf/index.php/topic,46362.msg271355.html#msg271355 it says
"Visual Studio Code does not have a compatible API"

Does anyone have a work around, some way to use Visual Studio Code to write a plugin?

3
I am building a report using Report Builder.

One component of the report requires selecting Diagrams using SQL. I can then use "Insert customer field" to output the Name and Notes etc. All good.

But I also need to output the Diagram Image. Cant find how to do that.

Can someone advise on approach?

Thanks

 

4
I need my plugin to apply a stereotype to new diagrams. For that it needs to add a Diagram Note element to the diagram.

To add a Diagram Note element I am following
* Add Text element to a Diagram: the Scripting EA book, section "Adding special objects" to diagrams.
* Make a text element a Diagram Note: https://sparxsystems.com/forums/smf/index.php?topic=37907.0

My resulting code is:

        public static void addDiagramNoteToDiagram(Diagram diagram, Package myPackage, Repository repository)
        {
            Element text = myPackage.Elements.AddNew("", "Text");
            String vbCrLf = ((char)13).ToString() + ((char)10).ToString();
            String nnn = "Name: " + diagram.Name + vbCrLf + "Author: " + diagram.Author + vbCrLf + "Version: " + diagram.Version + vbCrLf + "Created: " + diagram.CreatedDate + vbCrLf + "Updated: " + diagram.ModifiedDate;
            text.Notes = nnn;
            text.Subtype = 18;
            text.Update();
            string pos = "l=200;r=300;t=-20;b=-40";
            dynamic dia_obj = diagram.DiagramObjects.AddNew(pos, "");
            diagram.Update();
            dia_obj.ElementID = text.ElementID;
            dia_obj.Update();
            repository.ReloadDiagram(diagram.DiagramID);
        }
       
The text Element is created fine.

but nothing is added to diagram.DiagramObjects by the line

   dynamic dia_obj = diagram.DiagramObjects.AddNew(pos, "");

When walking through in debug mode, diagram.DiagramObjects.count remains at 0 at all times.

When I open the diagram the note element is showing, which I dont get.

But my code which gets the Diagram Note does not find it.

        // get the diagram element which will hold the Stereotype
        public Element getMyDiagramsElement(Repository repository)
        {
                Collection diagramObjects = myElement.DiagramObjects; // myElement is a Diagram property of the non static class
                foreach (DiagramObject o in diagramObjects)
                {
                    int eid = o.ElementID;
                    Element element = repository.GetElementByID(eid);
                    if (element.MetaType.Contains("Text"))
                    {
                        return element;
                    }
                }
                return null;
            }

        }

When the Diagram Note is added manually, through the front end, this code works fine.

Why does getMyDiagramsElement() work for manually added Diagram Notes and not for the addDiagramNoteToDiagram() method way?

Note: If I re-run the code it looks like the Diagram Note is there? So I tried adding
       repository.SaveDiagram(diagram.DiagramID);
at various places, as suggested by Scripting EA, but could not make it make a difference.


5
I have a profile, diagram and toolbox defined in my MDG.

When a user drags one of the stereotypes from the toolbox onto the diagram we need to trigger some behaviour. Specifically to set the value of one or more of the tags from the stereotype. In the future that could be other functions, like asking the user for more info.

Have searched sparx docs, SO and Thomas Killans books with no luck.

This must be a common requirement - what have I missed?


6
General Board / Hide Link Labels - how to in bulk and by default
« on: November 18, 2023, 04:42:03 pm »
How do you hide Link Labels on Diagrams? Not one by one, but in bulk for an existing diagram, and so they default to hidden on create?

This must be a common requirement,  but I cant find the how anywhere.

The closest is https://sparxsystems.com/forums/smf/index.php/topic,18878.msg177483.html#msg177483 but its not an actual answer.


7
I am looking to add Diagram stereotype and to set / get tags values in my C# code.

It quickly becomes obvious there is no native methods on Diagram class for this. There is a helpful conversation on this problem here https://sparxsystems.com/forums/smf/index.php/topic,46478.msg271861.html#msg271861

There is a quote of Paulo "As described elsewhere, we have adopted the convention to use the diagram title block (the misnamed Diagram Element Note in Sparxian) to act as a proxy for the diagram."

Have spent too long googling and looking at EA books - where is "diagram title block / misnamed Diagram Element Note"? Cant find documentation, let alone reference in API docs

Thanks

8
We need to find elements in our model by the value of Tags. Foreign keys to external systems, for example.

This seems like a common requirement and we are new to EA SQL.

Can someone point to or provide a snippet of SQL that will do this?

Thanks in advance.

9
My C# v7.3 plugins are working fine.

But I need to upgrade to C# 8.0+ (Visual Basic is saying you need this to get interface default methods)

Being new to C# and EA plugin development I dont know:

- will updating the C# version will break my installation?
- what about the new 64bit version - can we use the current DDL files in 64bit EA?
- Presumably a 64bit DDL would not run on a 32bit version of EA?
- Where is the documentation on these issues? Spent 45 min looking with no luck.

10
I am successfully assigning stereotypes to elements I am creating in C#.

When it comes to setting values of tags that the stereotype has I am failing.

I copied code from https://sparxsystems.com/forums/smf/index.php?topic=6097.0 but it is creating new tags, not setting the tag values of the stereotype.

I cant find example code anywhere.

Here is that I have come to.
        // https://sparxsystems.com/forums/smf/index.php?topic=6097.0
        public static bool addTaggedValue(EA.Element elementParam, string tagName, string value)
        {
            TaggedValue tag = elementParam.TaggedValuesEx.GetByName(tagName);
            if (tag == null)
            {
                TaggedValue element = elementParam.TaggedValuesEx.AddNew(tagName, value);
                element.Value = value;
                element.Update(); //must be executed in order to save new tagged value
                elementParam.Update(); // is it needed?
                elementParam.TaggedValues.Refresh();
                String debugString = element.FQName; // always ""
                return true;
            }
            tag.Value = value;
            tag.Update();
            elementParam.Update(); // is it needed?
            elementParam.TaggedValues.Refresh();
            return false;
        }

11
I am writing C# plugins using Visual Studio.

On my plugins menu I would like to have a menu item that triggers the Develop -> Data Modeling -> Import function.

How do you trigger standard EA menu items from C#?
 

12
I have:

a) created some add-ins - they appear under Specialize -> Addins. Look good. The <<javascriptAddin>> class has both EA_GetMenuItems and EA_MenuClick, which are working fine.

b) written some javascript scripts using functions under Specialize -> Javascript Library. They are also running fine.

Now I want to execute my b) javascript scripts from by a) menu items.

How do you do this?

I have search everywhere for an answer with no luck. I tried syntax like

 !INC Local Scripts.EAConstants-JScript

as it is used b) javascripts, but this causes a) EA_MenuClick javascript to throw a syntax error
2)

 

Pages: [1]