Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: OpenIT Solutions on December 12, 2014, 08:39:09 pm
-
Hi,
I'm trying to invoke an Addin from my shapescript. I've followed Geerts excellent example. I believe my add-in is registered ok. It should just return a test String - "Test". But I get nothing. I'm not sure if the code in my shapescript is correct, can someone validate:
println ("#ADDIN:RelationshipAddIn, GetRelationships, Application#");
Here
- RelationshipAddIn is the name of my "Class", should it be the name of the assembly/project ? Which would be dbSparxRelationshipAddIn
- GetRelationships is the Public method in my Add In. It has this signature:
public String GetRelationships(EA.Repository repo, String guid, String[] args)
{
return "Test";
}
Any thoughts, suggestions appreciated.
Regards,
Jon.
-
Hi,
Update on this - the issue turned out to be with the fact that I was staring Sparx via the MS Application Virtualization Client. It doesn't use the standard keys in the local registry for Sparx.
When I started Sparx locally the Addin was found and invoked. FYI
println ("#ADDIN:dbSparxRelationshipAddIn, GetRelationships, Application#");
Kind of works. I'm now getting an error dialogue in sparx informing me that the parameters for GetRelationships are invalid. I've tried String[] and Object[]. Same error.
Any suggestions what my final parameter type should be ?
Regards,
Jon.
-
Hi,
The "AddIn" part of the argument should be the name of the Add-In. This is not the name of the main class, nor the project/solution, but the assembly name.
If you don't have the source handy you can check the menu under Extensions -- Manage Add-Ins, that should give you the correct name.
As to the method signature, strictly speaking the third argument should be an object rather than a string[] but I think it'll work either way. Still, declaring it as object and performing the cast explicitly is more robust, and robust code is the only code worth writing (sorry, that's what fifteen years in the defence industry does to you...).
A simple way to check whether the call is coming through is to add a linerepository.WriteOutput("System", "GetRelationships() called", -1);
to your method. Remember to open the output tab in your test project, or call repository.EnsureOutputVisible(). Ahhh, the days of fprintf() debugging... :)
Finally, not to knock Geert's samples, but I strongly recommend that you do not allow Visual Studio to register the assembly for COM interop, but instead create an installer. Otherwise, since Studio does not automatically de-register when rebuilding (but an installer will deregister when uninstalling) you'll soon find your dev machine registry lousy with old registrations which can make debugging a far bigger PITA than it needs to be.
Ayone who's ever seen the above dialog complaining "Error - AddIn not found" knows what I'm on about.
/Uffe
-
Sorry, your update came in while I was crafting my eloquent, if not loquacious, reply. ;D
Try a plain object, rather than an object array.
/U
-
IIRC the methods receives a string collection (means you can use GetAt) and returns a string. So basically Uffe is right.
q.
-
Hi,
The solution that worked in the end was this method signature (in c#) :
public String GetRelationships(EA.Repository repo, String guid, params Object[] args)
{
String stereotype = ((string[])(args[0]))[0];
return stereotype;
}
Now to put some meat into the AddIn :-).....Thanks all for your help.
-
Thanks for sharing :-)
q.