I would like to read all those properties. is it possible to use a loop to get them or do i have to read themone by one with a separate call?
something more elegant than copy and paste in excel 100s of lInes, put some code before and after the enumerators and pasting back on the VBA IDE...
https://help.solidworks.com/2018/englis ... lue_e.html
loop with enumerators In VBA
Re: loop with enumerators In VBA
I do not think that you can loop through them and will have to read them one by one only with separate line of code.
Deepak Gupta
SOLIDWORKS Consultant/Blogger
SOLIDWORKS Consultant/Blogger
Re: loop with enumerators In VBA
One more reason to abandon VBA and use VB.NET or C#. It's a two liner in those languages:mp3-250 wrote: ↑Tue Feb 06, 2024 5:47 am I would like to read all those properties. is it possible to use a loop to get them or do i have to read themone by one with a separate call?
something more elegant than copy and paste in excel 100s of lInes, put some code before and after the enumerators and pasting back on the VBA IDE...
https://help.solidworks.com/2018/englis ... lue_e.html
Code: Select all
foreach (swUserPreferenceDoubleValue_e val in Enum.GetValues(typeof(swUserPreferenceDoubleValue_e)))
{
Debug.Print(val.ToString() + " = " + swApp.GetUserPreferenceDoubleValue((int)val));
}
Re: loop with enumerators In VBA
codestack has something similar in VB.NET unfortunately I am not a programmer and my company would need to buy a visual studio license for me to "play" with this.JSculley wrote: ↑Tue Feb 06, 2024 8:08 am One more reason to abandon VBA and use VB.NET or C#. It's a two liner in those languages:
Code: Select all
foreach (swUserPreferenceDoubleValue_e val in Enum.GetValues(typeof(swUserPreferenceDoubleValue_e))) { Debug.Print(val.ToString() + " = " + swApp.GetUserPreferenceDoubleValue((int)val)); }
I was hoping at least for something like a numerical "alias" for the enumerators to invoke them with for loop. like having them in an array and loop with the index to read the property.
I probably end up with 100 lines anyway but one the loop code, making a bit more readable and flexible for other kind of properties.
well it was for my personal understanding as I still struggle to grasp many concepts with VBA.
my code works, but sometimes more than intuition I would like to know why...
Re: loop with enumerators In VBA
You can install the free community license at home to play with.
Deepak Gupta
SOLIDWORKS Consultant/Blogger
SOLIDWORKS Consultant/Blogger