Excluding Print and Count if Sheet name matches

Excluding Print and Count if Sheet name matches

adeel.malik
Explorer Explorer
388 Views
8 Replies
Message 1 of 9

Excluding Print and Count if Sheet name matches

adeel.malik
Explorer
Explorer

I have a bunch of sheets named Vendor (e.g. Vendor:1 or Vendor:2...). For certain things I want to exclude these sheets from count and print. I wanted to write an ilogic for this but my code is not working.

 

 

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet

i = 0
x = 0

For Each oSheet In oDoc.Sheets
	i = i + 1
Next

While (x<i)
	Sheet_Name = "Vendor:" & x 
	x= x+1
	'ThisDoc.Document.Sheets.Item(Sheet_Name).ExcludeFromPrinting = True  <---Not working
	'ThisDoc.Document.Sheets.Item(Sheet_Name).ExcludeFromCount = True <---Not working
End While
0 Likes
Accepted solutions (2)
389 Views
8 Replies
Replies (8)
Message 2 of 9

A.Acheson
Mentor
Mentor

Does this work better for you? 

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim i as Integer = 0

For Each oSheet As Sheet In oDoc.Sheets
	
	i = i + 1
	
	If oSheet.Name = "Vendor:" & i
		oDoc.Sheets.Item(oSheet.Name).ExcludeFromPrinting = True  
		oDoc.Sheets.Item(oSheet.Name).ExcludeFromCount = True
	End If
Next

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 9

WCrihfield
Mentor
Mentor
Accepted solution

Hi @adeel.malik.  This is just another example, very similar to the one posted by @A.Acheson, but includes a quick question, so you can use the same rule to toggle the sheets either way.  Then it is using the StartsWith() method, which can be useful in some situations.

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oExcludeVendorSheets As Boolean = InputRadioBox("Exclude Vendor Sheets?", "True", "False", False, "Toggle Vendor Sheets")
For Each oSheet As Sheet In oDDoc.Sheets
	If oSheet.Name.StartsWith("Vendor") Then
		oSheet.ExcludeFromCount = oExcludeVendorSheets
		oSheet.ExcludeFromPrinting = oExcludeVendorSheets
	End If
Next

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 9

adeel.malik
Explorer
Explorer

For some reason this doesn't work

0 Likes
Message 5 of 9

adeel.malik
Explorer
Explorer

Thankyou this is really helpful.

0 Likes
Message 6 of 9

A.Acheson
Mentor
Mentor
Accepted solution

Just tested it now,  as the sheet name is found the sheet is excluded from the count and the sheet number drops. Therefore it will fail to catch all the sheets. This will work as well. 

If oSheet.Name.Contains("Vendor") Then
   oDoc.Sheets.Item(oSheet.Name).ExcludeFromPrinting = True  
   oDoc.Sheets.Item(oSheet.Name).ExcludeFromCount = True
End If

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 7 of 9

R_Cygan
Participant
Participant

That works rather well, I was wondering if we could reverse, the Code 

Let's say we have 30 Sheets, but just few = 4 Sheets want send to Client, 

Ideally The code would say:

If the Drawings is "Client" - Than Print Just "he "Client" Sheets,

otherwise Print All

No sure how that can work 

 

Thank You for your Help

0 Likes
Message 8 of 9

WCrihfield
Mentor
Mentor

How do you plan on specifying or identifying which sheets are for "Client", and which are not?  Do those sheets have the word "Client" (or similar text) in their sheet name, or do you have some other way of identifying them?  When iterating through client sheets, do you really just want the code to immediately print each sheet that is for client, or just un-exclude them, exclude non-client sheets, then print all un-excluded sheets at the end?  If you would like one of us to create or modify a code to do what you want, then we would have to know all the details that you know about the task, because code usually needs to be extremely specific to work.  If searching for a String (text), then spelling, capitalization, and even empty spaces are important to have correct.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 9 of 9

R_Cygan
Participant
Participant

Thx,

I managed to Modify one Code from above and Works well,

The Rule Essentially will Isolate Sheets NOT Starting with "S"- To Print/ Export PDF as "Client drawings"

Not sure if this is Elegant, or "Proper" - but works - 100%

Thanks to that Chat Above!!

 

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oExcludeSheets As Boolean = InputRadioBox("Client or All Sheets?", "Client", "All", Client, "Toggle Sheets")
For Each oSheet As Sheet In oDDoc.Sheets
	If oSheet.Name.StartsWith("S") Then
		oSheet.ExcludeFromCount = oExcludeSheets
		oSheet.ExcludeFromPrinting = oExcludeSheets
	End If
Next

Please comment,

I appreciate

0 Likes