Execute standalone app from Add-In and pass it the Inventor Application object

Execute standalone app from Add-In and pass it the Inventor Application object

hoeckesfeld
Enthusiast Enthusiast
469 Views
2 Replies
Message 1 of 3

Execute standalone app from Add-In and pass it the Inventor Application object

hoeckesfeld
Enthusiast
Enthusiast

Hi,

 

sorry if this question has already been asked, could not find an answer.

 

I want to start (execute) my Stand-Alone Application from an Add-In (e.g. by pressing a button.) and pass the current Inventor Application object to my stand alone app, so that i can do some work over there. Is there any way to do this ?

I need this to work for cases where multiple inventor processes are running. if it were only a single one i could start my Stand Alone app and have it get the inventor application object via GetActiveObject. But I have not figured out yet how to get the application objects if multiple inventor processes are running . 

 

If I could get a list of all active inventor applications, an idea would be have the addin set a flag to "mark the instance from which the user pressed the button" , then have my stand alone app call an interface method defined in my add in on all active inventor instances to select the correct application object by returning the state of the flag.

Maybe there is a simpler solution?

Thanks in advance!

0 Likes
470 Views
2 Replies
Replies (2)
Message 2 of 3

bradeneuropeArthur
Mentor
Mentor

maybe you can give each Inventor session you start with an unique id like Session##AutodeskInventor. Then call the standalone app and use this specific Session##AutodeskInventor with a parameter like p="Session##AutodeskInventor.". If you don.t understand i need to write te code for you...

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 3

hoeckesfeld
Enthusiast
Enthusiast

Hi, thanks for the reply, it doesn't work though because all running inventor processes only return the same Inventor.Application object of the first opened instance.

For example this:

public static IEnumerable<Inventor.Application> GetRunningInstances()
{

List<Inventor.Application> inventorApps = new List<Inventor.Application>();

IRunningObjectTable rot;
GetRunningObjectTable(0, out rot);

IEnumMoniker monikerEnumerator;
rot.EnumRunning(out monikerEnumerator);

monikerEnumerator.Reset();
IMoniker[] monikers = new IMoniker[1];

while (monikerEnumerator.Next(1, monikers, IntPtr.Zero) == 0)
{
IBindCtx bindCtx;
CreateBindCtx(0, out bindCtx);

string name;
monikers[0].GetDisplayName(bindCtx, null, out name);

Console.WriteLine(name);

if (name.Equals("!{B6B5DC40-96E3-11D2-B774-0060B0F159EF}"))
{
object comObject;
rot.GetObject(monikers[0], out comObject);
inventorApps.Add((Inventor.Application)comObject);
}

Marshal.ReleaseComObject(bindCtx);
}

Marshal.ReleaseComObject(rot);

return inventorApps;
}

[DllImport("ole32.dll")]
public static extern int GetRunningObjectTable(int reserved, out IRunningObjectTable prot);

[DllImport("ole32.dll")]
public static extern int CreateBindCtx(int reserved, out IBindCtx ppbc);

returns the same Inventor.Application object once for each running instance, the Inventor.Application object of the first started instance.





0 Likes