Exclude a sheet from print if a certain condition is met

Exclude a sheet from print if a certain condition is met

anthony.alam
Participant Participant
1,049 Views
2 Replies
Message 1 of 3

Exclude a sheet from print if a certain condition is met

anthony.alam
Participant
Participant

Hello, i am heaving difficulties with iLogic.
i wrote a rule in a drawing that checks a certain parameter, and if conditions are met it excludes a sheet from count and print.
but it does not seem to work.
here is the code:


oDoc= ThisApplication.ActiveDocument
Dim oSheet As Sheet

'If ActiveSheet.Name = "Jamb_typeG"

If Parameter("D1.ipt.f1_type") < 5 mm Then
For Each oSheet In oDoc.Sheets
If (ActiveSheet.Name = "Jamb_typeG") Or (ActiveSheet.Name = "Jamb_typeG:2")

oSheet.ExcludeFromCount = True
oSheet.ExcludeFromPrinting = True
End If

If (ActiveSheet.Name = "Jamb_typeM") Or (ActiveSheet.Name = "Jamb_typeM:2")

oSheet.ExcludeFromCount = False
oSheet.ExcludeFromPrinting = False
End If
Next
End If

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

MechMachineMan
Advisor
Advisor
Accepted solution

Because your stringing together things that aren't making consistent variable calls.

 

If you are iterating through sheets and wanting the loop's processing to stay consistent to those sheets, you need to use the consistent variable.

 

ActiveSheet <> oSheet UNLESS you call oSheet.Activate in the loop before ActiveSheet.

 

But the better way to code it is:

 

oDoc= ThisApplication.ActiveDocument
Dim oSheet As Sheet

If Parameter("D1.ipt.f1_type") < 5 mm Then
  For Each oSheet In oDoc.Sheets
    If (oSheet.Name = "Jamb_typeG") Or (oSheet.Name = "Jamb_typeG:2")
      oSheet.ExcludeFromCount = True
      oSheet.ExcludeFromPrinting = True
    End If

    If (oSheet.Name = "Jamb_typeM") Or (oSheet.Name = "Jamb_typeM:2")
      oSheet.ExcludeFromCount = False
      oSheet.ExcludeFromPrinting = False
    End If
  Next
End If

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 3 of 3

anthony.alam
Participant
Participant
worked perfectly, thank you so much!
0 Likes