Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started 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 :)
-
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
-
Thanks Bruno :D I'll try that next week :)
BTW: The OLE smiley is nice ;D
-
No problem Thomas, let me know how it went!
The OLE smiley took me by surprise. Sorry :-)
Bruno
-
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?
-
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
-
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.
-
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:
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();
}
-
Excellent!