Message 1 of 12
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This one line in my iLogic code does not work , any ideas?
ThisDrawing.Sheet("Sheet:1").ExcludeFromPrinting = True
Solved! Go to Solution.
This one line in my iLogic code does not work , any ideas?
ThisDrawing.Sheet("Sheet:1").ExcludeFromPrinting = True
Solved! Go to Solution.
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
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
It will be probably something in your code, can you post it here?
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
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 :
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.
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.
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.
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.
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
Hi Curtis , this works perfect... thank you so much for helping me out.