Parts Only Quantity

Parts Only Quantity

Anonymous
Not applicable
1,402 Views
5 Replies
Message 1 of 6

Parts Only Quantity

Anonymous
Not applicable

Hi

We have suppressed parts and unsuppressed parts in one assembly. We used this code in iLogic 

 

ThisBOM.CalculateQuantity("Model Data", oCompPartNumber)

 

But this code for "Model Data" gives us  total quantity of suppressed and unsuppressed parts.

 

Then we used this code in Inventor API 

 

quantity = ThisApplication.ActiveDocument.ComponentDefinition.BOM.BomViews(1).BomRows(1).TotalQuantity

 But this code gives "1" 

We need a code for quantity of unsuppressed parts in Inventor API

 

Thanks for replying 

0 Likes
Accepted solutions (1)
1,403 Views
5 Replies
Replies (5)
Message 2 of 6

wayne.brill
Collaborator
Collaborator

Hi,

 

I asked a colleague in Inventor Engineering and he confirms that the Inventor BOM is stored in the Master Level Of Detail and suppression can only take place in a non-master LOD. This effects behavior in the Inventor API including iLogic.  (you can see this in the user interface too)

Here is an approach to consider:

Have two rules. Run this rule with the custom level of detail current:

' Change this to the parts you want to suppress
Component.IsActive("Part_WB_2-24-16:2") = False
Component.IsActive("Part_WB_2-24-16:3") = False

Then switch to the Master level of detail and run this rule to get just the non suppressed occurrences:

ThisBOM.Export("Structured", "BomExport.txt", kTextFileTabDelimitedFormat)
'Change this to the parts in your assembly
quantity = ThisBOM.CalculateQuantity("Model Data", "Part_WB_2-24-16")
MessageBox.Show("Number of Part_WB_2-24-16 Not suppressed = " & quantity, "Title")

 

This works because the iLogic  Component.IsActive("xxxx") = False statement not only suppresses the component, but also sets the BOM Structure to Reference. This takes it out of the BOM. So even though there are no suppressed components in Master, they will still have their BOM Structure set to Reference.  That’s the same in all LODs.

The ThisBOM.Export statement is required to make sure that the BOM is up to date before trying to get a quantity out of it.

 

If you want a change so that you could directly get the suppressed parts in the Inventor API please log it on the Inventor idea station:

http://forums.autodesk.com/t5/inventor-ideastation/idb-p/v1232/tab/most-recent

 

 

Thanks,

Wayne

 

 

 



Wayne Brill
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 6

tolgay.hickiran
Advisor
Advisor

Hello Wayne,

Do you suggest us using a For Each loop for all sub assemblies and picking the master LOD, because our assemblies are automated with ilogic and some vb.net coding.

The actual case is that, we have a full parametric model, and we get all the sheet flat patterns from a third party program. It takes the iproperties and put it on the .dwg s(or .dxf s).

Can you explain


Some worthwhile ideas
Copy Design should rename ilogic Rules too!
Why Nastran In-CAD doesn't have an SDK?IMPLEMENTED!

Tolgay Hickiran
Founding Partner
SignatureSignature

website
emailskypelinkedinyoutubeemail

0 Likes
Message 4 of 6

wayne.brill
Collaborator
Collaborator
Accepted solution

Hi,

 

I would suggest not using the BOM functionality in the API if you are trying to only count the occurrences that are not suppressed. (This would be in a non Master level of detail).

 

The AssemblyCount VBA example in the Programming Help iterates through the occurrences. You could use the Suppressed property of each occurrence to get a count of the parts that are not suppressed. You could use that approach using the Inventor API in an iLogic rule.

 

This DevBlog post could also be useful:

http://adndevblog.typepad.com/manufacturing/2015/02/list-suppressed-components-in-lod.html

 

 

Let me know if there is a problem using this approach.  

 

Thanks,

Wayne 



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 5 of 6

tolgay.hickiran
Advisor
Advisor
So Wayne,

We ended up typing the code and its working. Only thing left is to count for different part names. Thank you very much.

Sub Asd()
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
Debug.Print oAsmDoc.DisplayName

Dim oAsmDef As AssemblyComponentDefinition
Set oAsmDef = oAsmDoc.ComponentDefinition

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oOcc As ComponentOccurrence
Dim Occurrences As ComponentOccurrences

Dim i As Integer
i = 0

For Each oOcc In oAsmDef.Occurrences
If (oOcc.Suppressed) = False Then
Debug.Print oOcc.Name
i = i + 1
End If
Next

MsgBox (i)

End Sub

Some worthwhile ideas
Copy Design should rename ilogic Rules too!
Why Nastran In-CAD doesn't have an SDK?IMPLEMENTED!

Tolgay Hickiran
Founding Partner
SignatureSignature

website
emailskypelinkedinyoutubeemail

0 Likes
Message 6 of 6

tolgay.hickiran
Advisor
Advisor
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
Dim oAsmDef As AssemblyComponentDefinition
oAsmDef = oAsmDoc.ComponentDefinition
Dim oOkka As Document
'oOkka = ThisDoc.Document
oOkka = ThisApplication.Documents.ItemByName(oRefDoc.FullDocumentName)
Dim oOccs As ComponentOccurrencesEnumerator
oOccs = oAsmDef.Occurrences.AllReferencedOccurrences(oOkka)
Dim p As Integer
p=0
Dim oOcc As ComponentOccurrence
'Dim Occurrences As ComponentOccurrences
For Each oOcc In oOccs
If (oOcc.Suppressed) = False Then
p = p + 1
End If
Next

every other p value gives us the TotalQuantity

Thanks again Wayne,
Tolgay

Some worthwhile ideas
Copy Design should rename ilogic Rules too!
Why Nastran In-CAD doesn't have an SDK?IMPLEMENTED!

Tolgay Hickiran
Founding Partner
SignatureSignature

website
emailskypelinkedinyoutubeemail

0 Likes