Book a Demo

Author Topic: Add in / Script Menu  (Read 6727 times)

Monsieur

  • EA User
  • **
  • Posts: 142
  • Karma: +0/-0
    • View Profile
Add in / Script Menu
« on: March 06, 2015, 02:41:59 am »
Hello all,

Dumb question from a dumb man [smiley=2vrolijk_08.gif] [smiley=2vrolijk_08.gif]:

[size=16]How do I add my script to a menu? [/size]

(for example right click on a diagram>script>myscript)

and last but not least... How do I add my script to a menu depending on a local context? (right click on a digram different than right click on Project Browser tree)

I am talking about js or vb script that you can see in the Scripting window

M.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Add in / Script Menu
« Reply #1 on: March 06, 2015, 03:13:59 am »
Not a dumb question at all. It's not part of the script as such, it's in the script group.

What you do is you create a script group (in the Scripting window, leftmost icon), and select a Project Browser or a Diagram group. Scripts placed in groups of either of these types are automatically placed in the corresponding browser / diagram context menus. Ta-daa! :)

You should also create the scripts inside the groups, not move them in from a regular group. That probably won't work. (But you can write small wrapper scripts in the browser / diagram groups, and call larger scripts in normal groups.)

HTH,


/Uffe
My theories are always correct, just apply them to the right reality.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Add in / Script Menu
« Reply #2 on: March 06, 2015, 05:57:32 pm »
Quote
You should also create the scripts inside the groups, not move them in from a regular group. That probably won't work.
/Uffe
It does word, but the default template for a new script is different for each group.
Other then that it just executes the whole script when the menu option is chosen.

If you want more control on how and when a menu option should appear you can use EA-Matic. See Using the add-in menu with EA-Matic for an example.

Geert

Monsieur

  • EA User
  • **
  • Posts: 142
  • Karma: +0/-0
    • View Profile
Re: Add in / Script Menu
« Reply #3 on: March 06, 2015, 07:27:20 pm »
Quote
Not a dumb question at all. It's not part of the script as such, it's in the script group.

What you do is you create a script group (in the Scripting window, leftmost icon), and select a Project Browser or a Diagram group. Scripts placed in groups of either of these types are automatically placed in the corresponding browser / diagram context menus. Ta-daa! :)

You should also create the scripts inside the groups, not move them in from a regular group. That probably won't work. (But you can write small wrapper scripts in the browser / diagram groups, and call larger scripts in normal groups.)

HTH,


/Uffe
Okay, i am dumb, i saw those groups and use them as such without noticing that they where doing the job (i thought those groups where only there to load some library or else)



Quote
Quote
You should also create the scripts inside the groups, not move them in from a regular group. That probably won't work.
/Uffe
It does word, but the default template for a new script is different for each group.
Other then that it just executes the whole script when the menu option is chosen.

If you want more control on how and when a menu option should appear you can use EA-Matic. See Using the add-in menu with EA-Matic for an example.

Geert
Yeah! i saw this add-in and it seem working just fine, i'll give it a try when i will developp on action scripts (for now they are just on content, manually exectutable scripts)

Thank you both for your fast reply!
« Last Edit: March 06, 2015, 07:28:08 pm by damien.reche »

Monsieur

  • EA User
  • **
  • Posts: 142
  • Karma: +0/-0
    • View Profile
Re: Add in / Script Menu
« Reply #4 on: March 06, 2015, 07:48:41 pm »
One verrrrrrrrrrrrrrry last question...  [smiley=thumbsup.gif]  [smiley=tekst-toppie.gif]

[size=16]Is there a may to add a sub menu to my menu?[/size]

something like :
right click >scripting >submenu 1 > script 1
                                                 > script 2
                              >submenu 2 > script 3
                              ...

M



Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Add in / Script Menu
« Reply #5 on: March 06, 2015, 08:44:47 pm »
I don't think you can add sub-menu's in the scripting context menu.

To be able to do that you need the Add-in menu, which you can access using a "real" add-in, or using EA-Matic, but not from the scripts themselves.

Geert

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Add in / Script Menu
« Reply #6 on: March 06, 2015, 11:36:45 pm »
No, I don't think you can do sub-menus in scripts either (but you can with Add-Ins).

If you deploy your scrips with an MDG Technology, they appear in their own group with the technology's name -- but that only works for "Normal" type scripts. You can't deploy browser / diagram scripts in an MDG Technology (as of EA 11, anyway).

/U
My theories are always correct, just apply them to the right reality.