Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inventor 2018 iLogic error

13 REPLIES 13
SOLVED
Reply
Message 1 of 14
p.robson
4219 Views, 13 Replies

Inventor 2018 iLogic error

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

 

13 REPLIES 13
Message 2 of 14
Owner2229
in reply to: p.robson

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)
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 3 of 14

I am having a similar problem.  My code looks like what Owner2229 posted, but I'm experiencing the same error.  My ilogic text is attached.

 

Thanks!

Message 4 of 14

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

 

 


--------------------------------------
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
Message 5 of 14
p.robson
in reply to: Owner2229

Cheers Mike....That solved the issue.

Message 6 of 14

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

Message 7 of 14

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! 

Message 8 of 14
Anonymous
in reply to: p.robson

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:

 

1.JPG2.JPG

Message 9 of 14
Rob67ert
in reply to: Anonymous

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

Robert

If you find this reply helpful ? It would be nice if you use the Accept as Solution or Kudos button below.
Message 10 of 14
Anonymous
in reply to: Rob67ert

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?

Message 11 of 14
MechMachineMan
in reply to: Anonymous

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.


--------------------------------------
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
Message 12 of 14
Anonymous
in reply to: MechMachineMan

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!

 

 

 

Message 13 of 14
MechMachineMan
in reply to: Anonymous

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. 


--------------------------------------
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
Message 14 of 14

Dennis has the solution!

Thanks Dennis!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report