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 Error When Opening BOM

4 REPLIES 4
Reply
Message 1 of 5
kwalker1
587 Views, 4 Replies

iLogic Error When Opening BOM

After much research on the internet, I’m in need of some assistance from the good people in this forum to help resolve an iLogic error I’m experiencing when I open the Bill Of Materials (BOM) in the assembly files.

 

1. Model Set-Up

My model is created in a hierarchy format such as the following:

a) Parts                  (e.g. Column Steel Section, Stiffener Plates, etc.)

b) Sub-Assembly  (e.g. Column & stiffener plates welded together to form a Mark Number)

c) Full Assembly  (e.g. Mark Numbers assembled together to form a Structure Assembly)

 

Each Sub-Assembly and Full Assembly file is created and saved on a custom Level of Detail called "Automated Model".

 

I have the Sub-Assembly files with iLogic code to suppress or make active certain components (such as some stiffener plates) within the model depending on a parameter’s value.

The iLogic code I'm running is as follows:

 

If Parameter("STIFFENER_REQUIREMENT") = 0 Then
Component.IsActive("COLUMN 1 - STIFFENER PLATE:1") = False
Component.IsActive("COLUMN 1 - STIFFENER PLATE:2") = False
ElseIf Parameter("STIFFENER_REQUIREMENT") = 1 Then
Component.IsActive("COLUMN 1 - STIFFENER PLATE:1") = True
Component.IsActive("COLUMN 1 - STIFFENER PLATE:2") = True
End If

 

And the iLogics are triggered to run when the following events occur:

- After open document

- Before save document

 

 

2. The Error Encountered

The above iLogic code performs perfectly. It suppresses / activates the components as it should and updates the BOM as it should.

 

But when in the Full Assembly file (with the customer Level of Detail called "Automated Model" active) and I click on the Bill Of Materials, I always get the following error appear:

 

Error in rule: iLogic Rules, in document: COLUMN 1.iam

 

Component.IsActive: Cannot change the suppression state of component COLUMN 1 - STIFFENER PLATE:1.

The active Level of Detail in COLUMN 1.iam is not a custom Level of Detail.

 

 

The above error dialogue box appears multiple times for each iLogic rule in the model’s Sub-Assemblies.

This is despite the Full Assembly & Sub-Assemblies already set to the custom Level of Detail ("Automated Model") and remaining on the custom Level of Detail even after closing the BOM.

 

 

The error seems to be a benign error and only generates these annoying dialogue boxes without any adverse effects on the model.

But my models are quite large and often end up having about 40 dialogue boxes appear when opening the BOM. If I make any changes to the BOM and save it, then I have another 40 dialogue boxes appear. In some large models, it gets to the point where it is unmanageable.

 

Does anyone else experience these same kind of errors?

Is there anything wrong with my code or model set-up?

I have attached a small example of a model with the iLogic error.

 

Any assistance in resolving this error would be greatly appreciated.

 

(Running model on Inventor 2014)

4 REPLIES 4
Message 2 of 5
LukeDavenport
in reply to: kwalker1

Hi kwalker1

 

It looks like Inventor is triggering the ilogic rule when you try to access the BOM, but only because you have the 'After Open Document' event trigger applied to the rule. Why is the 'After Open Document' event being triggered? Well it is a bit strange, but Inventor loads the 'Master' LOD every time you access the BOM, and it looks like that is being considered as 'Opening' a document....

 

Solutions - either 1) or 2)

 

1) Suppress the iLogic rule in the sub-assembly and only run it explicitly (i.e. by running it from the top level when required - add the iLogic rule as a button on a form in the top level for instance). With the rule suppressed, it won't run when you open the BOM and won't give you an error.

 

2) If you don't need the 'After Open Document' trigger set - delete this on all the sub assemblies and the rule won't trigger when accessing the BOM and you won't get the error.

 

Does that help?

Message 3 of 5
thomaskennedy
in reply to: kwalker1

A bit of a cheat, but you could enclose your code in a 'Try Catch' statement.

 

Try

If Parameter("STIFFENER_REQUIREMENT") = 0 Then
Component.IsActive("COLUMN 1 - STIFFENER PLATE:1") = False
Component.IsActive("COLUMN 1 - STIFFENER PLATE:2") = False
ElseIf Parameter("STIFFENER_REQUIREMENT") = 1 Then
Component.IsActive("COLUMN 1 - STIFFENER PLATE:1") = True
Component.IsActive("COLUMN 1 - STIFFENER PLATE:2") = True
End If

Catch 'Assume the error means wrong LOD
End Try

 

When the error occurs the code will jump to the 'Catch' part of the logic.

In your case it means we can catch and ignore the errors.

The risk here is that genuine errors will be ignored and could produce an invalid BOM.

 

 

The alternative is to exit the rule when the LOD is not 'Automated Model' :

 

 

If ThisDoc.Document.ComponentDefinition.RepresentationsManager.ActiveLevelOfDetailRepresentation.Name <> "Automated Model" Then Exit Sub

If Parameter("STIFFENER_REQUIREMENT") = 0 Then
Component.IsActive("COLUMN 2 - STIFFENER PLATE:1") = False
Component.IsActive("COLUMN 2 - STIFFENER PLATE:2") = False
ElseIf Parameter("STIFFENER_REQUIREMENT") = 1 Then
Component.IsActive("COLUMN 2 - STIFFENER PLATE:1") = True
Component.IsActive("COLUMN 2 - STIFFENER PLATE:2") = True
End If

 

 

Hope that helps.

Tom

Message 4 of 5
kwalker1
in reply to: LukeDavenport

Thanks very much for the reply Luke.

 

I believe you are correct in that Inventor is interpreting the opening of the BOM as opening of the document.

This is something that I hadn't considered.

 

I use the "After Open Document" & "Before Save Document" event triggers to ensure model is updated automatically without the need for further inputs / functions to be performed by the users.

If I only had the "Before Save Document" event trigger active, then there is a risk that the user may forget to save the document straight after opening it.

Hence this would result in the user checking the model before the model has been fully updated.

Having the model automatically update after it is opened is much better than relying on users to remember to perform functions in a set sequence (especially when the model may be used in different offices around the world).

 

Many thanks for your suggested solutions.

 

Regards,

Kurt.

Message 5 of 5
kwalker1
in reply to: thomaskennedy

Thanks very much Tom for your reply.

 

I have tried the second code you suggested and it works perfectly.

I couldn't be happier. This has been an ongoing issue for our models for some time now and it feels great to finally have found a solution.

 

But I do have just one concern with this code.

If a sub-assembly does come off its custom level of detail for some reason, then the user would never be aware of this.

 

So I thought I'd try to add the following code as a separate iLogic rule in each sub-assembly.

Considering this additional code is not attempting to suppress / activate anything, then it should matter if the BOM is trying to open on the Master LOD.

But my message box appears even if the sub-assemblies are already set and saved to the custom level of detail (Automated Model).

Not sure what I've got wrong. Would also like to name within the message which document is not on the custom LOD but I haven't worked out that part of the code yet (I'm bit of a novice at writing code).

 

If ThisDoc.Document.ComponentDefinition.RepresentationsManager.ActiveLevelOfDetailRepresentation.Name <> "Automated Model" Then
MessageBox.Show("The custom level of detail (named Automated Model) is not active and will not run iLogic rules", "WARNING",MessageBoxButtons.OK,MessageBoxIcon.Exclamation)
End If

 

If you've got any suggestions for the warning message I'm trying to create then it would be much appreciated.

Otherwise I may just live with the original code you suggested and keep an eye out for any sub-assemblies which may have inadvertently slipped off its custom level of detail.

 

Once again, many thanks for all the help.

 

Regards,

Kurt.

 

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

Post to forums  

Autodesk Design & Make Report