<?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: Modify an existing Revit file reference in an assembly. in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/modify-an-existing-revit-file-reference-in-an-assembly/m-p/10147032#M52953</link>
    <description>&lt;P&gt;I can reproduce the issue here, I logged a wish story (INVGEN-51051) for this. Before we get this implemented for ComponentOccurrence.Replace/Replace2, can you try if below workaround works for you, open your assembly data, and run below VBA code(change the Revit file path before running it):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub UpdateRevitReference()
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oFD As FileDescriptor
    Set oFD = oDoc.File.ReferencedFileDescriptors(1)
    Debug.Print oFD.FullFileName
        
    Debug.Print oFD.FullFileName
    oFD.ReplaceReference "C:\Temp\IVTest\Revit\Railing_Samples_New.rvt"
    
    Dim oIC As ImportedComponent
    Set oIC = oDoc.ComponentDefinition.ImportedComponents(1)
        
    Dim oDef As ImportedRVTComponentDefinition
    Set oDef = oIC.Definition
    Debug.Print oDef.Imported3DView
    oDef.Imported3DView = "{3D}"
        
    
    Set oFD = oDoc.File.ReferencedFileDescriptors(1)
    Debug.Print oFD.FullFileName
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Mar 2021 02:01:12 GMT</pubDate>
    <dc:creator>YuhanZhang</dc:creator>
    <dc:date>2021-03-11T02:01:12Z</dc:date>
    <item>
      <title>Modify an existing Revit file reference in an assembly.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/modify-an-existing-revit-file-reference-in-an-assembly/m-p/10101915#M52949</link>
      <description>&lt;P&gt;I have an Inventor C# AddIn.&lt;BR /&gt;How can the Inventor API in an assembly (.iam)&lt;BR /&gt;change the file reference to a Revit file (.rvt)?&lt;BR /&gt;So I have an IAM in which a "D:\Old.rvt" is embedded.&lt;BR /&gt;I want to change the reference in the IAM to "D:\New.rvt".&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;"...Descriptor.ReplaceReference" does not work.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;And with the following, the "Delete" method does not work:&lt;/P&gt;&lt;P&gt;&amp;nbsp; AssemblyDocument oAss = ...&lt;/P&gt;&lt;P&gt;&amp;nbsp; dynamic assemblyComponentDefinition = oAss.ComponentDefinition;&lt;BR /&gt;&amp;nbsp; dynamic importedComponents = assemblyComponentDefinition.ImportedComponents;&lt;/P&gt;&lt;P&gt;&amp;nbsp; dynamic importedComponentDefinition = importedComponents.CreateDefinition("D:\New.rvt");&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(importedComponents.Count &amp;gt; 0)&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; dynamic ic = importedComponents.Item(1);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ic.Delete(); // Method not implemented!&lt;BR /&gt;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;dynamic importedComp = importedComponents.Add(importedComponentDefinition);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 14:05:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/modify-an-existing-revit-file-reference-in-an-assembly/m-p/10101915#M52949</guid>
      <dc:creator>NPieper</dc:creator>
      <dc:date>2021-02-22T14:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Modify an existing Revit file reference in an assembly.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/modify-an-existing-revit-file-reference-in-an-assembly/m-p/10122159#M52950</link>
      <description>&lt;P&gt;Unfortunately, there is no way to directly replace the .rvt referenced this way. Instead, you will need to replace the ComponentOccurrence that uses the reference. This means you need to import the new reference and then do the replacement. Here is a VBA sample that assumes you have already imported the replacement file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub DoReplace(oAssy As AssemblyComponentDefinition, oldRvt As ImportedRVTComponent, newRvt As ImportedRVTComponent)
    Dim occs As ComponentOccurrences: Set occs = oAssy.Occurrences
    Dim oldOcc As ComponentOccurrence
    Dim newOcc As ComponentOccurrence
    Dim occ As ComponentOccurrence
    For Each occ In occs
        If occ.IsAssociativelyImported Then
            Dim impComp As ImportedRVTComponent: Set impComp = occ.ImportedComponent
            If impComp Is oldRvt Then
                Set oldOcc = occ
            ElseIf impComp Is newRvt Then
                Set newOcc = occ
            End If
            If Not oldOcc Is Nothing And Not newOcc Is Nothing Then
                oldOcc.Replace newOcc.Definition.Document.FullFileName, True
                Exit Sub
            End If
        End If
    Next occ
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 00:33:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/modify-an-existing-revit-file-reference-in-an-assembly/m-p/10122159#M52950</guid>
      <dc:creator>ruthsteed</dc:creator>
      <dc:date>2021-03-02T00:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Modify an existing Revit file reference in an assembly.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/modify-an-existing-revit-file-reference-in-an-assembly/m-p/10128908#M52951</link>
      <description>&lt;P&gt;Can you provide non-confidential data and your code for us to reproduce the failure when replace a Revit reference? And which Inventor are you&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;using?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 07:22:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/modify-an-existing-revit-file-reference-in-an-assembly/m-p/10128908#M52951</guid>
      <dc:creator>YuhanZhang</dc:creator>
      <dc:date>2021-03-04T07:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: Modify an existing Revit file reference in an assembly.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/modify-an-existing-revit-file-reference-in-an-assembly/m-p/10129307#M52952</link>
      <description>&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b"&gt;&lt;SPAN&gt;Inventor 2021.2.2 Build 289 (german) was used.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b"&gt;&lt;SPAN&gt;In the appendix are example files and an example cs code with questions.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 10:17:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/modify-an-existing-revit-file-reference-in-an-assembly/m-p/10129307#M52952</guid>
      <dc:creator>NPieper</dc:creator>
      <dc:date>2021-03-04T10:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: Modify an existing Revit file reference in an assembly.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/modify-an-existing-revit-file-reference-in-an-assembly/m-p/10147032#M52953</link>
      <description>&lt;P&gt;I can reproduce the issue here, I logged a wish story (INVGEN-51051) for this. Before we get this implemented for ComponentOccurrence.Replace/Replace2, can you try if below workaround works for you, open your assembly data, and run below VBA code(change the Revit file path before running it):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub UpdateRevitReference()
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oFD As FileDescriptor
    Set oFD = oDoc.File.ReferencedFileDescriptors(1)
    Debug.Print oFD.FullFileName
        
    Debug.Print oFD.FullFileName
    oFD.ReplaceReference "C:\Temp\IVTest\Revit\Railing_Samples_New.rvt"
    
    Dim oIC As ImportedComponent
    Set oIC = oDoc.ComponentDefinition.ImportedComponents(1)
        
    Dim oDef As ImportedRVTComponentDefinition
    Set oDef = oIC.Definition
    Debug.Print oDef.Imported3DView
    oDef.Imported3DView = "{3D}"
        
    
    Set oFD = oDoc.File.ReferencedFileDescriptors(1)
    Debug.Print oFD.FullFileName
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 02:01:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/modify-an-existing-revit-file-reference-in-an-assembly/m-p/10147032#M52953</guid>
      <dc:creator>YuhanZhang</dc:creator>
      <dc:date>2021-03-11T02:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Modify an existing Revit file reference in an assembly.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/modify-an-existing-revit-file-reference-in-an-assembly/m-p/10147643#M52954</link>
      <description>Yes, this workaround works.</description>
      <pubDate>Thu, 11 Mar 2021 09:22:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/modify-an-existing-revit-file-reference-in-an-assembly/m-p/10147643#M52954</guid>
      <dc:creator>NPieper</dc:creator>
      <dc:date>2021-03-11T09:22:47Z</dc:date>
    </item>
  </channel>
</rss>

