Existing iLogic Rule ends on Last Sheet - Can an edit end on Current Sheet?

Existing iLogic Rule ends on Last Sheet - Can an edit end on Current Sheet?

CarterDraws
Contributor Contributor
526 Views
2 Replies
Message 1 of 3

Existing iLogic Rule ends on Last Sheet - Can an edit end on Current Sheet?

CarterDraws
Contributor
Contributor

Hello. Fairly new to Inventor iLogic, but long time draftsperson and decent exposure to code. My work's drawing template has an iLogic Rule written by someone else who is no longer here and I would like to edit it.

 

The Rule is triggered by Saving the Document and after it runs, it puts you on the Last Sheet of the Document. I am trying to make it return you to the Current Sheet you are on when the Rule fires. It is very annoying to be actively working on 1 Sheet, Save, and then be on a different Sheet.

 

I imagine the solution is to add something into the existing Rule code, but am open to other solutions.

 

If it helps, the code itself is to write the Scale of the Base View (we draw with only 1 Part or Assembly per Sheet) to a Text field within a Sketch Symbol label on that Sheet. It does this on every Sheet to catch anything you have added or changed, hence finishing on the last one.

 

The code: 

For Each oSheet In ThisApplication.ActiveDocument.Sheets
    ActiveSheet=ThisDrawing.Sheet(oSheet.Name)
    If oSheet.DrawingViews.count>0 And oSheet.SketchedSymbols.Count>0 Then
        oSymbols=oSheet.SketchedSymbols
        For Each oSymbol In oSymbols
            If oSymbol.Name="Drawing Label" Or oSymbol.Name="Drawing Label OPEN" Then
                oTextBoxes=oSymbol.Definition.Sketch.TextBoxes
                For Each oTextbox In oTextBoxes
                    If oTextBox.Text="<View Scale>" Then
                        DrawingViewName=ThisApplication.ActiveDocument.ActiveSheet.DrawingViews.Item(1).Name
                        oSymbol.SetPromptResultText(oTextBox, ActiveSheet.View(DrawingViewName).ScaleString)
                    End If
                Next
            End If
        Next
    End If
Next
InventorVb.DocumentUpdate()

  

Thanks in advance for any pointers.

0 Likes
Accepted solutions (1)
527 Views
2 Replies
Replies (2)
Message 2 of 3

Curtis_Waguespack
Consultant
Consultant
Accepted solution

 Hi @CarterDraws ,

 

You can get the current active sheet first, and then activate it after iterating through the rest, as in this example.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

oDoc = ThisApplication.ActiveDocument

oCurrentSheet = oDoc.ActiveSheet

For Each oSheet In oDoc.Sheets	
    oSheet.activate
	MsgBox(oSheet.Name)
Next

oCurrentSheet.Activate

 

EESignature

Message 3 of 3

CarterDraws
Contributor
Contributor

Curtis,

 

Excellent. Worked like a charm. Thanks for the help!

0 Likes