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

Pages: [1] 2
1
Great, thanks!

2
I want to find any actions that are associated with a selected operation. I know I can do this from properties | call :: behavior in the GUI from the action-side, but how do I do it from my C# addin and from the operation side of things? I suspect a SQL query would help (it seems to always be the answer) but I'm not certain how or where that connection would be stored -- the only reference to behavior I see in the SQL schema are t_xref's, are those what I'm looking for?

I created the action by dragging the operation into a diagram, but aside from the call in the action's properties (seen via the GUI) I don't see a way of tracking it down given only the operation's identity -- how is that information stored in EA's schema, or is there a simpler way to make that connection on the addin side than delving into SQL queries?

We're trying to associate requirements with individual operations and we figured this would be the way to go, but I can't figure out how to trace the relationship!

Thanks!

3
Automation Interface, Add-Ins and Tools / Re: EXEC_ADD_IN
« on: February 24, 2012, 05:37:22 am »
Additionally the

Code: [Select]
public object getRequirementsList(EA.Repository repo, object arghs)

Is the correct constructor, after which your arguments should be cast into an array of strings (string[]).

4
Automation Interface, Add-Ins and Tools / Re: EXEC_ADD_IN
« on: February 23, 2012, 08:53:58 am »
Heard back from Sparx support and I was referencing the addin wrong in the macro -- you've got to use the full name as defined in the registry under HKEY_CURRENT_USER\Software\Sparx Systems\EAAddins . Don't know why I thought the regular name would work!

5
Automation Interface, Add-Ins and Tools / EXEC_ADD_IN
« on: February 22, 2012, 06:04:58 am »
Hi all,

I'm trying to use the EXEC_ADD_IN macro in the Code Template Editor ( http://www.sparxsystems.com/enterprise_architect_user_guide/modeling_languages/functionmacros.html ), but I can't figure out how to implement it in a C# addin. I've tried defining the function to be accessed in a few ways, the most obvious being:

Code: [Select]
public string getRequirementsList(EA.Repository repo, string[] args)
and

Code: [Select]
public object getRequirementsList(EA.Repository repo, object arghs)
but neither seems to even get called when I try to use the macro

Code: [Select]
$reqs = %EXEC_ADD_IN("My Addin", "getRequirementsList", opGUID)%
Anyone played with this before? Thanks for your help!

6
A further question: I'm trying to determine what Action elements call my selected operation as a behavior. Where in the database structure is that information stored?

7
Phew, thanks! That was holding me up.

8
Sorry if this is an obvious question, but EA isn't the most transparent environment.

I have an interface with a few child operations and I want to get access to those operations in my addin (and eventually the behaviors associated with those operations).

I get the selected object in my addin ok, but when I try to cast it to an EA.Element object I am informed that that is not the correct type -- what IS the correct type? When I look at the properties I see that the interface and its operations are all of Type Interface, and when I cast the parent as an EA.Element object it works fine, but I can't find any EA types to cast the operations to that will work. Help!

9
Thanks, that did the trick!

I assume all this is gleaned from the database structure and painful experience, or is there some hidden documentation I haven't found yet?

10
I'm trying to get a taggedvalue from a couple thousand requirements, which becomes cumbersome pretty quickly when I have to build the elements and parse through EA.Collection structures. I'm trying to use SQLQuery to get directly to the tagged values with something like:

Code: [Select]
"SELECT TagValue FROM t_taggedvalue WHERE ElementID  = <<requirement_element_id>>;"
 Suffice to say this doesn't work. Even when I do a general query like
Code: [Select]
"SELECT * FROM t_taggedvalue;"  I only get a few hundred results. Given that there are a few thousand requirements which all have 10+ taggedvalues associated with them this can't be right, so what am I doing wrong? When I rebuild the tags like so:

Code: [Select]
EA.Element currReq = (EA.Element)Repository.GetElementByID(objID);
EA.Collection tags = (currReq.TaggedValues);
EA.TaggedValue tag = (EA.TaggedValue)tags.GetByName("Status");

I get all the information I need, so I know the information is stored in a taggedValue, I must just be doing something wrong. Any tips for doing this by query?

11
All I want to do is script the addition of a connector to an element, then the addition of that element to a diagram. When I load the diagram after running my script, I see the element all right but there's no connector. What am I missing? I've tried editing other Connector attributes but no luck.

The c variable is the old Connector I want to base my new one on.
The Elements variable is the collection of ElementObjects in the Diagram.

Code: [Select]
Dim NewElement, AddingElement, NewConnectors, NewConn
Set NewElement = GetElementByGuid("{6DFB6497-AAE6-4a9f-90CE-2F86F8E9D542}")
c.SupplierID = NewElement.ElementID
                                          
NewConnectors = NewElement.Connectors
NewConn = NewConnectors.AddNew(c.Name, "Dependency")
NewConn.SupplierID = NewElement.ElementID
NewConn.ClientID = c.ClientID
NewConn.Stereotype = "deriveReqt"
NewConn.Update
                                          
Set AddingElement = Elements.AddNew(NewElement.Name, "")
AddingElement.ElementID = NewElement.ElementID
AddingElement.Update()

GetProjectInterface().LayoutDiagramEx Diagram.DiagramGUID, EA.ConstLayoutStyles.lsDiagramDefault, 8, 50, 50, true
ReloadDiagram(Diagram.DiagramID)

From what I've seen all I need to do is set the stereotype and sources, which I've done. What am I doing wrong?

EDIT: Appears I was overloading AddingElement = Elements.AddNew(NewElement.Name, "") , it didn't actually need a name. Also EA.ConstLayoutStyles.lsDiagramDefault, 8, 50, 50, true takes GetProjectInterface().LayoutDiagramEx Diagram.DiagramGUID, 0, 8, 50, 50, true instead; I guess the script doesn't like the layoutstyle stuff as much as addins do. Thanks Geert!

12
Geert: Thanks, that does exactly what I need!

When I posted this thread I also submitted a support query and they were kind enough to send me a full VB solution script:

Code: [Select]
option explicit

'!INC Local Scripts.EAConstants-VBScript

sub main
    Dim CurrentElement
    Dim i, DiagramIDs
    
    Set CurrentElement = GetContextObject
    DiagramIDs = FindInDiagrams(CurrentElement)
    
    If UBound(DiagramIDs) > 0 Then
        Session.Output CurrentElement.Type & " '" & CurrentElement.Name & "' appears on " & UBound(DiagramIDs) & " diagrams."
        For i = 1 To UBound(DiagramIDs)
            Dim Diagram, id
            id = DiagramIDs(i)
            Set Diagram = GetDiagramByID(id)
            Session.Output "Diagram #" & i & ": " & Diagram.Name
        Next
    Else
        Session.Output CurrentElement.Type & " '" & CurrentElement.Name & "' does not appear on any diagrams."
    End If
end sub

'returns array of diagram ids where diagram contains the specified element
Function FindInDiagrams(Element)
    Dim sql, xml, ids(), count
    Dim doc, rows, row

    Set doc = CreateObject("MSXML2.DOMDocument")

    sql = "SELECT Diagram_ID FROM t_diagramobjects WHERE Object_ID = " & Element.ElementID
    
    xml = SQLQuery(sql)
    
    count = 0
    ReDim ids(0)
    
    If doc.loadXML(xml) Then
        Set rows = doc.selectNodes("//EADATA//Dataset_0//Data//Row")
        For Each row In rows
            count = count + 1
            redim preserve ids(count)
            ids(count) = row.selectSingleNode("Diagram_ID").Text
        Next
    End If
    
    FindInDiagrams = ids
End Function


main

Problem solved!

13
I want to make a very simple script which will step through the diagrams that include a specific element and alter them. However I can't seem to find a simple API version of the 'Find in all Diagrams' GUI functionality (described here: http://www.sparxsystems.com/uml_tool_guide/modeling_tool_features/addingobjectlinks.htm), which is exactly the list of diagrams I need to get. I tried simply using the Element.Diagrams property but that didn't seem to give me what I wanted; is there a way of doing this short of parsing through every package in my script? Just trying to avoid making a long script, figured this should be doable. Thanks!

14
Quote
I think you've missed a semi-colon...

Quote
diagram.StyleEx = "ShowNotes=1[highlight];[/highlight]";
diagram.Update();

it seems to work both ways -- could anything terrible happen if I forget to close the last styling option?

15
Nevermind, I found it in the user manual:

Code: [Select]
diagram.StyleEx = "ShowNotes=1";
diagram.Update();

http://www.sparxsystems.com/enterprise_architect_user_guide/8.0/modeling_languages/attribute_values___stylex__pda.html

Pages: [1] 2