VBA Object with Configurations

VBA Object with Configurations

-Florian-
Participant Participant
1,740 Views
12 Replies
Message 1 of 13

VBA Object with Configurations

-Florian-
Participant
Participant

Hi there!

 

I just started using Inventor and I am trying to transfer a SolidWorks VBA project. The project is a GUI for managing all entries, which shall display in the drawing head. So far I managed to get the GUI to open and to read and write iProperties. Where I did not succeed so far is reading configurations. SolidWorks provides an object with all configurations of a part or assembly. By iterating through that object I can get the names of the configurations and with the name I am able to load specific configurations into my GUI.

 

Does Inventor know the concept of configurations? If so how can they be accessed?

 

Thanks for any hints!

0 Likes
Accepted solutions (1)
1,741 Views
12 Replies
Replies (12)
Message 2 of 13

Frederick_Law
Mentor
Mentor

ModelState is IV version of config which is available after 2022.

iPart and iAssembly are available for all.

It con ONLY be ModelState or iPart/iAssembly.

0 Likes
Message 3 of 13

swalton
Mentor
Mentor

You may find additional answers over on the iLogic and VB forum.

 

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/bd-p/120

Steve Walton
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


Inventor 2025
Vault Professional 2025
0 Likes
Message 4 of 13

JelteDeJong
Mentor
Mentor

If you are starting over in Inventor then don't use VBa because it is obsolete and is not a part anymore of the default Inventor installation. (However, it is still possible to add it as a separate package for backwards compatibility.)

You should have a look at iLogic for scripts of look at creating an add-in.

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 5 of 13

-Florian-
Participant
Participant

Thanks for the hint with VBA being obsolete. I'll see that I get this transferred.

0 Likes
Message 6 of 13

Frederick_Law
Mentor
Mentor

It was obsoleted, came back on life support.

iLogic is a good replacement.

Addin can do a lot more but much steeper learning curve.

0 Likes
Message 7 of 13

-Florian-
Participant
Participant

I looked at iLogic and I do not think it is a good replacement for my form. As I see it iLogic does not allow for a nice GUI.

Screenshot 2023-08-17 134021.png

 

I guess I have to look at the addin option more closely.

 

But back to topic. Which is the object I should look for in case I want to access different configurations? I found out that each configuration does have its own iProperties but I did not understand so far how to access those.

 

Thanks

Florian

0 Likes
Message 8 of 13

JelteDeJong
Mentor
Mentor

In Inventor, you would call a "configuration" a "model state". You might want to have a look at this page:

https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-AF380945-50B6-48B3-9D3A-578B85FFA260

 

It's possible to create Forms with iLogic. The most basic way is the iLogic form. They also look basic but do not require coding skills or other tools.

Because iLogic is an environment to write VB.Net code, you can create anything that you can do with .Net. Including forms but there is no nice interface to create them. So you have to write all the code to create a form yourself. It would not be my favourite possibility and I knew only 1 great article that described how to do it. It was written by @WCrihfield . (@WCrihfield ccan we still access your article some were?) But you would not need any special software.

That brings me to the 3e option creating an add-in with visual studio. (If you can write C# maybe you can do it also with visual code but I never tried that) This will give you all the freedom that you like. but it might be the most difficult thing to do if you never used iLogic and have no experience with programming and/or Inventor. But I wrote a tutorial about creating an add-in. You can find it here: http://www.hjalte.nl/tutorials

 

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 9 of 13

Frederick_Law
Mentor
Mentor

@-Florian- wrote:

But back to topic. Which is the object I should look for in case I want to access different configurations? I found out that each configuration does have its own iProperties but I did not understand so far how to access those.

 

Thanks

Florian


https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-3C968915-D5A1-423E-93E5-6EE1172AEDAD

Activate the ModelState and access iProperties "normally".

Pretty much the same when you use ModelState manually.

 

0 Likes
Message 10 of 13

Frederick_Law
Mentor
Mentor

@-Florian- wrote:

I looked at iLogic and I do not think it is a good replacement for my form. As I see it iLogic does not allow for a nice GUI.

 

Thanks

Florian


iLogic forms are "active".  iProperties are connected to the from programmatically, bidirectional.

Change in iProperties can activate iLogic, iLogic can change iProperties.

 

In Addin, you'll need to program everything and it's only one direction.

Unless you program event trigger on every iProperties change.

Message 11 of 13

WCrihfield
Mentor
Mentor
Accepted solution

They took all of our user submitted knowledge articles down, but I did preserve the article's contents to a Microsoft Word document, then on to a PDF, for storage and reference.  I also preserved a second article I had posted about another tool that uses a custom vb.net Windows Form from an iLogic rule, which was being used for pushing iProperties out to files in a directory.  I have attached both PDF's and a text file to this article for reference.  They remain a little rough around the edges, because they were among the first Windows Forms I ever created entirely by code in an iLogic rule, without the help of Visual Studio.  I actually got the main idea from another forum user years ago (I did not keep a link to it) and further developed it into something mainly to show what the possibilities are from an iLogic rule, and to take customization beyond the abilities of the iLogic Form Editor's capabilities at the time.  One of the main limitations of an iLogic Form where you have to source 'List' type data from.  An iLogic Form can only get that data from a multi-value user parameter right now, unlike what is possible with VBA UserForms or .net Windows Forms.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 12 of 13

-Florian-
Participant
Participant

Thanks a lot for all your support! I will check all this. For the moment my VBA is up and running (transfer from SolidWorks was really easy. Export form there and import in Inventor. Just needed to exchange the "Model".)

0 Likes
Message 13 of 13

WCrihfield
Mentor
Mentor

The main oddities about using Inventor's iLogic, when you are used to coding in VBA or strict vb.net, is that they created iLogic to make automating Inventor much simpler for folks that do not already know much (if anything) about coding.  When you create a new, empty iLogic rule, there are already several things taken care of for you in the background.  It will automatically create a Class block of code for you (Class name is "ThisRule") invisibly, in the background, if you to not start your code with a Class statement.  It will automatically create a 'Sub Main' block of code for you, invisibly, in the background, if you do not start your code with that key phrase.  That way you can just start typing in useful code that will work on its own, without needing to know anything about that stuff.  You only need to include those types of specifications when your rules need to call other, separate routines to run.  There are also lots of variables already defined and created for us invisibly, in the background, that we can simply start using in our simple rules.  Some of them represent Interface type objects, and have a lot of behind the scenes functionality to help reduce the amount of code needed.  But our iLogic rules can also be very strict, and professional, like if they were copied straight over from something like Visual Studio, to a certain degree, when certain settings are set-up correctly.  Even though iLogic is just an ApplicationAddIn within the Inventor application, it is actually capable of a lot more than most folks suspect, due to its coding language being based on vb.net.

https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-AB9EE660-299E-408F-BBE1-AFE44C723F59 

https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=110f3019-404c-4fc4-8b5d-7a3143f129da 

https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=UserManualIndex 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)