Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get the BOM of item leader is attached to

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
bsee1
783 Views, 8 Replies

How to get the BOM of item leader is attached to

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.

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1
8 REPLIES 8
Message 2 of 9
bsee1
in reply to: bsee1

To clarify, I'm looking for the Detail Number(Item Number) of the assembly it gets attached to.  

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1
Message 3 of 9
Vladimir.Ananyev
in reply to: bsee1

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.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 4 of 9
bsee1
in reply to: Vladimir.Ananyev

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.

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1
Message 5 of 9
Vladimir.Ananyev
in reply to: bsee1

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,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 6 of 9
bsee1
in reply to: Vladimir.Ananyev

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.

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1
Message 7 of 9
Vladimir.Ananyev
in reply to: bsee1

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,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 8 of 9
adam.nagy
in reply to: bsee1

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,



Adam Nagy
Autodesk Platform Services
Message 9 of 9
bsee1
in reply to: adam.nagy

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!

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report