Is there a way to combine identical components in BOM table through MACRO? It seems that I cant find the right function for that and macro recorder do not record this step either.
It appears to me this functionality is not included in the API.
Ok, Thanks! at least now i know that.
SPR 1030715-API required for option available in => Indented BOM => Combine Identical Components option.
Mithilesh Kapre Did they ever implement this request? Is this functionality now available in 2021? A macro to combine identical components would be a tremendous time saver.
I am running Solidworks 2021 SP01.
Thanks in advance!
I just checked the "Knowledge base" (in quotes because it hardly contains any knowledge) and this request is still open and not implemented.
Thank-you Peter Brinkhuis! Doesn't surprise me at all.
Yes its still Open. This will take a while to be exposed.
Check this solution: Combine identical components command in SOLIDWORKS BOM table using SOLIDWORKS API
Wow - thanks for sharing. This is the first I've seen a SW command invoked using Windows API. Did some digging, and wanted to share your blog on this subject, if that's okay,Artem Taturevych.
SOLIDWORKS API Command Doesn't Exist? Need plan B
Thank you, Austin. I prefer to use this instead of ISldWorks::RunCommand as it is executed instantly, but ISldWorks::RunCommand takes like 1-second delay for each call for some reasons.
Artem Taturevych wrote: Check this solution: Combine identical components command in SOLIDWORKS BOM table using SOLIDWORKS API
Artem Taturevych wrote:
Artem Taturevych I tried your macro you shared and it keeps throwing an error on
Set swFrame = swApp.Frame'
It says variable not set. I have done some programing in the past, but I'm not very familiar with VBA so I'm not sure what is wrong.
#If VBA7 Then Private Declare PtrSafe Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long#Else Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long#End IfDim swApp As SldWorks.SldWorksSub main() Set swApp = Application.SldWorks Dim swModel As SldWorks.ModelDoc2 Set swModel = swApp.ActiveDoc Dim swBomTable As SldWorks.TableAnnotation Set swBomTable = swModel.SelectionManager.GetSelectedObject6(1, -1) CombineIdenticalComponents swModel, swBomTable, 1, swBomTable.RowCount - 1 End SubSub CombineIdenticalComponents(model As SldWorks.ModelDoc2, table As SldWorks.BomTableAnnotation, startRowIndex As Integer, entRowIndex As Integer) Dim swSelMgr As SldWorks.SelectionMgr Set swSelMgr = model.SelectionManager Dim swSelData As SldWorks.SelectData Set swSelData = swSelMgr.CreateSelectData Dim swTableAnnotation As SldWorks.TableAnnotation Set swTableAnnotation = table Dim swAnn As SldWorks.Annotation Set swAnn = swTableAnnotation.GetAnnotation() swSelData.SetCellRange startRowIndex, entRowIndex, 0, 0 swAnn.Select3 False, swSelData RunCombineIdenticalComponentsCommand End SubSub RunCombineIdenticalComponentsCommand() Const WM_COMMAND As Long = &H111 Dim swFrame As SldWorks.Frame Set swFrame = swApp.Frame Const CMD_COMBINE_IDENTICAL_COMPONENTS As Long = 24378 SendMessage swFrame.GetHWnd(), WM_COMMAND, CMD_COMBINE_IDENTICAL_COMPONENTS, 0End Sub
Any help is appreciated!
You need to select the BOM table before running the macro.
Edit: I see the issue. You need to run the macro from the main sub. Just open for editing and run from main
I have now modified the macro to remove any ambiguity so you will not see this error anymore.
Thank you much Artem Taturevych. I will give it a try.
I finally got a chance to try it Artem Taturevych and works excellently! Thanks a lot Artem! This will save me a lot of time.
Retrieving data ...