Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: thomaskilian on September 24, 2004, 07:25:39 am

Title: Use Automation with PERL
Post by: thomaskilian on September 24, 2004, 07:25:39 am
Does anyone have an idea whether it is possible to use EA Automation interface with PERL? I think it should be feasible but I don't know how to make perl aware of EA's COM interface. Any help appreciated  :)
Title: Re: Use Automation with PERL
Post by: Bruno.Cossi on September 24, 2004, 07:41:37 am
Hi Thomas,

use Perl's Win32::OLE module and the methods NEW, GETOBJECT and GETACTIVEOBJECT. This way you can invoke any OLE/COM.

Hope this helps!
Bruno
Title: Re: Use Automation with PERL
Post by: thomaskilian on September 25, 2004, 12:16:34 pm
Thanks Bruno  :D I'll try that next week :)
BTW: The OLE smiley is nice  ;D
Title: Re: Use Automation with PERL
Post by: Bruno.Cossi on September 25, 2004, 01:10:57 pm
No problem Thomas, let me know how it went!
The OLE smiley took me by surprise. Sorry :-)

Bruno
Title: Re: Use Automation with PERL
Post by: thomaskilian on September 28, 2004, 08:42:37 am
Hi Bruno,
I found some time in the train to fiddle with PERL - again. Unfortunately half a year has gone since my last battle, so I forgot many things.
 $ea = Win32::OLE->new('EA.App');
actually creates an object, but I can't invoke any method or print any attribute. Any quick hint?
Title: Re: Use Automation with PERL
Post by: Bruno.Cossi on September 28, 2004, 10:04:54 am
Hi Thomas,

following your example, you need somthing like this:

print $ea->attributeormethod;

Much the same like in, say, Visual Basic, just instead of the dot notation, use ->

Hope this helps!

Bruno
Title: Re: Use Automation with PERL
Post by: thomaskilian on September 28, 2004, 03:01:52 pm
Hi Bruno,
that's exactly what I did, but it does not work. NEW delivers a scalar dereference in $ea and $ea->Repository also. But if I go further nothing is returned (result = undef). Probably I have to go into more detail with PERL. Thanks anyway - I'll be back with news as soon as I get it to work.
Title: Re: Use Automation with PERL
Post by: thomaskilian on September 29, 2004, 06:01:51 am
Hi Bruno,
at last I found the bug. You need EA.Repository not .App. :o
The following code sequence prints the top most package name:
Code: [Select]

use Win32::OLE;

$ex = Win32::OLE->new('EA.Repository', \&OleQuit) or die "oops\n";
$ex->OpenFile("C:\\test.EAP") or die "File not found";
$mo = $ex->{Models};
$mo = $mo->GetAt(0);
print $mo->{Name}, "\n";

sub OleQuit {
   my $self = shift;
   $self->Exit();
}

Title: Re: Use Automation with PERL
Post by: Bruno.Cossi on September 29, 2004, 09:58:56 am
Excellent!