When I run the macro I got a error: Run-time error ’91’: Object variable or With block variable not set
And the following line is highlighted: Set swBomFeat = swBomAnn.BomFeature
What am I doing wrong or what do I need to edited to the code?
I want to be able to delete a BOM and reassign a new BOM only if the old BOM don’t correspond to a certain given BOM template. Have you ever found a way to get the actual Template Name of the BOM already used in a drawing?
I have tried using BomFeature, but it doesn’t seems to have this particular information available. Is there anyway to proceed using GetFeature? If yes, could you give me a hint how to proceed?
I do not think that BOM templates are linked in any way to the table that is created from them, hence it is not possible to obtain this information. I do not see a way to obtain that information manually let alone programmatically. Really, a BOM table need not have anything in common with the template it was created from. (It could be modified heavily after it was inserted.) Hence the information you’re looking for might be useful from a historical point of view but not from the point of view of knowing what is actually in that BOM table.
What you should do is examine the BOM table’s actual properties — its row names, column names, cell contents, and IBomFeature properties to see if that BOM table meets a certain criteria. If it doesn’t, then you recreate the BOM table.
Ready to start learning the SolidWorks API? Sign up for FREE membership here.Keep up with new videos, macros, and training events by joining our mailing list:
When I run the macro I got a error: Run-time error ’91’: Object variable or With block variable not set
And the following line is highlighted: Set swBomFeat = swBomAnn.BomFeature
What am I doing wrong or what do I need to edited to the code?
You need to have an assembly drawing view selected; it isn’t possible to insert a top-level BOM into a drawing view of only a part.
Hello Keith,
I want to be able to delete a BOM and reassign a new BOM only if the old BOM don’t correspond to a certain given BOM template. Have you ever found a way to get the actual Template Name of the BOM already used in a drawing?
I have tried using BomFeature, but it doesn’t seems to have this particular information available. Is there anyway to proceed using GetFeature? If yes, could you give me a hint how to proceed?
Thank you.
I do not think that BOM templates are linked in any way to the table that is created from them, hence it is not possible to obtain this information. I do not see a way to obtain that information manually let alone programmatically. Really, a BOM table need not have anything in common with the template it was created from. (It could be modified heavily after it was inserted.) Hence the information you’re looking for might be useful from a historical point of view but not from the point of view of knowing what is actually in that BOM table.
What you should do is examine the BOM table’s actual properties — its row names, column names, cell contents, and IBomFeature properties to see if that BOM table meets a certain criteria. If it doesn’t, then you recreate the BOM table.
Hello Keith,
How would a go about using a BOM in a specified location?
“Material_BOM.sldbomtbt” in folder “C:\Solidworks Templates\BOM”
Thanks in advance
I believe that you would need to use IModelDocExtension.InsertBomTable3, which has an argument that lets you specify the template name.