All VBA users please give some input

All VBA users please give some input

shastu
Advisor Advisor
494 Views
5 Replies
Message 1 of 6

All VBA users please give some input

shastu
Advisor
Advisor

This is just a general post about the fact that VBA is going away and will probably no longer be offered at some point.  This was just brought to my attention a few weeks ago, and I am very discouraged because I have decades of code in VBA that now will need to be "converted" to something else.  I am curious as to what other people are doing or thinking about doing in order to keep all of the functionality that they have provided their company in VBA in the future.  Is iLogic the only option and if so, has anyone started this process?  How is the process going for you?  Also, how are you going to execute the ilogic since you can't just create buttons for the iLogic like you can for the VBA macros?  Hopefully, I can get a lot of feedback from multiple users so that I can make a plan on how to move forward.  Thanks everyone.

0 Likes
495 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

Hi @shastu.  That's a tough situation.  My advise would be to look into transitioning into VB.NET, and using Microsoft Visual Studio as the IDE.  It shares the same ancestry (Visual Basic) so it should be a fairly easy transition, and easy to pick-up.  Plus the code used in Inventor's iLogic AddIn's user interface (the iLogic Rule Editor) uses VB.NET as its basis, so you can run VB.NET code within iLogic rules, with a few minor adjustments.  Within iLogic rules, you can still do things like adding references to external resources, dll's, Imports, and references to other API systems & Object Libraries, but those types of things are often put into the 'Header' of the rule, due to its limited user interface.  Most of the keywords and structure are the same, but vb.net is a bit more forgiving, and can be less strict, depending on your settings.  Coding from scratch directly within the iLogic Rule Editor, is possible, because I have done it for several years, and it gets quicker with time, as you build-up your custom 'snippets' and reference helper documents.  However, some choose to write their code entirely within the Visual Studio environment, then transition their code from there down into iLogic rules.  If you have written code for Inventor using VBA for that many years then you must be pretty familiar with the Inventor's API, which is great.  Many of what I call iLogic's 'shortcut' snippets, are just that, shortcuts that really just run more API code in the background when they are called, so learning about them, and how to use them is a bonus, and can greatly shorten your code at times, but sticking with using straight API for most things will not steer you wrong.  There may be a couple situations where using an iLogic snippet for it is either greatly preferred, or even the only known way of doing certain things, but those are rare situations.  You can also build up your own collection of external iLogic rules that contain the bulk of the custom Classes, Methods, Enums, and such that you can simply add a reference to at the top of a rule, then keep the rule's code to a bare minimum to accomplish a lot.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6

JelteDeJong
Mentor
Mentor

I'm trying to warn people about VBa for some time. I even wrote a blog post about it "Is VBA in Inventor obsolete?". If you are used to the VBa editor you probably will miss some features. I have written another post "Writing and debugging iLogic rules". In that post, you will hopefully find some tips and tricks that help you overcome the lack of good debugging tools in iLogic.

If you need buttons for your iLogic rules then I have some good news. I created a free addon especially for creating buttons for (external) iLogic rules. More info on my page "Button Constructor". But Autodesk realised also that this is an issue and in Inventor 2023 this is standard functionality.

Last point on the topic. If you have a lot of code/functions you probably don't want to use iLogic but create your own addin. They are easier to distribute to your colleagues and also version control easier. (At least in my opinion, but I'm a bit biased as I do this for a living.) I can imagen that creating an addin sounds like a too big challenge but if you want to give it a try I wrote a tutorial about that. I just released part 4:

(I see that I referred quite a lot to my own site. Just to be clear I'm not trying to sell you anything. This site is just a hobby project that I maintain in my free time.)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 4 of 6

shastu
Advisor
Advisor

I appreciate the suggestions.  I have to admit, it all seems so much more complicated than using VBA.  I am not sure if that is just because I am not used to it, or if it truly is more complicated to accomplish the same thing.  It seems strange that Autodesk would take away something that works well and is more user friendly.  I was hoping more would reply that have actually been through the process of making the change but these two suggestions are helpful and I really appreciate all the links in the second post.  Does anyone know if version 2024 will still support VBA or is 2023 the last version that my code will work in?

0 Likes
Message 5 of 6

Curtis_Waguespack
Consultant
Consultant

@shastu wrote:

 It seems strange that Autodesk would take away something that works well and is more user friendly.  


It's Microsoft's doings, not Autodesk's. VBA macros are a huge source of malicious threats in some other software and industries... we don't see it much in Inventor, but it is a problem for others.

 

 


@shastu wrote:

I was hoping more would reply that have actually been through the process of making the change but these two suggestions are helpful and I really appreciate all the links in the second post.  


I would venture a guess that much/most of your code will work with iLogic with a few simple tweaks:

  • iLogic is based in .NET languages and most commonly VB.net
    • Spend a little time searching/reading about the primary differences between VB.net and VBA( VB 6) and it will inform you on what to look for when converting your code.
  • I often only need to do these 3 things to convert a VBA script to an iLogic rule:
    • Remove "Set" from the code.
      • Paste the code into an iLogic rule and then do a search for "Set " <-- with the space
      • Replace all instance of "Set " with ""
    • Add parenthesis 
      • Things like Msgbox "Hello World" , become Msgbox("Hello World")
    • Add enum names:
      • oDoc.SelectionPriority = kComponentSelectionPriority      gets changed to:
      • oDoc.SelectionPriority = SelectionPriorityEnum.kComponentSelectionPriority

see Page 22 of this PDF for a "Converting VBA to VB.net" guide:

https://ekinssolutions.com/wp-content/uploads/2018/11/CreatingInventorAddIns-AU2018.pdf

 

 


@shastu wrote:

Does anyone know if version 2024 will still support VBA or is 2023 the last version that my code will work in?


We've been being warned for years that it's going away, but I'm not convinced that it truly ever will. There are too many businesses that have a lot of their customization in Excel, or other office apps that are written in VBA 

 

But MS has recently made some significant changes that disable macros in Office apps ( recently being this summer).

 

So now you'll see something like this red Security Risk message, but if you click the Learn More button you will find instructions on how to unblock trusted macros, etc.

Curtis_Waguespack_1-1667482996362.png

 

Of course that is MS and what they are doing, and does not mean that AD will follow suit or handle things in the same way.

 

You might search the AutoCAD customization forum for information on this, as I think the AutoCAD community is probably more up to speed on what the future of VBA might look like for AD products than the Inventor community.

 

EESignature

Message 6 of 6

shastu
Advisor
Advisor

That is extremely helpful.  Thanks so much and I apologize for making the comment against Autodesk as I did know it was a Microsoft issue.  I guess that was just my frustration speaking which was inaccurate.

0 Likes