I tried to search but failed to succeed. Is someone aware of macro that can help me assign all my views (section, details) on multiple sheet to a BOM.
Thanks for the clarification, Amol.
I believe you are looking for something like this:
Specify the referenced BOM Table name as the "BOMName" constant.
Dim swApp As SldWorks.SldWorksDim swDraw As SldWorks.DrawingDocDim vSheets As VariantDim vViews As VariantDim swView As SldWorks.View
Const BOMName As String = "Bill of Materials1"
Set swApp = Application.SldWorks Set swDraw = swApp.ActiveDoc vSheets = swDraw.GetViews Dim i As Integer Dim j As Integer For i = 0 To UBound(vSheets) vViews = vSheets(i) For j = 0 To UBound(vViews) Set swView = vViews(j) swView.SetKeepLinkedToBOM True, BOMName Next Next End Sub
Could you please clarify what are you looknig for. Since I'm a little bit confused. The steps to reproduce the issu via UI would be the best.
I have SW drawings having multiple sheets and each sheet is having atleast 4 to 5 views of assembly. I want all these views linked to BOM for which I have to right click each view, go into its properties and check mark the option where it says " Link to BOM" .
If I can generate a macro which picks all the views in all sheet in one go and link to BOM.
Thanks a lot Artem. this was exactly i wanted. Once again thanks a lot.
I will try to use same principle for assigning configurations to all views in all of my sheets....
this will really save lot of my time and defects.... thanks...
This macro from Artem has been very useful and in heavy use :-)
After updating SW2009SP5.0 it is not working any more (It was fine with SP4.1)!
Any advice? (Vista Business 64 bit)
Macro started working after renaming all variables. Hmmm ... Don't know what to say ...
this one will find the BOM name for you then link all the views to it.
Dim swApp As SldWorks.SldWorksPrivate Const strApp As String = "Link2BOM v1.00"
Public Sub subMain() Dim iCnt, iTotal As Integer Dim retVal As Variant Dim sBOMname As String Dim vSheetNames As Variant Dim swView As SldWorks.View Dim swSheetView As SldWorks.View Dim swModel As SldWorks.ModelDoc2 Dim swDrawing As SldWorks.DrawingDoc Dim swFeat As SldWorks.Feature Dim swBOM As SldWorks.Feature Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swDrawing = swModel Set swFeat = swModel.FirstFeature 'Get BOM name Do While Not swFeat Is Nothing If "BomFeat" = swFeat.GetTypeName Then Set swBomFeat = swFeat.GetSpecificFeature2 Set swBOM = swBomFeat.GetFeature sBOMname = swBOM.Name Exit Do End If Set swFeat = swFeat.GetNextFeature Loop vSheetNames = swDrawing.GetSheetNames iTotal = UBound(vSheetNames) + 1 iCnt = 0
Do While iCnt < iTotal 'Set view linked to BOM retVal = swDrawing.ActivateSheet(vSheetNames(iCnt)) Set swSheetView = swDrawing.GetFirstView Set swView = swSheetView.GetNextView Do While Not swView Is Nothing retVal = swView.SetKeepLinkedToBOM(True, sBOMname) Set swView = swView.GetNextView Loop iCnt = iCnt + 1 Loop
retVal = swDrawing.ActivateSheet(vSheetNames(0)) swApp.SendMsgToUser2 " Linking is complete... ", swMbInformation, swMbOk
Set swApp = Nothing Set swModel = Nothing Set swDrawing = Nothing Set swFeat = Nothing Set swBomFeat = Nothing Set swBOM = Nothing Set swSheetView = Nothing Set swView = Nothing EndEnd Sub
This is great help... this code again saves my time because i need not modify my code for different bom names... Thanks
Exactly what I wanted!
Thanks great macro, can't say how often the lack of such and macro has bitten me in the behind. Often had balloon numbers not matching the BOM.
HI, thanks for this macro. It really works, but it is not automatically linking the views to the BOM as I have to run the macro again and again to link the views to the BOM whenever I insert the new BOM in the drawing sheet. Can you please modify this program so that once I run the macro it automatically links the view to the BOM every time when I insert the new BOM.
Did you get the workaround to link view of individual component to the BOM?
you cant manually do that in SW2007, which the code was written for.
I have been trying to get it to work in 2009 but I just wont link those type of views. SetKeepLinkedToBOM returns false for individual components.
Retrieving data ...