Hi,
I'm trying to sort a structured BomView trough .Net Api in Inventor 2012.
I'm using Sort method of BOMView object.
I don't get any error but BOM isn't changed after this call.
Any ideas?
I've tried :
oBv.Sort("Item") or oBv.Sort("Item", False)
oBv.Sort("Part Number") or oBv.Sort("Part Number", False)
Thanks in advance
Hi,
thanks for your reply, probably I wasn't so clear.
My problem regards "Sort" method.
I call it properly but seems that it doesn't work.
Have you tried your code with a concrete case?
Thanks in advance
Hi. Yea i have this code working fine in 2012. It in VBA so remove the 'set'.
Dim oBOMView As BOMView: Set oBOMView = thisapplication.activedocument.ComponentDefinition.BOM.BOMViews.Item("Structured")
'Call the sort and renumber methods. Sort in ascending order.
Call oBOMView.Sort("column name", True)
Call oBOMView.Renumber(1, 1)
My memory wasnt far off.
Hi,
i've tried this code in VBA without getting result.
Sub SortBom()
Dim oBOMView As BOMView
Dim oBOM As BOM
Set oBOM = ThisApplication.ActiveDocument.ComponentDefinition.BOM
oBOM.StructuredViewEnabled = True
Dim bv As BOMView
For Each bv In oBOM.BOMViews
If bv.ViewType = BOMViewTypeEnum.kStructuredBOMViewType Then
Set oBOMView = bv
Exit For
End If
Next
'Call the sort and renumber methods. Sort in ascending order.
Call oBOMView.Sort("Part Number", False)
End Sub
Probably it doesn't work because of my Italian version?
If I use italian translation of column name, Sort method generates one error.
Thanks in advance
I think you are making it more difficult than it needs to be. Did you try my code? I tried the code as well and it doesnt like the oBOM declaration.
Whats the point in looping through the bomviews (of which there are only three, only two of which can be addressed in the api) if you are only sorting one view. Just address it directly then sort it.
Maybe its a language thing. I did read somewhere the other day about german characters being interpreted differantly.
Sorry for this delay.
I tried you code but the result is the same.
I'm even more sure the problem is in Sort method.
In my sample BOM there aren't strange characters.
My code not working I want sort by bom structure
oStructuredBOMView.Sort("BOM structure", True)
Message = (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"
comand oStructuredBOMView.Sort("Part Number", True) worked
Thank you
The code of CadUser46 works indeed.
But make sure you don't have the BOM opened on your screen, otherwise the code won't execute on the .sort function
I can confirm it: there is something awkward in the Sort method.
I am trying to sort on Item Number
call oBOMView.Sort("Item", True)
and I do not see any effect in the BOM view (renumbering is another story). I also tried to sort on Part Number
call oBOMView.Sort("Part Number", True)
without seeing any effect.
The method does not fail, but apparently no result is visible (and I'm using inventor in English).
Shall we try to escalate it or can anybody actually sort the BOMView via VBA successfully?
(or maybe the "case is closed" because it is too old??)