Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Programming Inventor: VBA C# or C++?

15 REPLIES 15
Reply
Message 1 of 16
oransen
5090 Views, 15 Replies

Programming Inventor: VBA C# or C++?

I'm about to do some customization for Inventor and though I've read the introduction and which language is best for which application I'm still not sure which to use.

 

Some considerations:

 

  1. The program will create a specific component of a heat exchanger parametrically.
  2. There will be a dialog and some selection of existing components before the new composite component is created.
  3. VBA code already exists in an Access MDB to create 2D versions of the component (creates flat 2D DXF files and BOMs).
  4. Many of the smaller sub components will be iParts
  5. A database of rules already exists for the creation of the component, in the same MDB as the VBA application mentioned previously.

It would be tempting to "port" the Access VBA to Inventor VBA, but I'm not sure that in the long term this is the best solution. VBA is not fast and is a pretty grim language at times. On the other hand VBA may be less version specific, compared to compilers and C# IDEs, interpreters etc.

 

I know basic C# and advanced C++, but again I've not got enough experience with Inventor to make a completely informed decision.

 

Any pointers or help anyone?

 

 

15 REPLIES 15
Message 2 of 16
MegaJerk
in reply to: oransen

Why not use VB.Net? If you're making a plug-in or stand alone program, it will do the trick. If you are especially familiar with VBA, it won't even be that much of a stretch to just jump in and get your hands dirty from the get go.



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 3 of 16
oransen
in reply to: MegaJerk

I was not clear methinks. I consider VBA and VB.NET close enough to be the same sort of language.So the question should have been VBX vs C# vs C++

 

Message 4 of 16
oransen
in reply to: oransen

I found this comment in the ModTheMachine blog

 

"...we only recommend using VBA for quick prototyping or for small macros...."

 

and my application will not be a small macro. So that leaves me the choice of C# or C++...

 

Message 5 of 16
MegaJerk
in reply to: oransen

VBA and VB.Net are not the same thing. Both VB.net & C# both use the .Net framework, on the other hand VBA is a rudimentary development tool that it typically packaged alongside software (suites) such as Office, and in this case, Inventor. It is that VBA that is packaged along with Inventor (Found in Tools --> VBA Editor) that Brian is talking about.

There are a few reasons for that! First being that Autodesk may not continue to support VBA along side their products (or so it has been hinted), and second, it's not a very robust tool! Though it is wonderful for quickly seeing how something is working (as the debugging features are rather easy to use), it is not a very practical solution to actually building your own stand alone programs / plugins.

Though VB.Net and C# are similar (due to the same framework) VB.Net just happens to be more familiar if you’re already familiar with VBA, which is why I suggested it.



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 6 of 16
oransen
in reply to: MegaJerk

For some applications VBA can be very robust if used wisely. I looked down on it for many years until 10 years ago I had to use it to create piping diagrams for heat exchangers automatically. Never looked back!

 

I don't love VBA though, and I don't think I'd love VB.NET. Is VB.NET 32 bit?

 

I dug deeper now and I think that C++ is the way to go.

 

C# is tempting...

Message 7 of 16
MegaJerk
in reply to: oransen

I have no interest in looking down on a language for whatever reason. VBA is wonderful for doing quick and dirty prototyping. A lot of the epic iLogic code that I do is typically tested and debugged first in a series of VBA rough drafts.

Ultimately it doesn’t particularly matter which language and IDE you use, so long as YOU want to use it. If you feel comfortable using C++ and know how to interact with Inventor through it, why not just jump in? The reason I suggest VB.net is due to the staggering amount of examples / tutorials / snippets that exist for it. There are also a significant body of examples that are done in both VB.Net and C#.

 If you look in my signature you’ll see a link to an iLogic injector that I made (and has since been updated by the cool guys over at Being Inventive), which was done in VB.net, another (possibly biased even) reason I suggested it.

Depending on your success with C++, perhaps you should start writing tutorials for how to get started with C++ and the Inventor API. Post a follow up once you have your program completed.

(Also : Yes, .Net can do both 32 and 64, though I’m not entirely sure that it matters when interacting with Inventor which is single threaded no matter what L )



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 8 of 16
oransen
in reply to: MegaJerk

"Depending on your success with C++, perhaps you should start writing tutorials for how to get started with C++ and the Inventor API. Post a follow up once you have your program completed."

 

You mean like I did with ObjectARX? I could do. One of the best ways of learning a subject is having to write a book or blog about it. The mistakes are so public I'm more careful about what I say!

 

Message 9 of 16
MegaJerk
in reply to: oransen

I do not know what ObjectARX is, but I suspect that you have written a blog about it, so, yes! Because it's somewhat hard to find resources on programming for the world of Inventor, I will try to encourage people to post their solutions / information here as a follow up, just for the sake of having some sort of archive repository.

Good luck on your journey!



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 10 of 16
bsee1
in reply to: oransen

Language wise C# and VB.Net are very similar.  C++ is much lower level and I find vba far too limiting when compared to the full addins you can make with the .net languages.  

 

I do not recommend C++ or VBA for Inventor programming.  Like mentioned above, VBA is good at prototyping.  If you search the forums, if you use C++ with Inventor you'll probably have a hard time getting any support.  It then becomes more difficult to tell if your issue is an Inventor bug or your own bug.  If you choose C++, do so knowing that you are forging your own path.

 

I would recommend either VB.Net or C#.  Personally I find C# easier to use, and language popularity seems to be doing a slow shift from VB.Net to C#.  That said, currently there are far more VB.Net Inventor examples than C#.  However, the modthemachine blog recently redid all the vb.net sample addins in C#.  

 

One huge reason I recommend choosing a .net language over C++ is ReSharper.  Every programmer should have at least used a trial of it so they know what features it has.  It is well worth the cost, and will save you far more in time than you spend on it.

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1
Message 11 of 16
oransen
in reply to: bsee1

An interesting reply, but C# and VB are NOT very similar. VB is an old language with pecularities because of its decades long history. C# is a new, clean, and well designed language. Maybe you meant that their capabilities WRT Inventor are similar. Thay may be true.

 

C++ is not "much lower level". C++ can be as high level or low level as the programmer decides. That is its good point and bad point. It is certainly more sophisticated than C# and VB.

 

You are right to be concerned about the apparent lack of examples in C++. C# has more, but neither as has many examples as VB.

 

But you've made me think that maybe C# would be a better choice for this project than C++.

 

Message 12 of 16
DifanH
in reply to: oransen

Hey I am currently working on a programme taking advantage of Inventor API with VC++.

 

That is a standalone application which will take a sketch (or a working plane) as input, mesh the area with Bubble packing and dig wholes on the plane.

 

This is a big project and I am on the start. But as you might see, there are few material on C++ with Inventor API. If you decide to implement your project with C++, pls contact me. It is always a good thing to have some one working together.

 

 

Message 13 of 16
oransen
in reply to: MegaJerk

"I do not know what ObjectARX" is the C++ API for AutoCAD. It was well designed and I wrote a few apps with it.

 

Thanks for the good wishes on my journey, it feels like I'll need them!

 

Message 14 of 16
oransen
in reply to: DifanH

"It is always a good thing to have some one working together."

 

Will do. The project is at an early stage and may not take some time to get. In the meantime I suppose I could write another book like my "AutoCAD programming in C/C++"

 

Why do you think there is so little data on C++ programming Inventor?

 

 

Message 15 of 16
jdkriek
in reply to: oransen

My perspective - C++ was one of the first languages I seriously learned and I still love it. I have for some applications made the transition from C++ to C# and even VB.NET. However, I still miss the full power of C++. In C++ you have incredible control over the creation and even the layout of your objects as you already know. You can create an object on the stack, on the heap, or even in a particular place in memory.

 

With C# however you give up that level of control. When you choose the type of your object, the choice of where the object will be is implicit. Simple types are always created on the stack and classes are always created on the heap. You can't control where on the heap an object is created, you can't get its address, and you can't pin it down in a specific memory location. You no longer control the lifetime of your object as C# has no destructor. It's all up to the garbage collector and finalization is non-deterministic. In C# everything ultimately derives from Object.

 

Having said that C# was an easy transition and it has a portion of C++ power with the simplicity of VB. For Inventor applications I’d suggest VB.NET for those more familiar with VB, but if you have a C++ soul in you – shoot for C#.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 16 of 16
oransen
in reply to: jdkriek

All you say about C# is true, but I don't find them as objections but as good simplifications.

 

C++ is a better choice maybe for applications you want to sell.

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums