Author Topic: Add-In disabled when starting EA via Powershell  (Read 6811 times)

coatie

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Add-In disabled when starting EA via Powershell
« on: July 24, 2015, 04:30:37 am »
Hello,

just wrote me a Powershell script to open an EA model and realized that my add-in is not enabled when running EA via the PS script.

Snippet from powershell script:
Code: [Select]
     
...
  $dbConnection = "DBType=3;Connect=Provider=OraOLEDB.Oracle.1;Password=XXXXX;Persist Security Info=True;User ID=YYYYYY;Data Source=eadb;"
  $EaApp = New-Object -ComObject "EA.App"
  $EaRepo = $EaApp.Repository
  $EaRepo.OpenFile2($dbConnection,"user","secret"))
...

After calling the OpenFile2 I expected the event EA_FileOpen to be fired and my Add-In (C# DLL) to do some action but it didn't happen. Then I added $EaRepo.ShowWindow(1) to the Powershell script and found that my Add-In is in state "disabled" within the Addin-Manager.

Any way to enabled it?

Markus

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Add-In disabled when starting EA via Powershel
« Reply #1 on: July 24, 2015, 04:44:35 am »
That means you did something wrong during initialization. Unfortunately EA just lets you guess about what that might have been :-/

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: Add-In disabled when starting EA via Powershel
« Reply #2 on: July 24, 2015, 08:26:51 am »
No add-ins are loaded when EA is created from automation. It behaves that way so that add-ins don't interfere with the caller.

There should be1 API functions to load the add-ins.

1 Meaning I remember a function to load a specific add-in, and one to load all add-ins being implemented a while back in response to a similar situation. I assume they are part of 12, but no idea what they are called.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Add-In disabled when starting EA via Powershel
« Reply #3 on: July 24, 2015, 10:16:36 am »

coatie

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: Add-In disabled when starting EA via Powershel
« Reply #4 on: July 24, 2015, 02:59:39 pm »
Thanks a lot, totally missed that when browsing the help...

Anything else to consider?
I added the LoadAddins() (tried before and after OpenFile2) to the PS script and now the Addin is in state enabled but still events seem not to be triggered and menu entry of the Addin is missing.

Using EA 11.0.1106

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Add-In disabled when starting EA via Powershel
« Reply #5 on: July 24, 2015, 09:43:04 pm »
Add-ins are supposed to react to human interaction. External scripts are intended to run in batch (without human interaction). So I don't see the point in enabling add-ins for batch use. If you run a batch then include all code you need.

q.

coatie

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: Add-In disabled when starting EA via Powershel
« Reply #6 on: July 25, 2015, 02:24:27 am »
Quote
If you run a batch then include all code you need.
That's exactly what I wanted to prevent and was looking for an alternative and use the trigger EA_FileOpen for supporting automation from within my add-in.

BTW, why was LoadAddins() added if there would be no need for it?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Add-In disabled when starting EA via Powershel
« Reply #7 on: July 25, 2015, 03:12:17 am »
Quote
BTW, why was LoadAddins() added if there would be no need for it?

I can't count the number of features that have been added with (at least) doubtful use cases.

q.
« Last Edit: July 25, 2015, 03:12:41 am by qwerty »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: Add-In disabled when starting EA via Powershel
« Reply #8 on: July 27, 2015, 08:45:33 am »
At a minimum, it could be required for add-ins providing an MDG technology. (ie. An external script to run documentation isn't going to be useful if the shape scripts defined in an add-in aren't used)