Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: xkrystof on February 06, 2008, 02:22:57 am

Title: connection Perl to automtaion interace
Post by: xkrystof on February 06, 2008, 02:22:57 am
Hi, could you advise me, how to connect Perl to the EA automation interface?

thank you

Jan
Title: Re: connection Perl to automtaion interace
Post by: thomaskilian on February 06, 2008, 02:37:04 am
I posted something on the EAUG (not the Wiki) some very long time ago.
Title: Re: connection Perl to automtaion interace
Post by: «Midnight» on February 06, 2008, 03:44:58 am
EA is a COM server, so with luck you can use the appropriate Perl library.

Thomas can confirm whether I'm off on a tangent here.

Of course, the actual details are left to the reader as an exercise...

David
Title: Re: connection Perl to automtaion interace
Post by: thomaskilian on February 06, 2008, 04:18:21 am
Actually it's very easy (if you know how). It should be still in the EAUG... Maybe if someone could maintain what I did, publish the stuff and write a few comment lines I'd be willing to post it again.
Title: Re: connection Perl to automtaion interace
Post by: gpc on February 06, 2008, 07:29:42 am
Hi,
Here's a snippet from something I downloaded (and modified) a while ago (attributed to a Dr. UV Wildner). It should give you a basic idea of how to access the interface.

Quote
#!/cygwin/bin/perl -W

use strict;
use Win32::OLE;

sub dumpPackages
{
  my ($pkgCollection) = @_;
  for (my $j=0;$j < $pkgCollection->Count;$j++)
  {
    my $package = $pkgCollection->GetAt($j);

    print $package->Name. " \n";

    # recurse children
    &dumpPackages($package->Packages);
  }
}

my $repository = Win32::OLE->new('EA.Repository', \&OleQuit) or die "oops cannot access Repository interface\n";
my $result = $repository->OpenFile($model);
print "file opened\n" if $result;
die $repository->GetLastError ()."\n" unless $result;
 
my $allModels = $repository->Models();
die "no models found in $model\n" unless ($allModels);
print "found " , $allModels->Count, " models in file\n";
 
for (my $i=0;$i < $allModels->Count;$i++)
{
  my $model = $allModels->GetAt($i);
  print "model ==> ", $model->Name, "\n";
  &dumpPackages($model->Packages);
}

you'll need to set the $model variable to your file name and location. HTH. (maybe someone has the full code or better examples?)
Title: Re: connection Perl to automtaion interace
Post by: xkrystof on February 13, 2008, 05:06:14 am
thanks a lot !!
it looks working :D