iLogic Rule in Before Save running, most of the time?

iLogic Rule in Before Save running, most of the time?

mslosar
Advisor Advisor
271 Views
1 Reply
Message 1 of 2

iLogic Rule in Before Save running, most of the time?

mslosar
Advisor
Advisor

We have an automated set up here that builds 90ish parts in a finished assembly.

 

We have an ilogic script that is suppressing some features and it seems to work fine, but around 90% of the time. Usually, one or two random parts calling the same basic script simply do not hide the features they are called to hide (or unhide as the case may be).

 

So my base question is, is there some quirk in the Before Save trigger that would result in a scenario like this?  The ilogic in question is far from complex:

 

As you can see i've tried DocumentUpdate and now i'm trying a rebuild option to see if it makes a difference.

On Error Resume Next
If (HasControl) Then
Select Case (IsDualBlade)
Case True
	Feature.IsActive("DualShaftHole") = True
	Feature.IsActive("DualSideStandoff") = IsControlSide
	Feature.IsActive("DualBearingHole") = HasBearings
	
	Feature.IsActive("SingleShaftHole") = False
	Feature.IsActive("SingleSideStandoff") = False
	Feature.IsActive("SingleBearingHole") = False
	
	IsSingleBlade = False
Case False	
	Feature.IsActive("DualShaftHole") = False
	Feature.IsActive("DualSideStandoff") = False
	Feature.IsActive("DualBearingHole") = False
	
	Feature.IsActive("SingleShaftHole") = True
	Feature.IsActive("SingleSideStandoff") = IsControlSide
	Feature.IsActive("SingleBearingHole") = HasBearings
	
	IsDualBlade = False
End Select	

Else
	Feature.IsActive("DualShaftHole") = False
	Feature.IsActive("DualSideStandoff") = False
	Feature.IsActive("DualBearingHole") = False
	
	Feature.IsActive("SingleShaftHole") = False
	Feature.IsActive("SingleSideStandoff") = False
	Feature.IsActive("SingleBearingHole") = False
	
	IsSingleBlade = False
	IsDualBlade = False
End If

'InventorVb.DocumentUpdate()
ThisDoc.Document.Rebuild ()

 

 

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

WCrihfield
Mentor
Mentor

Hi @mslosar.  What version/year of Inventor are you using?  If 2022 or newer, are you using any custom ModelStates in any of the files that this code would be interacting with?  Is this code in an 'internal' iLogic rule (saved within an Inventor document) or an external iLogic rule?  If it is an internal rule, is it located in a part or assembly, and is this came rule located within multiple different documents under the influence of the main assembly?  I often recommend one of two options for code that is being used in large projects, to avoid document reference confusion:  Either use as much Inventor API code as possible and avoid using the iLogic snippets where the document it is working on may be in question / or use the somewhat new iLogic SOP = StandardObjectFactory.Create(oDoc) method, where you input the document you want the code to target, then use the IStandardObjectProvider object that the method creates (the SOP variable) to start those iLogic shortcut snippets from.  This helps avoid those snippets trying to target the wrong document in large assembly related projects.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes