<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Another Inventor API bug in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/another-inventor-api-bug/m-p/3351709#M137258</link>
    <description>&lt;P&gt;Hi Dennis,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry I forgot to say, I was using VBA in Access. &amp;nbsp;Do you know of an appropriate fix for that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 29 Feb 2012 13:02:45 GMT</pubDate>
    <dc:creator>BugFinder</dc:creator>
    <dc:date>2012-02-29T13:02:45Z</dc:date>
    <item>
      <title>Another Inventor API bug</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/another-inventor-api-bug/m-p/3349725#M137256</link>
      <description>&lt;P&gt;I am trying to use the OnFileresolution event to resolve files and so far this is what I have:&lt;/P&gt;&lt;PRE&gt;Option Explicit

Private WithEvents inv As Inventor.FileAccessEvents
Private invApp As Inventor.Application

Private Sub Class_Initialize()
    
    On Error Resume Next
    
    Set invApp = GetObject(, "Inventor.Application")
    
    If Err Then
        Err.Clear
        Set invApp = CreateObject("Inventor.Application")
        invApp.Visible = False
    End If
    
    On Error GoTo 0
        
    Set inv = invApp.FileAccessEvents
    
End Sub

Private Sub inv_OnFileResolution(ByVal RelativeFileName As String, ByVal LibraryName As String, CustomLogicalName() As Byte, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, FullFileName As String, HandlingCode As Inventor.HandlingCodeEnum)
    
    Dim str As String
    
    HandlingCode = kEventHandled
    
    If (BeforeOrAfter = kBefore) Then
        str = "C:\New folder\"
        FullFileName = str &amp;amp; RelativeFileName
    End If
    
End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;The problem is the Handlingcode does nothing. &amp;nbsp;Event though it is set to handled, I still get a dialog box asking for the file which I have specified in the FullFileName.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone else got this?&amp;nbsp;&lt;img id="smileyfrustrated" class="emoticon emoticon-smileyfrustrated" src="https://forums.autodesk.com/i/smilies/16x16_smiley-frustrated.png" alt="Smiley Frustrated" title="Smiley Frustrated" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2012 11:10:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/another-inventor-api-bug/m-p/3349725#M137256</guid>
      <dc:creator>BugFinder</dc:creator>
      <dc:date>2012-02-28T11:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Another Inventor API bug</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/another-inventor-api-bug/m-p/3350097#M137257</link>
      <description>&lt;P&gt;Hi BugFinder,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to reproduce your issue and was faced with the same problem in VB.net 2010.&lt;/P&gt;
&lt;P&gt;It seems that this is related to an MS issue. More information you can find here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://social.msdn.microsoft.com/Forums/eu/clr/thread/a312244e-371c-4435-a21c-89e604a670d0" target="_blank"&gt;http://social.msdn.microsoft.com/Forums/eu/clr/thread/a312244e-371c-4435-a21c-89e604a670d0&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After I changed the value for Embed Interop Types in VB.net to False&amp;nbsp;the issue was gone.&lt;/P&gt;
&lt;P&gt;Then the file resolution will accept your FullFileName and you can redirect to another file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please test and give us a feedback.&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;Dennis&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2012 14:45:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/another-inventor-api-bug/m-p/3350097#M137257</guid>
      <dc:creator>Dennis.Ossadnik</dc:creator>
      <dc:date>2012-02-28T14:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: Another Inventor API bug</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/another-inventor-api-bug/m-p/3351709#M137258</link>
      <description>&lt;P&gt;Hi Dennis,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry I forgot to say, I was using VBA in Access. &amp;nbsp;Do you know of an appropriate fix for that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 29 Feb 2012 13:02:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/another-inventor-api-bug/m-p/3351709#M137258</guid>
      <dc:creator>BugFinder</dc:creator>
      <dc:date>2012-02-29T13:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Another Inventor API bug</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/another-inventor-api-bug/m-p/3353421#M137259</link>
      <description>&lt;P&gt;Hi BugFinder,&lt;/P&gt;
&lt;P&gt;I&amp;nbsp;checked this on my machine and it works. I can handle the event properly&amp;nbsp;using VBA in&amp;nbsp;Access.&lt;/P&gt;
&lt;P&gt;(Inventor 2012 - Access 2010)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But maybe the following could cause the confusion:&lt;/P&gt;
&lt;P&gt;The RelativeFileName could contain also the relative path to the file. If the FullFileName you assembled in your code does not exist, Inventor will show the standard file resolution dialog.&lt;/P&gt;
&lt;P&gt;I stepped in this trap&amp;nbsp;while testing&amp;nbsp;the&amp;nbsp;code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance:&lt;/P&gt;
&lt;P&gt;The RelativeFileName is "Test\file1.ipt" and you want to redirect to the folder "C:\New folder\" then this would end in "C:\New folder\Test\file1.ipt".&lt;/P&gt;
&lt;P&gt;But if your file is in "C:\New folder\" Inventor will show the standard dialog and it "seems" that nothing happend.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I changed the code to check if there is a relative path and check afterwards&amp;nbsp;if the file exist.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you could give it a try:&lt;/P&gt;
&lt;PRE&gt;Private Sub inv_OnFileResolution(ByVal RelativeFileName As String, ByVal LibraryName As String, CustomLogicalName() As Byte, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, FullFileName As String, HandlingCode As Inventor.HandlingCodeEnum)
    
    If (BeforeOrAfter = kBefore) Then
                    
        Dim FileName As String
        Dim NewFullFileName As String
        
        Dim str As String
        str = "C:\New folder\"
        
        NewFullFileName = str &amp;amp; RelativeFileName
        
        'relative path?
        If InStr(1, RelativeFileName, "\") &amp;gt; 0 Then
            If MsgBox("Your RelativeFileName [" &amp;amp; RelativeFileName &amp;amp; "] contais a relative path. Do you want to use only the FileName instead?", vbYesNo) = vbYes Then
                FileName = Right(RelativeFileName, Len(RelativeFileName) - InStrRev(RelativeFileName, "\"))
                NewFullFileName = str &amp;amp; FileName
            End If
        End If
                
        'Check if the file exists
        Dim objFSO As Object
        Set objFSO = CreateObject("scripting.filesystemobject")
        If objFSO.FileExists(NewFullFileName) = False Then
            MsgBox ("File [" &amp;amp; NewFullFileName &amp;amp; "] not found! Event OnFileResolution will not be handled in this step.")
        Else
        'Only if the check is okay, then set the handling code
            HandlingCode = kEventHandled
            FullFileName = NewFullFileName
        End If
        objFSO = Nothing
    End If
    
End Sub&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Dennis&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2012 10:53:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/another-inventor-api-bug/m-p/3353421#M137259</guid>
      <dc:creator>Dennis.Ossadnik</dc:creator>
      <dc:date>2012-03-01T10:53:09Z</dc:date>
    </item>
  </channel>
</rss>

