Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started 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
-
I posted something on the EAUG (not the Wiki) some very long time ago.
-
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
-
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.
-
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.
#!/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?)
-
thanks a lot !!
it looks working :D