Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Dimitar.Atanasov2VL53
350 Views, 2 Replies

Import data exchange model into Inventor

I found a post in Mod the Machine about importing data exchange models into inventor using VBA.

original post: https://modthemachine.typepad.com/my_weblog/2022/04/import-data-exchange-model.html

Sub ImportDataExchangeComponentSample()
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim sFdx As String
    sFdx = "https://developer.api.autodesk.com/exchange/v1/exchanges"
    
    Dim sUrn As String
    sUrn = "urn:adsk.wipprod:dm.lineage:**********************"
    
    Dim sUrl As String
    sUrl = sFdx + "?filters=attribute.exchangeFileUrn==" + sUrn
    
    Dim oDEDef As ImportedDataExchangeComponentDefinition
    Set oDEDef = oDoc.ComponentDefinition.ImportedComponents.CreateDataExchangeDefinition(sUrl)
    
    Dim oDEComp As ImportedDataExchangeComponent
    Set oDEComp = oDoc.ComponentDefinition.ImportedComponents.Add(oDEDef)
End Sub

I tried it with a few data exchange models that I have on the Autodesk construction cloud and I don't get a model in inventor.

Has any of you tried it?

Labels (3)

Funny enough when running the code in the blog post using the urn of an old Data Exchange file I had, I did get the same result: nothing got imported and also got an *.htm file showing an error:

adamnagy_0-1675855099289.png

Maybe I don't have access to that exchange file anymore or something went wrong with it - I don't even know where to look for it. 
Then I used the urn of another Data Exchange file in ACC, and with that the import worked fine:

adamnagy_1-1675855255441.png

Please make sure that you are indeed using the urn of a Data Exchange file, not the original file it was created for, and also open it in ACC to see that it's working fine.



Adam Nagy
Autodesk Platform Services

The problem at my end was that we still use Revit 2022 and Data exchange models can be created from Revit 2023+. Also, I skipped the most important step of actually creating a data exchange model in the ACC.
Initially, I thought that every model in the ACC is readily available to grab with that code and imported into Inventor.

Anyway, when I tested with an actual data exchange model and the code works fine.