PDF I logic problems after 2018 upgrade

Ikruse
Contributor
Contributor

PDF I logic problems after 2018 upgrade

Ikruse
Contributor
Contributor

Good Afternoon,

 

I am hoping someone can help me out. After our company recently upgraded to 2018 Inventor our PDF export code throws the following error. 

 

Error in rule: iPDF_Out, in document: Drawing2

Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))

 

I have attached our current code for review as a text file. If anyone can help identify the issue it would be greatly appreciated. 

 

Thanks,

Isaac

0 Likes
Reply
Accepted solutions (1)
1,892 Views
2 Replies
Replies (2)

MechMachineMan
Advisor
Advisor
Accepted solution

There is many a post on the forums already. Search functionality is a fantastic thing.

 

 Public Sub Main()
	Dim doc as DrawingDocument
	' Is this a drawing document?
	Try
		doc = ThisApplication.ActiveDocument
	Catch
		If Not ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then
			MessageBox.Show("This command is only used on drawing documents", _
											"Harmony Enterprises Automation", _
											MessageBoxButtons.OK, _
											MessageBoxIcon.Exclamation)
			Exit Sub
		End If
	End Try
	
	'Set all variables and build paths
 	iLogicVb.RunExternalRule("SharedVars")
	iLogicVb.RunExternalRule("PathBuilder")
	
	' hook the PDF export add-in
 	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 'old
 	If oPDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then 'new
	oOptions.Value("All_Color_AS_Black") = 0
	oOptions.Value("Remove_Line_Weights") = 0
	oOptions.Value("Vector_Resolution") = 400
	oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
	End If

	'get PDF target folder path
	Dim targetFile As String = SharedVariable("fullpdfPath")
	If System.IO.File.Exists(targetFile) Then
		booleanParam = InputRadioBox("WARNING!", "Overwrite Existing File...", "Cancel Command", False, Title := "Harmony Automation")
		If booleanParam = False then Exit Sub
	End If
	
	 'Set the PDF target file name
	oDataMedium.FileName = targetFile

	'Save the file
	oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
	
	'Was the file created?
	Dim argMap As NameValueMap
	argMap = ThisApplication.TransientObjects.CreateNameValueMap()
	argMap.Add("checkFile", targetFile)
	iLogicVb.RunExternalRule("file_Validation",argMap)
 End Sub

--------------------------------------
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

guamejiama
Enthusiast
Enthusiast

Worked just fine, thanks a lot.

_________________________________________________________________
(Por favor, seleccioname como solución si he ayudado en lo que necesitabas)
(Please, select me as a solution if I helped in what you needed)
0 Likes