
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
First time posting on this forum and relatively new to all this ilogic code. I have searched extensively for solution to this problem and can't seem to find it exactly.
I want to create a pdf copy of a dwg but with an added extension that details the revision number. The catch here is that the revision number needs to be from the assembly that the drawing is of and NOT the revision number from the drawing. ie. the revision number extension should be the number that you see in the title block of the drawing.
This is the code that i have been working on but there is an error - i believe it is in the part of the code referring to the Sheet.
SyntaxEditor Code Snippet
'' Get the PDF translator Add-In. Dim PDFAddIn As TranslatorAddIn PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") '' Set a reference to the active document (the document to be published). Dim oDocument As Document oDocument = ThisApplication.ActiveDocument Dim oContext As TranslationContext oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = kFileBrowseIOMechanism '' Create a NameValueMap object Dim oOptions As NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap '' Create a DataMedium object Dim oDataMedium As DataMedium oDataMedium = ThisApplication.TransientObjects.CreateDataMedium '' Check whether the translator has 'SaveCopyAs' options If PDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then ' ' Options for drawings... 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 '' Pick up the revision number Dim oSheet As Sheet oTitleblock = oSheet.TitleBlock oRevNum = oTitleBlock.GetResultText(oTitleBlock.Definition.Sketch.TextBoxes.Item(6)) '' Set the destination file name oDataMedium.FileName = ThisDoc.Path & "\" & ThisDoc.FileName & "_rev" & oRevNum & ".pdf" '' Publish document. Call PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
I get an error saying this:
Error in rule: PDF Saver, in document: 812.100.70_Approval.dwg
Object reference not set to an instance of an object.
Can anyone help me out or shed any light? Any help would be greatly appreciated.
Cheers, Finn
Solved! Go to Solution.