Hi everyone,
I would like pay your attention to methods of BOM object. It has two methods: GetPartNumberMergeSettings and SetPartNumberMergeSettings.
With setter everything is clear, however, not with getter. If you take a look on this method you will see that it has two arguments MergeEnabled and MergeExcludeList(). This is actually unclear. Why does getter have these arguments???
Thanks.
Solved! Go to Solution.
Solved by YuhanZhang. Go to Solution.
The two arguments in the SetPartNumberMergeSettings are output arguments for you to get the value of the MergeEnabled and MergeExcludeList, so you need to declare two variables to receive them, below VBA code demonstrate how to use them:
Sub Test()
Dim oDoc As AssemblyDocument Set oDoc = ThisApplication.ActiveDocument Dim oBOM As BOM Set oBOM = oDoc.ComponentDefinition.BOM Dim sKeys(1) As String sKeys(0) = "Part1" sKeys(1) = "Part2" Call oBOM.SetPartNumberMergeSettings(True, sKeys) Dim sList() As String Dim bMerge As Boolean Call oBOM.GetPartNumberMergeSettings(bMerge, sList) Debug.Print "The BOM rom merge is enabled: " & bMerge Dim i As Long For i = LBound(sList) To UBound(sList) Debug.Print "The merge exclude list item " & i&; ": " & sList(i) Next
End Sub
Hope this explains.
Hi yuhanzhang,
Thank you for responce. It's clear for VBA. What about Intent?
Hi Lesoux,
Intent can not call .Net members with ByRef or Out parameters in their signature. The only workaround is to call such methods from managed code.
It just means that I can't use some API methods in Intent.
Clear.
Thank you everyone.
@YuhanZhang (Rocky),
I know this is an old post, but I thought it relevant rather than starting a new post.
So do you have to know the names of parts in the active assembly in order to populate the string array (sList)?
Could you just use "<BLANK>"?
I look forward to your reply.
Regards,
Jerry
Hi Jerry,
It is up to what you want to exclude. The string array can be any part number strings, they need not to be in the assembly currently(they may be placed in the future). If you want to exclude some part numbers in current assembly you can iterate the referenced documents(AssemblyDocument.AllReferencedDocuments) to find the ones.
As for the "<BLANK>", it is the default item in the exclude list no matter you set it or not, so if you want to clear the list you can use a string array with only one "" value, or with one "<BLANK>" value.
Thanks for the clarification, Rocky.
I have the code working now so that I can warn users if Row Merging has been detected.
Much appreciated.
Regards,
Jerry