Ilogic save problem

Ilogic save problem

tegstette
Advocate Advocate
375 Views
1 Reply
Message 1 of 2

Ilogic save problem

tegstette
Advocate
Advocate

HelloSmiley Happy

 

I am a beginner at ilogic and I am playing around with some ilogic rules, but cannot seem to figure this one out... I need a simple ilogic rule that does something like this:

 

  1. If the file is not yet saved (typical for new parts from a template) – do nothing
  2. If the file is saved (has a filename) and BOM-quantity is «Each» - do nothing
  3. If the file is saved (has a filename) and BOM-quantity is not «Each» - set BOM-quantity to «Each»

 

'set the Base Quantity to the parameter Each

  1. ThisDoc.Document.ComponentDefinition.BOMQuantity.SetBaseQuantity(BOMQuantityTypeEnum.kEachBOMQuantity)

 

Is there anyone that can help me out?

Best regards
TG

Autodesk Inventor/Vault Professional 2021
0 Likes
376 Views
1 Reply
Reply (1)
Message 2 of 2

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

Please refer to the code below. Hope it helps you.

 

 

doc = ThisDoc.Document

 

If doc.FileSaveCounter = 0 Then

  ' If the file is not yet saved (typical for new parts from a template) – do nothing

  MsgBox("The Document has not been saved!")

Else

 

    Dim oAssDef As AssemblyComponentDefinition

    oAssDef = doc.ComponentDefinition

   

    Dim oBOMType As BOMQuantityTypeEnum

    oAssDef.BOMQuantity.GetBaseQuantity (oBOMType)

   

    If oBOMType = BOMQuantityTypeEnum.kEachBOMQuantity Then

     'If the file is saved (has a filename) and BOM-quantity is ?Each? - do nothing

      MsgBox("The BOM Quantity type is Each!")

    Else

     'If the file is saved (has a filename) and BOM-quantity is not ?Each? - set BOM-quantity to ?Each?

     MsgBox("The BOM Quantity type is NOT Each!")

      oAssDef.BOMQuantity.SetBaseQuantity (BOMQuantityTypeEnum.kEachBOMQuantity)

    

    End If

   

End If

 

0 Likes