Page 1 of 1
My Macros
Posted: Tue Mar 16, 2021 12:06 pm
by mattpeneguy
Before anyone tries any of my macros, have a look over at
https://www.codestack.net/solidworks-tools/ and see if there's a similar macro, if so use the one from the above site before you try mine.
Those macros were made by
@artem. For those that don't know he's a programmer, I'm not.
Some macros I've kludged together:
- All Title Text Resize - changes all titles in all views in a drawing file to a particular size
- Change Default Drawing Fonts - Change all annotations in a drawing to set sizes, good for switching fonts and sizes
- Change Dim Tolerances - Changes dimension tolerances for selected dimensions
- ChangeToolboxPartType with Dialogue - Self explanatory
- Rename all Views In Drawing - Cycle through all views and sequentially renumber them A-Z. This is good if you've
- deleted section views and added new ones
- Renumber Sheets - Renumbers all sheets in a drawing file based on a starting number you enter in a dialog
- Roll Back - Rolls the rollback bar up the feature tree and then back down. Needs modifying to be useful
- Sketch Color Change - Change sketch colors with a dialog
- Title Text Resize - Self explanatory
- Update Sheet Formats - Changes out the sheet formats for all sheets in a drawing file
- View Title Text - Adds the BOM Name to a View Title, if selected.
Re: My Macros
Posted: Tue Mar 16, 2021 12:39 pm
by mike miller
A few of mine.....
- Combine Identical Components - useful for BOMs that have multiple instances of a part. (Pre-selection required)
- Dynamic Highlight ON - Just what it says
- Multi-Body DXF - a massive masterpiece from Codestack that was modified by us. It will take an assembly or a multibody part file and save all the DXFs to a specified folder using a name based on cutlist properties (you can edit it).
- Profile Center Mate - Mates two selected faces/edges, sets distance at 0, locks rotation, and confirms.
- Reload all Sheet Formats -- reloads 'em all in a large drawing.
- Remove blanks in BOM -- Scans the second to left row in the selected BOM and hides/deletes any row with a blank value. (Needs a little work yet, but extremely powerful!)
- Save all sheets as PDF and close - Saves all sheets to a specified location, saves, and closes file. Great for those huge behemoths when you have to go pee while it's saving!
[EDIT: 4-22-21 replaced zip file due to board corruption.]
Re: My Macros
Posted: Tue Mar 16, 2021 2:13 pm
by AlexLachance
Hide referenced geometry - Hides referenced geometries such as sketches, insertpoints, planes.
Link views to BOM - Serves to link views to a specific BOM in a multi-BOM drawing.
Note Level selecter - Allows to select the desired level of a note.
Sketch direction - temporarly displays sketch element directions. Useful for people working in multibody parts
Dynamic Highlighting - Turn on Dynamic Highlight. Dang thing keeps turning off randomly so this is a macro to activate it from a click.
Re: My Macros
Posted: Wed Mar 17, 2021 8:01 am
by Jaylin Hochstetler
Here's a version of the Multi-body DXF macro, that Mike posted, on steroids! It allows you to either browse for the "DXFs" folder location or enter the address of the location instead of putting it in the folder the part is located in.
Re: My Macros
Posted: Thu Apr 22, 2021 6:30 am
by mike miller
Due to the board corruption of attachments, could you update your files? TIA, @mattpeneguy, @AlexLachance, @Jaylin Hochstetler.
Re: My Macros
Posted: Thu Apr 22, 2021 7:17 am
by matt
We can also put them in the Downloads area which is a nice central location. The Download area wasn't affected by the corruption. Admin is the only one who can upload, but I'll take that on. You can attach the macros here and I'll upload.
Re: My Macros
Posted: Thu Apr 22, 2021 9:45 am
by mattpeneguy
The mention thing is kinda flakey for me lately. Mike Miller and Matt, I have re-uploaded my macros.
Thanks for letting me know.
Re: My Macros
Posted: Thu Apr 22, 2021 9:57 am
by AlexLachance
Also done.
Re: My Macros
Posted: Thu Apr 22, 2021 10:07 am
by Jaylin Hochstetler
Done.
Re: My Macros
Posted: Wed May 25, 2022 3:42 am
by DONALT_95
Hi Matt,
I am new to macros and tried to use your 'rename all views in drawing' macro, however when I attempt to run the macro I get a notification saying
"Run-time error'13': type mismatch" when I click debug it highlights this line "For i = 0 To UBound(vViews)"
I appreciate I am attempting to use something I admittedly know nothing about, but this macro in particular would save me endless amounts of time!
Could you advise me on potential mistakes I am making?
Thanks in advance
Re: My Macros
Posted: Wed May 25, 2022 12:13 pm
by AlexB
DONALT_95 wrote: ↑Wed May 25, 2022 3:42 am
Hi Matt,
I am new to macros and tried to use your 'rename all views in drawing' macro, however when I attempt to run the macro I get a notification saying
"Run-time error'13': type mismatch" when I click debug it highlights this line "For i = 0 To UBound(vViews)"
I got curious and had a look. There's a for loop in there to look through all the views on a sheet. If the view array is empty, meaning there are no views on the sheet, then it will produce an error.
Surround the for loop with this if statement:
If Not IsEmpty(vViews) Then
[for loop]
End If
Code: Select all
If Not IsEmpty(vViews) Then
For i = 0 To UBound(vViews)
Dim swView As SldWorks.View
Set swView = vViews(i)
Select Case swView.Type
Case swDrawingViewTypes_e.swDrawingSectionView
Dim swSectionView As SldWorks.DrSection
Set swSectionView = swView.GetSection
Debug.Print swSectionView.GetLabel
swSectionView.SetLabel2 GetNextName
Case swDrawingViewTypes_e.swDrawingDetailView
Dim swDetailedView As SldWorks.DetailCircle
Set swDetailedView = swView.GetDetail
Debug.Print swDetailedView.GetLabel
swDetailedView.SetLabel GetNextName
End Select
Next
End If
Re: My Macros
Posted: Fri Sep 01, 2023 5:13 am
by Arnaud7.77
Hello everyone,
Do you have a macro for bom export (catia V5 to excel)?
Either from Product to excel
Either from a drawing table to excel
Arnaud
Re: My Macros
Posted: Tue Oct 24, 2023 9:42 am
by mme
Open part or assemblies. Run the macro. Enter a new name. If there is a drawing, it will put the same name on the drawing.
Re: My Macros
Posted: Thu Nov 02, 2023 4:35 am
by Stefan Sterk
mme wrote: ↑Tue Oct 24, 2023 9:42 am
Open part or assemblies. Run the macro. Enter a new name. If there is a drawing, it will put the same name on the drawing.
Hi
@mme,
Sounds the same as this macro;
https://www.codestack.net/solidworks-ap ... t-drawing/
Re: My Macros
Posted: Thu Nov 02, 2023 4:43 am
by mme
Oh! I'm sorry. So I have labored in vain.
Re: My Macros
Posted: Thu Nov 02, 2023 5:07 am
by mme
There is actually some difference. Artyom's macro works with a batch of assemblies and renames the file in the assembly as well. For me, I copy parts or assemblies and rename them along with the drawing.
Re: My Macros
Posted: Sun Apr 21, 2024 5:15 am
by laukejas
Adding my macros as well.
Modify External References - small dialog to Lock / Unlock / Break all references for all components in the assembly. Useful with Master models.
Rebuild Assembly Parts - for when Force Rebuild doesn't cut it. This macro opens each part individually, shakes it down, saves and closes it. Should get these stuck references to update.
Set Image Quality For All Parts - quickly change imaqe quality for all components in an assembly. Useful when you have tons of components that have high quality setting inherited from template or something.
Toggle Tangent Edge Display - quickly toggle tangent edge view without having to go into Options.
Edit Component - we all know how annoying it is that you can't assign Edit Component / Part command to a keyboard shortcut or mouse gesture. But you can with this macro. Select face / feature of any component in the assembly, and it will enter Edit Component mode. Run it again without anything selected, and it will exit Edit Component mode.
Draw CoV - creates a sketch with a point that marks the center of volume (not mass) of the assembly components. Useful when parts have different materials and densities and CoM doesn't match CoV.
Each body to STL - exports each body from a multibody part to an STL. There are some naming rules in there (I use this in conjunction with my Revision Control App (viewtopic.php?t=1823), so there are rules to add revision name to the file. You might want to adjust naming for your use case.