ilogic , Exclude from printing

ilogic , Exclude from printing

JorisSteurs1246
Advocate Advocate
1,874 Views
11 Replies
Message 1 of 12

ilogic , Exclude from printing

JorisSteurs1246
Advocate
Advocate

This one line in my iLogic code does not work , any ideas?

 

ThisDrawing.Sheet("Sheet:1").ExcludeFromPrinting = True

 

0 Likes
Accepted solutions (1)
1,875 Views
11 Replies
Replies (11)
Message 2 of 12

Curtis_Waguespack
Consultant
Consultant

Hi JorisSteurs1246,

 

This should work:

 

ThisDoc.Document.Sheets.Item("Sheet:1").ExcludeFromPrinting = True

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

 

EESignature

0 Likes
Message 3 of 12

JorisSteurs1246
Advocate
Advocate

Thanks Curtis , that did worked perfectly. 

 

Indeed the sheet is now set  as exclude from printing.

The rest of my Ilogic is printing the sheets as PDF and  DXF.

I found out now that the output to PDF works as expected, but the output to DXF is still printing all sheets from the drawing.

Is there a way in Ilogic that I can control this?

 

Joris

0 Likes
Message 4 of 12

Owner2229
Advisor
Advisor

It will be probably something in your code, can you post it here?

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 5 of 12

JorisSteurs1246
Advocate
Advocate

If I make a new .ini file where the checkbox "all sheets" is unchecked then the sheet that is vissible at the time of the print command will be printed, even when this sheet  has the checkbox active " exclude from printing" ( problem is with DXF, not PDF).  so i can't control this with the .ini file, therefor i guess I somehow need to fix this in the Ilogic?

 

Joris

0 Likes
Message 6 of 12

JorisSteurs1246
Advocate
Advocate

Hi Mike,

 

Here is the part of the code that does the printing.

 

' exit rule if no part or assembly is in the drawing yet

If (ThisDrawing.ModelDocument Is Nothing) Then
MessageBox.Show("Could not find model in this drawing ", "PROBLEM")
Goto Endrule
Else
Goto ContRule
End If

ContRule :

 

'***** use the custom rule copy Iprops from model to drawing to get the Part Number on the drawing.

'***** save as PDF
oPN = iProperties.Value("Project", "Part Number")

oPath = ThisDoc.WorkspacePath
oFolderPDF = (oPath & "\output\PDF")
oFileName = ThisDoc.FileName(False) 'without extension
'oRevNum = iProperties.Value("Project", "Revision Number")
oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _
("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 0
oOptions.Value("Vector_Resolution") = 600
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("Custom_End_Sheet") = 4
End If

'Check for the PDF folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolderPDF) Then
System.IO.Directory.CreateDirectory(oFolderPDF)
End If
'Set the PDF target file name
oDataMedium.FileName = oFolderPDF &"\"& oPN & "--" & oFileName & ".pdf"
'Publish document
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

'***** DXF
'***** use the custom rule copy Iprops from model to drawing to get the Part Number on the drawing.

oFolderDXF = (oPath & "\output\DXF")
oDataMediumDXF = ThisApplication.TransientObjects.CreateDataMedium
oDXFAddIn = ThisApplication.ApplicationAddIns.ItemById _
("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")

If Not System.IO.Directory.Exists(oFolderDXF) Then
System.IO.Directory.CreateDirectory(oFolderDXF)
End If

' Check whether the translator has 'SaveCopyAs' options
If oDXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
Dim strIniFile As String
strIniFile = "C:\Users\kasutaja\Documents\Inventor\MY support files\AI2012_to_DXF2004_NotAllSheets.ini"
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
End If

oDataMediumDXF.FileName = ThisDoc.PathAndFileName(False)
oDataMediumDXF.FileName = oFolderDXF &"\"& oPN & "--" & oFileName & ".dxf"
oDXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMediumDXF)

oSpace = ""
MessageBox.Show("Drawing is printed as PDF and saved in : " & oFolderPDF _
& vbLf & ""& oSpace _
& vbLf & "Drawing is printed as DXF and saved in : "& oFolderDXF _
& vbLf & ""& oSpace _
& vbLf & " Click OK to save drawing and close this box. " , "DONE!")
ThisDoc.Save
Goto Alldone

Endrule :

MessageBox.Show("No PDF or DXF was saved ", "Info")


Alldone :

 

0 Likes
Message 7 of 12

Owner2229
Advisor
Advisor

Hi, uncommenting 29th line of your code should do the trick.

 

oOptions.Value("Custom_Begin_Sheet") = 2

The problem will rise, when you'll want to exclude different sheet then "Sheet:1". But if that's all what you need then it should do it.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 8 of 12

JorisSteurs1246
Advocate
Advocate

But this line 29 is in the PDF section of the code and the PDF is behaving correctly. 

In my ilogic i suppress some views on the different sheets. When all of the the views on  a specific sheet are suppressed I'll make the code to set the sheet to " exclude from printing"  so at this moment it works OK with PDF but in DXF , everything still gets printed included the blank sheets.

0 Likes
Message 9 of 12

MechMachineMan
Advisor
Advisor

You could always just have it print the current sheet, and then iterate through the sheets so you can perform a check on the exclusion status.


--------------------------------------
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 10 of 12

JorisSteurs1246
Advocate
Advocate

I think that must be the  way to go Justin, thanks for that tip.

I hope my limited coding skills allow me to do this. 

 

0 Likes
Message 11 of 12

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi JorisSteurs1246,

 

 

Try something like this:

 

Dim oCurrentNumber  As Sheet
oCurrentNumber = ThisApplication.ActiveDocument.ActiveSheet
	
' Iterate through the sheets
Dim oSheet As Sheet
For Each oSheet In ThisApplication.ActiveDocument.Sheets
	oSheet.Activate
	If oSheet.ExcludeFromPrinting = False Then
	
	'run DXF code here
	MessageBox.Show("DXF output...", "iLogic")

	End If
Next
' Return to original active sheet
oCurrentNumber.Activate

 

 

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

EESignature

0 Likes
Message 12 of 12

JorisSteurs1246
Advocate
Advocate

Hi Curtis , this works perfect... thank you so much for helping me out.  

0 Likes