Can I run an addin from an external api driven app?

Can I run an addin from an external api driven app?

greg.mort
Participant Participant
526 Views
4 Replies
Message 1 of 5

Can I run an addin from an external api driven app?

greg.mort
Participant
Participant

I am creating addins that I would like to run without needing a user to click a button, I would like to have a separate EXE app that executes the add ins similar to how iLogic commands can be triggered from .net

 

iLogicAutomation.Runrule(assy.InventorDocument, "ruleName");

 

is that possible?

0 Likes
527 Views
4 Replies
Replies (4)
Message 2 of 5

bradeneuropeArthur
Mentor
Mentor

For my understanding:

You want to run a command form the add in, right?

If the add in is correctly created you can run also commands form external and getting the Inventor object.

 

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 5

Michael.Navara
Advisor
Advisor

This is possible, but it is little bit tricky. The best way (IMHO) is to implement your own API and expose it thru Automation property of the AddIn.

Then you can get the AddIn by its ID and then get Automation property, re-type value to your known API type and then you can call any method exposed by this object.

NOTE: Re-type is not necessary (but recommended) when you call methods by late binding (VB.NET) 

 

EDIT:

Here is minimalistic example of custom API implementation

 

namespace MyAddInWithApi
{
  [Guid("GUID-OF-YOUR-ADDIN-HERE")]
  public class MyAddInServerWithApi : Inventor.ApplicationAddInServer
  {
      private Application inventor;
      private MyAddInApi myAddInApi;
  
      public void Activate(ApplicationAddInSite AddInSiteObject, bool FirstTime)
      {
          inventor = AddInSiteObject.Application;
          myAddInApi = new MyAddInApi(inventor);
      }
  
      public void Deactivate()
      {
          myAddInApi = null;
      }
  
      public void ExecuteCommand(int CommandID)
      {
          //OBSOLETE, DO NOTHING
      }
  
      /// <summary>
      /// Gets the IUnknown of the object implemented inside the AddIn that supports AddIn-specific API.
      /// </summary>
      public object Automation
      {
          get
          {
              return myAddInApi;
          }
      }
  
  }
  
  public class MyAddInApi
  {
      private readonly Application inventor;
  
      public MyAddInApi(Application inventor)
      {
          this.inventor = inventor;
      }
  
      public void SetApplicationCaption(string caption)
      {
          inventor.Caption = caption;
      }
  }
}

Here is example of custom API call

 

namespace MyExternalApp
{
  ...
  void CallMyApiMethodExample()
  {
      var myAddInServerWithApi = inventor.ApplicationAddIns.ItemById["{GUID-OF-YOUR-ADDIN-HERE}"];
      var myAddInApi = myAddInServerWithApi.Automation as MyAddInApi;
      myAddInApi.SetApplicationCaption("It works :-)");
  }
  ...
}
0 Likes
Message 4 of 5

greg.mort
Participant
Participant

Yes run a command that lives within the add in. But run it from an external .exe 

0 Likes
Message 5 of 5

bradeneuropeArthur
Mentor
Mentor

If you know the CommandName then it is possible.

thisapplication.CommandManager.ControlDefinitions.Item("COMMAND NAME").Execute

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes