Hi,
I have just updated to AIP 2018 on Windows 10. I was previously using AIP 2017 on Windows 7 and my drawing files (idw) have an iLogic rule to save to PDF triggered on file close. This rule will not run at all on AIP 2018 yet worked without hitch on AIP 2017...
I get the following error message,
Error in rule: SavePDF, in document: A02633.idw
Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))
The more info tab shows,
System.NullReferenceException: Invalid pointer (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 LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
Any assistance would be appreciated. Code attached.
Regards
Phil
Solved! Go to Solution.
Solved by Owner2229. Go to Solution.
Hey, here's the error: In your code you're setting up the PDF addin up to the point where you want to export it. Then you use simple save as instead of export. There've been some changes in 2018 to the PDF export, so I guess that's what you're encountering.
Yours:
ThisDoc.Document.SaveAs(PDFPath & "\" & ThisDoc.FileName(False) & _ " Rev" & oRevNum & " - " & oDescrip & ".pdf" , True)
Should be:
oDataMedium.FileName = PDFPath & "\" & ThisDoc.FileName(False) & _ " Rev" & oRevNum & " - " & oDescrip & ".pdf" oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
Please see this other post that is currently on the front page of the forums for your solution:
https://forums.autodesk.com/t5/inventor-customization/ilogic-fail/td-p/6972701
I walked through my code line by line and found that the problem code dealt with the PDF options. When I hid the "If" statement and simply kept the rest it worked.
The "if" statement I'm referring to is:
If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
This solved my issue.
I had the same problem as described and my code was already like Mike's solution. Commenting the "If [...]" statement (and the "End if" line) made the trick.
Thanks Dennis!
Hello,
I use the follwoig code to export pdf and dwg in the same time.
In Inventor 2017 it's working perfect, but in 2018 I recive an error.
Can you help me?
This is the code:
Public Sub Main()
Dim oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension
oDuctName = iProperties.Value("Project", "Description")
oRevNum = iProperties.Value("Project", "Revision Number")
oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
Dim oDWGAddIn As TranslatorAddIn
oDWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}")
oDrafstman = ThisApplication.UserName
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMediumPDF = ThisApplication.TransientObjects.CreateDataMedium
oDataMediumDWG = ThisApplication.TransientObjects.CreateDataMedium
'Choose Preselected Folder
Dim oChoice
Dim ProjectChoice As New ArrayList
ProjectChoice.Add("Export")
oFolder = "C:\Users\Cosmin\Desktop\"& ProjectChoice(oChoice) &"\"
Dim Proc As String = "Explorer.exe"
Dim Args As String = ControlChars.Quote & IO.Path.Combine("C:\", oFolder) & ControlChars.Quote
'PDF Setup
If oPDFAddIn.HasSaveCopyAsOptions(oDataMediumPDF, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 1200
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
End If
' DWG SETUP - Check whether the translator has 'SaveCopyAs' options
If oDWGAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
Dim strIniFile As String
strIniFile = "C:\folder\INVENTOR\iLogic\Save as DWG aparte sheets.ini"
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
End If
'get target folder path
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If
'Set the destination file name
Dim fileName As String
fileName = ThisDoc.FileName(False) & " - " & iProperties.Value ("Project", "Revision Number")
oDataMediumDWG.FileName = oFolder & fileName & ".dwg"
oDataMediumPDF.FileName = oFolder & fileName & ".pdf"
'Ask the User if he wants PDF or PDF+DWG
oQuestion = MessageBox.Show("For PDF select YES for PDF+DWG select NO", "PDF or PDF/DWG", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
'Publish document.
If oQuestion = vbYes Then
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMediumPDF)
Else If oQuestion = vbNo Then
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMediumPDF)
oDWGAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMediumDWG)
Else
'MessageBox.Show("Canceled", "We're doing nothing now...")
End If
If oQuestion = vbYes Or oQuestion = vbNo Then
OpenFolder= MessageBox.Show("Would you open the folder?", "PDF EXPORTED", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
'open the folder where the new files are saved
If OpenFolder = vbYes Then
Process.Start(Proc, Args)
Else
'Return
End If
Else
End If
End Sub
And the error is this:
Hi,
Remove the If and End If from the PDF setup
'PDF Setup
' If oPDFAddIn.HasSaveCopyAsOptions(oDataMediumPDF, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 1200
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
' End If
This will not work in Inventor 2018
Hi,
Can you help me with another problem.
I put the template on the server to be used by my collegues, and they can't do that because of this line:
oFolder = "C:\Users\Cosmin\Desktop\"& ProjectChoice(oChoice) &"\"
Can I change this somehow?
Well, if you read the code and look at what that line does, and where it points to, you will see 2 things:
1. It points to a local path on YOUR computer, so it's obvious that it wouldn't work on a different computer.
2. It's only used to open up the folder for viewing after export.
It's up to you to decide what you want to do with the functionality that is lost by this not working... Do you want to modify it do a generic path that works on all computer?
Do you just want to remove it?
etc.
Hello,
First I want to thank you for the response, I know what the line dose but I don't know how to modify it to let other person to use the macro. I want to chage the line to work for all, because I moved the teamplate folder on the server to have all of us the same teamplate.
If is that posible.
Also can I modify the macro to export the dwg file to autocad 2010, for example?
Thank you!
Have a nice day!
Have you tried using backspace/delete and the letter keys on your keyboard? That's usually the way to change file locations.
If you still want it to be in a folder named by the project, that part of it looks fine.
So instead, change the "C:\" section to your drive letter....
Also, to change your ACAD export year, change the .ini file that's used. You'll understand what I'm talking about if you MANUALLY export a dwg and keep your eyes open for the "Save Configuration" option in the dialog box.
Can't find what you're looking for? Ask the community or share your knowledge.