I have a sketchedsymbol with leaderline. How can I get the BOM of the item this is attached to? I don't see any referenced way to do this. I assume it's possible because a balloon can get this info.
The full extent of what I want to do is to create a split balloon symbol. The top portion of the balloon with hold the detail number, the botton half will hold a user prompted text entry.
Solved! Go to Solution.
Solved by adam.nagy. Go to Solution.
To clarify, I'm looking for the Detail Number(Item Number) of the assembly it gets attached to.
You could consider the following references chain to get ItemNumber and other BOM characteristics.
Balloon -> BalloonValueSet -> DrawingBOMRow -> BOMRow -> ItemNumber
Select the balloon and run this sample code:
Sub GetBOMRowfromBaloon() Dim oDrawDoc As DrawingDocument Set oDrawDoc = ThisApplication.ActiveDocument Dim SSET As SelectSet Set SSET = oDrawDoc.SelectSet Dim oBalloon As Balloon Set oBalloon = SSET.Item(1) Dim oBalloonValueSet As BalloonValueSet Set oBalloonValueSet = oBalloon.BalloonValueSets.Item(1) Dim oDrawingBOMRow As DrawingBOMRow Set oDrawingBOMRow = oBalloonValueSet.ReferencedRow Dim oBOMRow As BOMRow Set oBOMRow = oDrawingBOMRow.BOMRow Dim ItemNumber As String ItemNumber = oBOMRow.ItemNumber MsgBox ItemNumber Beep End Sub
Hope this helps.
That code only works for balloons. I'm working with sketchedsymbols. From what I can tell sketchedsymbols don't have a valueset for the item the leader is attached to.
There's 2 ways I can make my addin work. I can either get the itemnumber from the leader for a sketchedSymbol. (effectively replicating what the balloon command does)
The other option would be to find a way to add a user prompted text entry to a split balloon so it could hold both the item number and a user prompted entry. I don't believe this is an option in Inventor, which is why I'm exploring the first option.
OK, let’s try another approach:
Leader -> RootNode -> ChildNode -> GeometryIntent -> DrawingCurve
Dim oLeader As Leader Set oLeader = oSymbol.Leader Dim oNode As LeaderNode Set oNode = oLeader.RootNode.ChildNodes.Item(1) Dim oIntent As GeometryIntent Set oIntent = oNode.AttachedEntity Dim oDC As DrawingCurve Set oDC = oIntent.Geometry
As you get DrawingCurve object you are able (a) to find the reference to the AssemblyDocument and its BOM object and (b) to find the ComponentDefinition via DrawingCurve.ModelGeometry property.
ComponentDefinition allows you to find the reference to the BOMRow that represents your component in the BOM.
Select your sketched symbol with the leader and run the attached VBA test. This is a proof of idea so feel free to customize it to your needs.
Cheers,
Now that the forums are back up...
The code you posted works very well for most cases. However it does still appear to differ from the way balloons get the item number. I know the api side, not the engineering side so I can't really explain what items it does/does not work for. I can send you a small sample file in private if that would help.
In my specific instance it isn't working on a purchased component. However I don't know if that's by coincidence, or if it doesn't work for any purchased parts.
My previous sample code works fine if the sketched symbol is attached
to the drawing curve that belongs to part but fails if it belongs to subassembly.
It is not important either it is purchased component or not.
Let's consider more sophisticated approach to fix this problem. It consists of the following steps.
First, we can easily find the drawing curve sketched symbol is attached to (oTargetDC).
Second, using DrawingBOM we may find all occurrences that are graphically
represented in the drawing view
(DrawingBOMRow --> BOMRow --> ComponentDefinitions --> Occurrences list).
Finally, for each occurrence we may find out all its drawing curves and
check if oTargetDC belongs to this curves set or not.
If belongs then BOMRow.ItemNumber gives us the required value.
Test code is attached. It works on my side.
Cheers,
Hi,
I'm thinking that the easiest might be to let the Balloon object figure out what you need: http://adndevblog.typepad.com/manufacturing/2013/11/get-itemnumber-from-the-drawingcurve.html
Cheers,
The code by Vladimir appears to work perfectly, but I like the idea of piggybacking off of the official balloon command for itemnumber. Looks like you wrote that blog post specific for me, so thanks!