change properties of assemblies and parts from an excel list
Posted: Fri Jun 16, 2023 9:48 am
Hello,
I'ts my 1st post, i'm French and noob in VBA so please be friendly and understanding
i need to change properties of a lot of files because my clients often change their minds and decide that their shelves would look better in blue rather than red for example.
I imagined an excel table in which I list the solidworks files (drawings).
In this table I would name the colors that I no longer want and those that would replace them.
example:
Red => Blue
Green => Yellow
Purple => Black
Same for materials.
Steel => Aluminum
...
3 for each.
When i finish writing the list of solidworks files, finishes and materials, i run the macro.
Solidworks opens the 1st file in the list, opens the assembly of the first page of the drawing, searches in "FINITION", "FINITION2", "FINITION3", "MATIERE_PRINCIPALE", MATIERE_PRINCIPALE2" and "MATIERE_PRINCIPALE3" to replace finish and material.
After that, check if this fil is a part or assembly, if it's an assembly, open every sub assembly and part one by one to apply the same.
Then, close every part or assembly and run another macro to export as PDF, DXF and STEP (i aready have this macro) in a folder that I specified in my excel table.
Phew! that's it, we made a line!
next line...
until the end of the list in the excel table.
a progress bar would be nice, error messages in case of file not found too (a color on the line of the excel table for example)
Attention, for the change of material for the parts, it is not necessary to change the property but the material if however it would be to change.
I know it's a lot of work. I tried by myself by doing research on different forums, I found pieces of code that I tried to assemble but I can't.
below the macro to do what I want but for only the open document.
I obviously forgot things but it's already long enough, I'll answer all your questions if you have any.
Thank you in advance for taking the time to read me, I don't just want to have this table but to understand how it works and why I made these choices in the programming to be able to be more independent for the next few times.
I'ts my 1st post, i'm French and noob in VBA so please be friendly and understanding
i need to change properties of a lot of files because my clients often change their minds and decide that their shelves would look better in blue rather than red for example.
I imagined an excel table in which I list the solidworks files (drawings).
In this table I would name the colors that I no longer want and those that would replace them.
example:
Red => Blue
Green => Yellow
Purple => Black
Same for materials.
Steel => Aluminum
...
3 for each.
When i finish writing the list of solidworks files, finishes and materials, i run the macro.
Solidworks opens the 1st file in the list, opens the assembly of the first page of the drawing, searches in "FINITION", "FINITION2", "FINITION3", "MATIERE_PRINCIPALE", MATIERE_PRINCIPALE2" and "MATIERE_PRINCIPALE3" to replace finish and material.
After that, check if this fil is a part or assembly, if it's an assembly, open every sub assembly and part one by one to apply the same.
Then, close every part or assembly and run another macro to export as PDF, DXF and STEP (i aready have this macro) in a folder that I specified in my excel table.
Phew! that's it, we made a line!
next line...
until the end of the list in the excel table.
a progress bar would be nice, error messages in case of file not found too (a color on the line of the excel table for example)
Attention, for the change of material for the parts, it is not necessary to change the property but the material if however it would be to change.
I know it's a lot of work. I tried by myself by doing research on different forums, I found pieces of code that I tried to assemble but I can't.
below the macro to do what I want but for only the open document.
I obviously forgot things but it's already long enough, I'll answer all your questions if you have any.
Thank you in advance for taking the time to read me, I don't just want to have this table but to understand how it works and why I made these choices in the programming to be able to be more independent for the next few times.