calling a function from a c++ dll

calling a function from a c++ dll

Anonymous
Not applicable
347 Views
1 Reply
Message 1 of 2

calling a function from a c++ dll

Anonymous
Not applicable

Hello,

 

I'm working inside the Inventor VBA Editor and trying to call a function from my own external c++ dll.

I can't seem to figure it out with the given info about this topic.

Could anyone guide me through the process?

 

Thanks in advance!

0 Likes
348 Views
1 Reply
Reply (1)
Message 2 of 2

RichardErnstberger
Enthusiast
Enthusiast

Hi Sonny,

i do not waste any time with VBA in Inventor.

I have a large app inside Inventor (also C++ dll) and i do anything inside the dll.

Define commands, create ribbon buttons and tabs, do user interaction, do anything...

 

I strongly recommend you to avoid the VBA crap inside Inventor - it is in no way a must.

Most times VBA is quick and dirty.

I rarely use it for some short tests, but would not implement any production function in VBA.

 

 

But, i also have to deal with other products, where the native dll approach wont work as in Inventor.

 

Here's an example of a VBA module to access a remote dll in a very famous big CAD system 🙂

 

Hopefully it would work in Inventor also.

 


In the first line of your module, prior to any function declarations you have to place lines like this one

'

Private Declare PtrSafe Sub myfuncCallvba Lib "D:\\yourappdir\\your.dll" ()

'

You probably can omit the PtrSafe keyword

And it would be helpful to have yourappdir somewhere Inventor can find it.

 

A call to the declared funtion looks like this:

Call myfuncCallvba

 

Arguments (if you need) should work also, at least if you use standard types.

In my case i have a set of registry keys and variables where i place the argument values before calling the dll functions.

 

Hope that can help you.

 

Regards,

RIchard

0 Likes