Hello!
My question: We want to use iLogic to save a PDF-file of the DWG-drawing every time we hit "save". We now use the following iLogic code:
Question 1: Is it possible to save the PDF in a new folder that lies "one step up". For example: My DWG-file is placed in c:/drawings/thing4/DWG, I want the PDF to end up in c:/drawings/thing4/PDF. If I am in folder "c:/drawings/thing2/DWG" I want the PDF to end up in "c:/drawings/thing2/PDF" etc. Possible?
Question 2: My DWG files is named "thing4.dwg" and it is the 2nd revision. I want the PDF-file to be named
"thing4 Ed2.pdf". Possible?
Any help would be very appreciated!
/Gustav
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
This is how I've done it, the information I want to turn off must be in the Layer "Title (ISO)":
SyntaxEditor Code Snippet
'------start of iLogic-------' ' If the drawing is not at Status "Released", the Title Block will NOT print If iProperties.Value("Status", "Design State") <> 3 Then ThisDrawing.Document.StylesManager.Layers("Title (ISO)").Visible= False Else ThisDrawing.Document.StylesManager.Layers("Title (ISO)").Visible= True End If 'oPath = ThisDoc.Path 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") = 1 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'oOptions.Value("Custom_Begin_Sheet") = 2'oOptions.Value("Custom_End_Sheet") = 4 End If 'get PDF target folder path oFolder = Left(oPath, InStrRev(oPath, "\")) & "PDF" 'Check for the PDF folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oFileName & _ " Rev" & oRevNum & ".pdf" 'Publish document oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) 'ThisDrawing.Document.StylesManager.Layers("Title (ISO)").Visible= True InventorVb.DocumentUpdate() '------end of iLogic-------
This iLogic code doesn't work in Inventor 2018.
Inventor 2018 has PDF export changes "The From and To values specified for Sheets in range are no longer session based"
This command confuses it:
SyntaxEditor Code Snippet
If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
And I get this message:
Error in rule: PDF_Export, in document: ?????.idw
Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))
How can we fix this?
Hi Curtis,
I have successfully used your ilogic to create a pdf when closing down dwg files. A number of my drawings have two sheets or more. Is there some coding I can include to pdf all sheets as opposed to just the front/selected sheet?
Thanks,
Edward
In Inventor 2018 the following works:
SyntaxEditor Code Snippet
'------start of iLogic------- ' If the drawing is not at Status "Released", the Title Block layer will NOT appear on pdf ' Title block must be in that layer for this to work If iProperties.Value("Status", "Design State") <> 3 Then ThisDrawing.Document.StylesManager.Layers("Title (ISO)").Visible= False Else ThisDrawing.Document.StylesManager.Layers("Title (ISO)").Visible= True End If ' oPath = ThisDoc.Path 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 oOptions.Value("All_Color_AS_Black") = 1 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'get PDF target folder path oFolder = Left(oPath, InStrRev(oPath, "\")) & "PDF" 'Check for the PDF folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oFileName & _ " Rev" & oRevNum & ".pdf" 'Publish document oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) ' ThisDrawing.Document.StylesManager.Layers("Title (ISO)").Visible= True InventorVb.DocumentUpdate() '------end of iLogic-------
I try the code in Inventor 2019 and its not working.
I get the mesage box and then i get an error:
System.NullReferenceException: Ongeldige aanwijzer (Exception from HRESULT: 0x80004003 (E_POINTER))
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
at ThisRule.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
Do i have to change the code somewhere to make it work?
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
This is the code:
docFile = ThisDoc.ModelDocument Dim FNamePos As Long FNamePos = InStrRev(docFile.FullFileName, "\", -1) Dim docFName As String docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) 'Dim SN As String SN = iProperties.Value(docFName, "Project", "Stock Number")
Can't find what you're looking for? Ask the community or share your knowledge.