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: 

Error getting PDF translator Add-In

11 REPLIES 11
Reply
Message 1 of 12
sellis
1989 Views, 11 Replies

Error getting PDF translator Add-In

Can not get the PDF translator Add-In

 

Trying to export a PDF with PDF translator. Using sample "Save as PDF Translator Sample" from programers help as guild.

 

Getting error "Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))" with

 

Dim PDFAddIn As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")


Tried on another system with same results. Can get other translators with ItemById. Can export PDF manually.  

 

Inventor 2014, Visual Studios 2012

 

(this is sort of a repost of http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/error-with-ThisApplication-Application... that got marked solved)

 

Thanks

Stan

11 REPLIES 11
Message 2 of 12
djreesing
in reply to: sellis

I don't think you can set an object like that in VBA

 

Try it like this

 

Dim PDFAddIn As TranslatorAddIn
Set PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")

 

Daniël

Message 3 of 12
sellis
in reply to: djreesing

This is VB.net and line works with other translator IDs.

 

Should note IV is 64-bit build 170, update 1

 

 

Message 4 of 12
djreesing
in reply to: sellis

Check if you have the PDF translator in the list of translators at the Addin manager. It should be there with load behavior automatic/on demand.

Message 5 of 12
sellis
in reply to: djreesing

It is there and shows loaded after a maual PDF export...

Message 6 of 12
philippe.leefsma
in reply to: sellis

Do you get the same error when trying from VBA? Works fine on my side...

 

If VBA works, can you post the full Vb.Net code?

 

Public Sub PublishPDF()

    Dim translator As TranslatorAddIn
    Set translator = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD95-2F4D-42CE-8BE0-8AEA580399E4}")

    Dim doc As Document
    Set doc = ThisApplication.ActiveDocument

    Dim ctx As TranslationContext
    Set ctx = ThisApplication.TransientObjects.CreateTranslationContext
    ctx.Type = kFileBrowseIOMechanism

    ' Create a NameValueMap object
    Dim options As NameValueMap
    Set options = ThisApplication.TransientObjects.CreateNameValueMap

    ' Create a DataMedium object
    Dim dataMedium As dataMedium
    Set dataMedium = ThisApplication.TransientObjects.CreateDataMedium

    'Set the destination file name
    dataMedium.filename = "c:\Temp\test.pdf"

    'Publish document.
    Call translator.saveCopyAs(doc, ctx, options, dataMedium)
End Sub

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 7 of 12
sellis
in reply to: philippe.leefsma

Error in VBA also.

 

Run-time error '-2147467259 (80004005)':

Message 8 of 12
sellis
in reply to: sellis

Tried on other systems with same results. Manually exporting to PDF works on all.

 

Windows 7 64 bit inventor professional 2014 build 170, update 1 (Tried VB.net and VBA)

Windows 8 64 bit inventor professional 2014 build 170 (Tried VB.net, system on differnt network... off site)

Windows 7 64 bit inventor 2014 build 170 (Tried VBA)

Windows 7 64 bit inventor 2013 build 176 sp1.1 (Tried VBA,  same system as above)

 

All systems had 2014 installed with 2013 already installed. Two systems had 2013 uninstalled after.

 

Could there be a regional change with PDF addin ID? These systems are in Canada, Software was downloaded through subscription.

 

Message 9 of 12
djreesing
in reply to: sellis

You can check the class id of the addin. Go to: C:\ProgramData\Autodesk\Inventor 2014\Addins and look for this file: Autodesk.TranslatorPDF.Inventor.addin

If you open this file with notepad you can find the class id somewhere in the first couple of lines.

 

 

Message 10 of 12
sellis
in reply to: djreesing

Well this is embarrassing...

 

When I checked the addin ID I discovered a "?" got added in the ID when I pasted the VBA code over to the editor. So VBA works so must be a problem in my VB.net code.

 

When I get time I will start a new VB.net project and just grab the PDF translator to see what happens.  Oddly other translators work fine...

Message 11 of 12
sellis
in reply to: sellis

Made a new addin with template and added two buttons. On gets the PDF translator and the other gets the STEP translator. PDF fails, STEP works.

 

Imports Inventor
Imports System.Runtime.InteropServices
Imports Microsoft.Win32

Namespace InventorAddIn1
    <ProgIdAttribute("InventorAddIn2.StandardAddInServer"), _
    GuidAttribute("6a980868-cdce-4631-a170-77a49bf32c15")> _
    Public Class StandardAddInServer
        Implements Inventor.ApplicationAddInServer

        ' Inventor application object.
        Private m_inventorApplication As Inventor.Application

        Private WithEvents _GetPdfTraslatorButton As Inventor.ButtonDefinition
        Private WithEvents _GetStepTraslatorButton As Inventor.ButtonDefinition

        Public Shared AddInCLSID As String

#Region "ApplicationAddInServer Members"

        Public Sub Activate(ByVal addInSiteObject As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean) Implements Inventor.ApplicationAddInServer.Activate
            Try

                ' This method is called by Inventor when it loads the AddIn.
                ' The AddInSiteObject provides access to the Inventor Application object.
                ' The FirstTime flag indicates if the AddIn is loaded for the first time.

                ' Initialize AddIn members.
                m_inventorApplication = addInSiteObject.Application

                ' TODO:  Add ApplicationAddInServer.Activate implementation.
                ' e.g. event initialization, command creation etc.

                Dim _AddInCLSID As GuidAttribute = CType(System.Attribute.GetCustomAttribute(GetType(StandardAddInServer), GetType(GuidAttribute)), GuidAttribute)
                AddInCLSID = "{" & _AddInCLSID.Value & "}"

                Dim UserInterfaceManager As UserInterfaceManager = m_inventorApplication.UserInterfaceManager

                ' Get the ribbon associated with part documents
                Dim DrawingRibbon As Ribbon = UserInterfaceManager.Ribbons.Item("Drawing")

                ' Create a new tab
                Dim InventorAddIn2Tab As RibbonTab = DrawingRibbon.RibbonTabs.Add("InventorAddIn2", "InventorAddIn2.TranslatorsTab", AddInCLSID, , , False)

                ' Create a new panel within the tab
                Dim TranslatorsRibbonPanel As RibbonPanel = InventorAddIn2Tab.RibbonPanels.Add("Translators", "InventorAddIn2.TranslatorsTab.TranslatorsPanel", AddInCLSID)

                'Get icon
                Dim IconIPictureDisp As Object = System.Type.Missing

                'create the commands for the environment
                Dim ControlDefinitions As Inventor.ControlDefinitions = m_inventorApplication.CommandManager.ControlDefinitions

                _GetPdfTraslatorButton = ControlDefinitions.AddButtonDefinition("Get PDF translator", "InventorAddIn2.GetPdfTraslatorCmd", Inventor.CommandTypesEnum.kQueryOnlyCmdType, AddInCLSID, , , IconIPictureDisp, IconIPictureDisp)
                _GetStepTraslatorButton = ControlDefinitions.AddButtonDefinition("Get STEP translator", "InventorAddIn2.GetStepTraslatorCmd", Inventor.CommandTypesEnum.kQueryOnlyCmdType, AddInCLSID, , , IconIPictureDisp, IconIPictureDisp)

                ' Create a control within the panel
                Call TranslatorsRibbonPanel.CommandControls.AddButton(_GetPdfTraslatorButton, True)
                Call TranslatorsRibbonPanel.CommandControls.AddButton(_GetStepTraslatorButton, True)

            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
        End Sub

        Public Sub Deactivate() Implements Inventor.ApplicationAddInServer.Deactivate

            ' This method is called by Inventor when the AddIn is unloaded.
            ' The AddIn will be unloaded either manually by the user or
            ' when the Inventor session is terminated.

            ' TODO:  Add ApplicationAddInServer.Deactivate implementation

            ' Release objects.
            m_inventorApplication = Nothing

            System.GC.Collect()
            System.GC.WaitForPendingFinalizers()
        End Sub

        Public ReadOnly Property Automation() As Object Implements Inventor.ApplicationAddInServer.Automation

            ' This property is provided to allow the AddIn to expose an API 
            ' of its own to other programs. Typically, this  would be done by
            ' implementing the AddIn's API interface in a class and returning 
            ' that class object through this property.

            Get
                Return Nothing
            End Get

        End Property

        Public Sub ExecuteCommand(ByVal commandID As Integer) Implements Inventor.ApplicationAddInServer.ExecuteCommand

            ' Note:this method is now obsolete, you should use the 
            ' ControlDefinition functionality for implementing commands.

        End Sub

#End Region

        Private Sub _GetPdfTraslatorButton_OnExecute(Context As NameValueMap) Handles _GetPdfTraslatorButton.OnExecute
            Try
                Dim PdfTranslator As TranslatorAddIn
                PdfTranslator = m_inventorApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
                MsgBox("PDF TranslatorAddIn found")
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
        End Sub

        Private Sub _GetStepTraslatorButton_OnExecute(Context As NameValueMap) Handles _GetStepTraslatorButton.OnExecute
            Try
                Dim StepTranslator As TranslatorAddIn
                StepTranslator = m_inventorApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")
                MsgBox("STEP TranslatorAddIn found")
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
        End Sub
    End Class

End Namespace

 

Message 12 of 12
chockalingam
in reply to: sellis

I am also facing the same issue.... tried for the past two days... But not able to find the solution... can any one help iin this issue

 

 

Thanks in Advance

 

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

Post to forums  

Autodesk Design & Make Report