Virtual studio can't declare Inventor application.

Virtual studio can't declare Inventor application.

FINET_Laurent
Advisor Advisor
2,012 Views
14 Replies
Message 1 of 15

Virtual studio can't declare Inventor application.

FINET_Laurent
Advisor
Advisor

Hi,

 

I'm trying to make an EXE for inventor using Virtual studio.I've created a new project and tried to declare the Inventor application but I can't do it. I've looked through the internet, sample files etc..

Is there a secret trick to it ?

 

Regards,

 

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Accepted solutions (1)
2,013 Views
14 Replies
Replies (14)
Message 2 of 15

FINET_Laurent
Advisor
Advisor

I'm refering to those lines  :

 

Dim oInventorApp As Inventor.Application
oInventorApp = GetObject( , "Inventor.Application")

 

The " Get Object " is not defined.. =C

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 3 of 15

sundars
Autodesk
Autodesk
Accepted solution

Hi @FINET_Laurent 

 

Did you mean Visual Studio? If it's visual studio you can create an Addin DLL which can be loaded into Inventor. Are you specifically looking to create a stand alone exe?

 

You can access the SDK samples here: C:\Users\Public\Documents\Autodesk\Inventor 2021\SDK

- Run "developertools.msi"

- This will extract the SDK folders

- Navigate to C:\Users\Public\Documents\Autodesk\Inventor 2021\SDK\DeveloperTools\Samples

- you will see sample projects which you can customize.

 

Hope that helps.

-shiva

Shiva Sundaram
Inventor Development
Message 4 of 15

sundars
Autodesk
Autodesk

Hi @FINET_Laurent 

 

objInventorApp = GetObject( , "Inventor.Application") is a microsoft call - https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/getobject-functio....

 

It should work, if you have built the project correctly. Can you take a look at the standalone VBA sample programs in the SDK folder. They use the same logic and execute GetObject().

 

Thanks

-shiva

Shiva Sundaram
Inventor Development
0 Likes
Message 5 of 15

FINET_Laurent
Advisor
Advisor

I've changed to framework 5.0 and got the execute the command :

Imports Inventor

Public Class Form1

Private Sub Ola_Click(sender As Object, e As EventArgs) Handles Ola.Click
Dim oApp As Inventor.Application
oApp = GetObject(, "Inventor.Application")
Dim oDoc As AssemblyDocument = oApp.ActiveDocument
End Sub

End Class

 

But the oApp is empty.. :C

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 6 of 15

sundars
Autodesk
Autodesk

Interesting. Did it use to work with .NET 4.7/4.8? I dont see why that would fail with .Net 5.0.

Can you check to see if you can call GetObject() on any other application?

 

-shiva

 

Shiva Sundaram
Inventor Development
0 Likes
Message 7 of 15

sundars
Autodesk
Autodesk

You could also try

 

Dim oApp As Inventor.Application = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")

Reference:

https://adndevblog.typepad.com/manufacturing/2012/07/run-vba-macro-using-inventor-api.html

 

-shiva

Shiva Sundaram
Inventor Development
0 Likes
Message 8 of 15

FINET_Laurent
Advisor
Advisor

Thank you for taking your time to answer.

Unfortunately I'm out of the officie until monday..

I'll try those and let you know asap.

Also this is the very first time I'm using Visual Studio.. ^^'

 

Thanks again,

 

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 9 of 15

johnsonshiue
Community Manager
Community Manager

Hi Laurent,

 

Another thing to watch out is that Inventor Apprentice Server is a separate install on top of Inventor now. If you need it, go to the following page.

 

https://knowledge.autodesk.com/support/inventor/downloads/caas/downloads/content/inventor-apprentice...

 

Many thanks!



Johnson Shiue ([email protected])
Software Test Engineer
0 Likes
Message 10 of 15

FINET_Laurent
Advisor
Advisor

Hi, I installed every thing but it's still not working... I have Inventor 2021 & Visual studio 2019..

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 11 of 15

FINET_Laurent
Advisor
Advisor

Tried too.. It's like the application doesn't exist...

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 12 of 15

sundars
Autodesk
Autodesk

Hi @FINET_Laurent 

 

After installing visual studio did you restart your computer (silly question - but just making sure). Another thing you can try is calling GetObject() on a different application - not Inventor, but notepad or paint or Excel and see if that works. If not, then there may be something else going on your machine. If it's only a problem with Inventor, then either there is something incorrect with your installation or your vba project.

 

If nothing else works, you can zip up your project with just the code which doesnt work and send it to usWe can try to take a look at it.

 

Thanks

-shiva

 

Shiva Sundaram
Inventor Development
0 Likes
Message 13 of 15

FINET_Laurent
Advisor
Advisor

Hi,

 

I indeed can't get any application object..

 

Anyway I tried using the addin template and got something to work (close the application when pressing a button), so I guess I'll go this way instead.

I'll dig further down to see if I'm configuring the project wrong or something...

 

Regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

Message 14 of 15

bradeneuropeArthur
Mentor
Mentor

@johan.degreef  had similar things with Excel.

He can maybe help you out!

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 15 of 15

pockybum522
Enthusiast
Enthusiast

https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/getting-inventor-object-in-net-core/td-...

 

Please check out this post for how to Marshal a COM object in .NET 5.