Book a Demo

Author Topic: Custom elements  (Read 7106 times)

damien

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
    • View Profile
Custom elements
« on: May 14, 2008, 12:19:18 am »
Hello,

I have two quesions

First, when i create an element that i define in my technology, the size of the element wasn't the same. How can i define the size of my element in a diagram? I search in the help but i haven't see a method to do it.

The second question is can i copy an element from a package to an another package ?

Thank you
Bye


Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Custom elements
« Reply #1 on: May 14, 2008, 08:04:40 am »
You can set the size in your profile.  (Add attributes _sizeX and _sizeY)

http://www.sparxsystems.com.au/EAUserGuide/index.html?supportedattributes_2.htm

damien

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
    • View Profile
Re: Custom elements
« Reply #2 on: May 14, 2008, 05:03:04 pm »
Thank for your answer

I already set the size in my profile with _sizeX and _sizeY.
But when i create an element of my profile with my add-in, the size that i define in my profile isn't applied to this element
I look in the Element class and in the DiagramObject class but i see not parameters to set it.
Someone can help me please ?

Thanks you
Bye
« Last Edit: May 14, 2008, 05:07:36 pm by damien »

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: Custom elements
« Reply #3 on: May 14, 2008, 05:37:12 pm »
That's a common problem: EA automation doesn't give a damn what is defined in a profile. You add an element with a profile stereotype via automation, but no tagged values are being created. You add it to diagram and it gets the default size for the underlying metaclass, not matter what your profile says. Seems like you have to do it all yourself.

I don't see properties for the size in the the DiagramObject either. Guess you have to use the Bottom and Right properties.

By the way: I just noticed a kind of cencorship in this forum. I wrote "doesn't give a d-a-m-n" and it was automatically changed to "darn" in preview. Event within a code tag the indicated word will be changed to "darn".

Which pc buggers have written this bleeding forum software? Americans, obviously, or the last sentence wouldn't have passed either.

damien

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
    • View Profile
Re: Custom elements
« Reply #4 on: May 14, 2008, 09:08:28 pm »
I try to define the position of an element with

DiagramObject.Bottom
DiagramObject.Top
DiagramObject.Right
DiagramObject.Left

But the new element is always in the Upper Right Corner :(
I don't understand why.
My code is :

Sub UpdateActionsPlans(ByVal Repository As EA.Repository, ByVal Client As EA.Element, ByVal Supplier As EA.Element)

        Dim Diagram As EA.Diagram
        Dim DiagramObject As EA.DiagramObject

        Diagram = Client.Diagrams.GetByName(Client.Name)
        DiagramObject = Diagram.DiagramObjects.AddNew(Supplier.Name, Supplier.Type)
        DiagramObject.ElementID = Supplier.ElementID
        DiagramObject.right = 100
        DiagramObject.top = 100
        DiagramObject.left = 200
        DiagramObject.bottom = 200
        DiagramObject.Update()
        Diagram.DiagramObjects.Refresh()
        Repository.ReloadDiagram(Diagram.DiagramID)

End Sub


« Last Edit: May 14, 2008, 09:13:01 pm by damien »

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Custom elements
« Reply #5 on: May 14, 2008, 10:12:31 pm »
Create an element by hand, then inspect the database to get the top, bottom, left and right coordinates.

EA handles these numbers in a truly strange manner. You'll probably pick it up fairly quickly; understanding it is another matter entirely.
No, you can't have it!

damien

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
    • View Profile
Re: Custom elements
« Reply #6 on: May 14, 2008, 11:46:41 pm »
i manage to resize an element, i don't know why but when i try :

DiagramObject = Diagram.DiagramObjects.AddNew(Supplier.Name, Supplier.Type)
DiagramObject.ElementID = Supplier.ElementID
DiagramObject.left = 10
DiagramObject.right = 135
DiagramObject.top = 10
DiagramObject.bottom = 70
DiagramObject.Update()
Diagram.DiagramObjects.Refresh()

Nothing change but i manage to resize with this code :

DiagramObject = Diagram.DiagramObjects.AddNew("l=10;r=135;t=10;b=70;", Supplier.Type)
DiagramObject.ElementID = Supplier.ElementID
DiagramObject.Update()
Diagram.DiagramObjects.Refresh()

Now if someone knows how to cut an element from a package and paste it to another, i interested ^^
« Last Edit: May 14, 2008, 11:49:07 pm by damien »

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Custom elements
« Reply #7 on: May 15, 2008, 03:13:38 am »
Now that you've done that, query the diagram to get the various coordinates. I think you'll find that the y direction uses negative numbers, perhaps as an offset from the bottom.

I just don't remember the details, and don't have time to whip something up to check it just now. You certainly need to set the coordinates for one axis in negative numbers when you position the object in code.

[If you get the hang of it please post back, so others don't have to deal with my failing memory on the subject...]

David
No, you can't have it!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Custom elements
« Reply #8 on: May 15, 2008, 09:17:01 am »
EA uses a cartesian coordinate system with the origin being at the top left of the diagram.  This means that x coordinates are positive, and y coordinates are negative.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Custom elements
« Reply #9 on: May 15, 2008, 07:58:44 pm »
Thanks Simon,

And sometimes starts new elements out with 'strange' coordinates to indicate a default position (or something). Could you please shed light on this Simon?

Oh yes, could you please tell us the units EA uses as well? Is it twips, or something else?

David
« Last Edit: May 15, 2008, 07:59:50 pm by Midnight »
No, you can't have it!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Custom elements
« Reply #10 on: May 16, 2008, 08:29:03 am »
I'm not sure about strange coordinates as defaults.  You'll have to describe them.

The units are pixels at 100% zoom.