Book a Demo

Author Topic: Example of shapescript calling to addin function?  (Read 3257 times)

Robert Kowalchuk

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Example of shapescript calling to addin function?
« on: August 22, 2015, 07:07:03 am »
I can't seem to get a shapescript make a call to a function in an add-in.  I am trying to determine if an element is used by more than one diagram.  If so we considered it a share element and want to display a symbol of some kind using shapescript.

To do this I believe we will need to have the shape script make a call to the addin via #ADDIN:MyAddin:MyFunc:Parms# as indicated by the user guide.  Does anyone or does the EAExample.EAP have a working example that I can reference?  The documentation is a little light on that particular topic.

NOTE:  We are using v11

Thanks,
Rob
« Last Edit: August 22, 2015, 07:07:30 am by geekoid »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Example of shapescript calling to addin functi
« Reply #1 on: August 22, 2015, 08:28:18 am »
There are no public examples. However, I once did a test and had no big issues getting it to run.

q.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Example of shapescript calling to addin functi
« Reply #2 on: August 24, 2015, 05:19:53 pm »
Hi Rob,


Let's say you've got this in your shape script:
       print("#addin:AddInRegKey, MethodName#");

AddInRegKey then has to match the name of the Add-In as listed in the registry under HKCU\Software\Sparx Systems\EAAddins. (I think this is the same as the name shown in the Extensions -- Manage Add-Ins dialog).

In the main class of your Add-In (as specified by the same registry key), you need a method with the following signature:
       public string MethodName(Repository repository, string elementGuid, Object args)

First thing in there, if you're passing arguments, is to cast args. If you want to pass more than one argument, cast args to an Object array, then cast each argument in turn. If you're not passing any arguments, you still need the dummy parameter in the method signature.

Please note that doing a lot of Add-In calls in a shape script can have a significant performance impact, especially in a networked environment, so it's a good idea to write the method with an eye to performance.

HTH,


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