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: 

Ilogic save problem

1 REPLY 1
Reply
Message 1 of 2
tegstette
215 Views, 1 Reply

Ilogic save problem

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
1 REPLY 1
Message 2 of 2
xiaodong_liang
in reply to: tegstette

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

 

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

Post to forums  

Autodesk Design & Make Report