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 - Ribeye

Pages: [1] 2
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
Thanks Geert. "its too hard to use Visual Studio Code" was my conclusion. If you say, it will be so for sure.

Thanks again.

3
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?

4
My answer to date is that you cant. Switched to Scripts, abandon Report Builder.

5
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

 

6
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.


7
General Board / Re: Hide Link Labels - how to in bulk and by default
« on: December 07, 2023, 10:28:22 am »
Thanks Sunshine, I now see the "show stereotype labels" option on the Connectors tab.

For my DLS Diagrams I tried setting this property on the diagram and re-generating my MDG. Unfortunately I am not seeing new diagrams of my type inheriting the "show stereotype labels" = off from it.

So presumably I should set using the code which sets up the diagram.

But where is the "show stereotype labels" on Connectors property in the documentation?

From the Object Model documentation for Diagram, here https://sparxsystems.com/enterprise_architect_user_guide/16.1/add-ins___scripting/diagram.html

I reviewed classes Diagram, DiagramLink and DiagramObject and could not find reference to it.


Thanks again.
 

8
Thanks Geert, a whole section of documentation I could not find. The sooner they replace me with an AI Bot the better!

9
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?


10
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.


11
As At 2023-10-14 I am seeing this bug in the latest version.

My question is how to do the casting from object to diagram? When I use

            Diagram diagramDynamic = (Diagram) repository.GetDiagramByGuid(testDiagramGUID);

I get Visual Studio saying

     Error   CS0656   Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.Binder.Convert'   

12
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

13
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.

14
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.

15
Thanks for the replies, they do help.

For anyone else looking to answer this question:

I came to believe the unique name of a tag is "profileName::stereotypeName::tagName"

So my method for adding / updated the tag of an EA.Element is:

        // https://sparxsystems.com/forums/smf/index.php?topic=6097.0
        public static bool addTaggedValue(EA.Element elementParam, string profileName, string stereotypeName, string tagName, string value)
        {
            String tagId = profileName + "::" + stereotypeName + "::" + tagName;
            TaggedValue tag = elementParam.TaggedValues.GetByName(tagId);
            if (tag == null)
            {
                TaggedValue element = elementParam.TaggedValues.AddNew(tagName, value);
                element.Value = value;
                element.Update(); //must be executed in order to save new tagged value
                return true;
            }
            tag.Value = value;
            tag.Update();
            return false;
        }


For EA.Attribute and other EA.element types I needed another version with exactly the same code but replacing  EA.Element with EA.Attribute. Could not find a way to generalise EA.Element and EA.Property!


Pages: [1] 2