BOMViews Object Query

BOMViews Object Query

tdant
Collaborator Collaborator
1,273 Views
11 Replies
Message 1 of 12

BOMViews Object Query

tdant
Collaborator
Collaborator

Hey all,

 

Is there a way to query the BOMViews object for a particular BOMRow by the properties of the BOMRow? I'm trying to get the BOM Item number by Part Number.

0 Likes
Accepted solutions (1)
1,274 Views
11 Replies
Replies (11)
Message 2 of 12

MechMachineMan
Advisor
Advisor

A function along these lines should work for you.

 

BOMRow.PARENT is the proper call, but if it is a child row, it will just return the parent row, so some recursion is built in to ensure it finds the BOM View

 

 

Sub Main()

End Sub

Function GetBOMRowParentBOMView(oBOMRow As BOMRow) As BOMView
    
    oParent = oBOMRow.Parent

    If oParent.Type = 100674304 'kBOMViewObject
        GetBOMRowParentBOMView = oParent
    Elseif oParent.Type = 100674816 'kBOMRowObject
        oBOMView = GetBOMRowParentBOMView(oBOMRow)
        GetBOMRowParentBOMView = oBOMView
    Else
        MsgBox("Parent Object Neither BOMRow nor BOM View" & vblf & oParent.Type")
        GetBOMRowParentBOMView = Nothing
    End if
      

Next

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 12

tdant
Collaborator
Collaborator

Correction: I'm running my query on BOMRows looking for the row that bears a target part number.

0 Likes
Message 4 of 12

MechMachineMan
Advisor
Advisor

Sorry, It appears I completely misread that one.

 

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-33A8C8DA-FBD9-41DF-A7BD-793C693A485A

 

The link shows the standard way of iterating through the BOM Rows.

 

Without a specific call to find the property, you are left writing your own.

 

Also, there is a recursive call to use as outlined in the following article:

http://modthemachine.typepad.com/my_weblog/2009/03/accessing-assembly-components.html

 

 

 

Also, saying "find the Bom row OR ROWS that contain part number'x'" could either return all of the rows, the first one, or just one. I think you might need some further criteria.

Also, why not just iterate through the AllReferencedDocuments instead of using the more complex BOMView?


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 5 of 12

tdant
Collaborator
Collaborator

I'm trying to extract the item number from the bill of materials and use it as the view label on my drawings. I want that view label to always match the parts list that's displayed on the drawing, which is always the parts only list. I think the only way to do that is through BOMView.Item("Parts Only"). Am I right?

0 Likes
Message 6 of 12

MechMachineMan
Advisor
Advisor

So you want a balloon without the circle and no leader?

 

(To hide balloon leader - https://forums.autodesk.com/t5/inventor-ideas/delete-balloon-leader/idi-p/6642017)

 

 

Are you planning on using a sketched symbol prompted entry to populate with the Item Number and use as a substitute view label?

 

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 7 of 12

tdant
Collaborator
Collaborator

Nope. I want to use the same thing the balloon uses in the text of my view label.

 

What I really want is for Inventor to have a native function that will do that in the same way as it can the part number.

0 Likes
Message 8 of 12

MechMachineMan
Advisor
Advisor

And you are just wanting the view label to show the main document of the view, and not a specific one? When are you planning on making the iLogic automatically add this information? What's your plan for updating it if the drawing changes?

Also, sounds like a good suggestion for the Idea forums!


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 9 of 12

tdant
Collaborator
Collaborator

I want the BOM Item number to follow the view label in exactly the same way that it follows the balloons. Any time the item number changes on the parts list, it also changes in the balloons. It seems like it would be easy to apply the same logic to the view labels. Ideally, I would put all this in an iLogic rule that's always active so it updates in real time.

0 Likes
Message 10 of 12

tdant
Collaborator
Collaborator

If I could get this loop to work, I'd be in the clear:

 

For Each BOMRow In ParentPOBOM.BOMRows
    
Dim CompDefs As ComponentDefinitionsEnumerator Set CompDefs = BOMRow.ComponentDefinitions
If CompDefs.Item(1) = ViewPart Then
BOMItem = BOMRow.ItemNumber 'set the view label to "POSITION " & BOM Item Number View.Label.FormattedText = "POSITION " & BOMItem Else View.Label.FormattedText = "ERR BOM" End If
Next

but I'm getting "object doesn't support this property or method" on CompDefs.Item(1).

0 Likes
Message 11 of 12

MechMachineMan
Advisor
Advisor
Accepted solution

Because you are trying to compare 2 objects. Use the "is" keyword in VBA instead. Or there's an object equals method otherwise.

 

 

If CompDefs.Item(1) Is ViewPart Then

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 12 of 12

tdant
Collaborator
Collaborator

Ah. I was barking up the wrong tree the whole time. I blame it on Excel.

 

Thanks for the help Mech.

0 Likes