BOM QTY and Vault

BOM QTY and Vault

Anonymous
Not applicable
506 Views
1 Reply
Message 1 of 2

BOM QTY and Vault

Anonymous
Not applicable

I have attached a working ilogic code that many people have helped with. 

 

Here is my over all goal. 

  • Once a design is finished and checked in.
  • Open the main assembly. 
  • Run this BOM Qty code. 
  • Print PDFS. 
  • Export excel BOMS

 

 

The problem that I have this BOM ilogic, is that it asks us to check out all changed parts. I don't want it too!

 

We can say "no to all" and have the changes be temporary, this is actually the desired change. Because we have some standard parts (library parts) that are used in every new sales order. If some one says yes to one or all, then it gets checked in....someone else sees that its changed, it has to be changed back...etc. 

 

I would like to run the code without having the option to check everything out. Just run the code, it temporally adds the SO and QTY to the parts in the assembly. 

 

Could use some help,

Thanks

0 Likes
507 Views
1 Reply
Reply (1)
Message 2 of 2

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Seems to be that you are change the assembly with your code.

See the comments

Sub Main()

    doc = ThisDoc.Document
    Dim oAssyDef As AssemblyComponentDefinition = doc.ComponentDefinition
    Dim oBOM As BOM = oAssyDef.BOM
'Think this is the issue
'if this is not already set the assembly changes
    oBOM.StructuredViewEnabled = True
    oBOM.StructuredViewFirstLevelOnly = False

    Dim oBOMView As BOMView = oBOM.BOMViews.Item("Structured")

    Dim oBOMRow As BOMRow
    Dim oCompDef As ComponentDefinition

    For Each oBOMRow In oBOMView.BOMRows

      oCompDef = oBOMRow.ComponentDefinitions.Item(1)
      
      Call SetRowProps(oCompDef, oBOMRow.TotalQuantity)
      
      If Not oBOMRow.ChildRows Is Nothing
          Call RecurseBOMRow(oBOMRow)
      End If
    Next
End Sub

Sub RecurseBOMRow(oBOMRow As BOMRow)
   For Each oBOMRow In oBOMRow.ChildRows
     Dim oCompDef As ComponentDefinition
     oCompDef = oBOMRow.ComponentDefinitions.Item(1)

     Call SetRowProps(oCompDef, oBOMRow.TotalQuantity)
	


     If Not oBOMRow.ChildRows Is Nothing
          Call RecurseBOMRow(oBOMRow)
     End If
   Next
End Sub

Sub SetRowProps(oCompDef As ComponentDefinition, QTY As String)
 Dim CompFullDocumentName As String = oCompDef.Document.FullDocumentName
 Dim CompFileNameOnly As String
 Dim index As Integer = CompFullDocumentName.lastindexof("\")
 CompFileNameOnly = CompFullDocumentName.substring(index+1)

 'MessageBox.Show(CompFileNameOnly)
'Think this is the issue
'if this is not already set the assembly changes
 iProperties.Value(CompFileNameOnly, "Custom", "PartQty") = QTY
 iProperties.Value(CompFileNameOnly, "Custom", "SO") = iProperties.Value("Custom", "SO") 
End Sub

:

 

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes