Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Attach a revit link

7 REPLIES 7
Reply
Message 1 of 8
a.sabatier
1166 Views, 7 Replies

Attach a revit link

a.sabatier
Contributor
Contributor

Hi

I try to link a revit file and then bind it in my host project.

Capture.JPG

I've created my linked instance but can't find a way to bind it..

 

Here  is my code :

_____________________________________________________________________________

string testFile = "C:\\Users\\asabatier\\xxx.rvt";
ModelPath linkpath = ModelPathUtils.ConvertUserVisiblePathToModelPath(testFile);

RevitLinkOptions options = new RevitLinkOptions(false);
tr.Start("Base Vie");

Autodesk.Revit.DB.LinkLoadResult result = RevitLinkType.Create(doc, linkpath, options);
RevitLinkInstance instance = RevitLinkInstance.Create(doc, result.ElementId);

__________________________________________________________________________

 

I've tried to create a gropu with my link but as it says it creates a group but don't attach my link..

 

Thanks for your help.

 

Alexandre

0 Likes

Attach a revit link

Hi

I try to link a revit file and then bind it in my host project.

Capture.JPG

I've created my linked instance but can't find a way to bind it..

 

Here  is my code :

_____________________________________________________________________________

string testFile = "C:\\Users\\asabatier\\xxx.rvt";
ModelPath linkpath = ModelPathUtils.ConvertUserVisiblePathToModelPath(testFile);

RevitLinkOptions options = new RevitLinkOptions(false);
tr.Start("Base Vie");

Autodesk.Revit.DB.LinkLoadResult result = RevitLinkType.Create(doc, linkpath, options);
RevitLinkInstance instance = RevitLinkInstance.Create(doc, result.ElementId);

__________________________________________________________________________

 

I've tried to create a gropu with my link but as it says it creates a group but don't attach my link..

 

Thanks for your help.

 

Alexandre

7 REPLIES 7
Message 2 of 8
jeremytammik
in reply to: a.sabatier

jeremytammik
Autodesk
Autodesk

Dear Alexandre,

 

Thank you for your query.

 

Is my understanding correct as follows?

 

First, you can successfully link in the target RVT document into the host document using the code above. It creates a new RevitLinkType object plus other bits and pieces to represent and manage the linked-in file.

 

Secondly, the built-in Revit command to bind the link is executed afterwards and converts the objects to something else.

 

Is that correct?

 

If so, I would suggest that you use RevitLookup and other tools to explore what objects are created, which elements are affected, and exactly how, by the second step in this process.

 

Maybe the same functionality can be achieved programmatically by your add-in.

 

Maybe, however, this built-in command does something that is not exposed though the Revit API.

 

In that case, you might have to drive the existing built-in command programmatically, e.g., by calling PostCommand.

 

The problem with that is that in many cases you cannot fully automate the user input, if any is required.

 

Please confirm my assumptions so far and explore further if possible.

 

I hope this helps.

 

Looking forward to further discussions on this and finding out how we can solve this.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

Dear Alexandre,

 

Thank you for your query.

 

Is my understanding correct as follows?

 

First, you can successfully link in the target RVT document into the host document using the code above. It creates a new RevitLinkType object plus other bits and pieces to represent and manage the linked-in file.

 

Secondly, the built-in Revit command to bind the link is executed afterwards and converts the objects to something else.

 

Is that correct?

 

If so, I would suggest that you use RevitLookup and other tools to explore what objects are created, which elements are affected, and exactly how, by the second step in this process.

 

Maybe the same functionality can be achieved programmatically by your add-in.

 

Maybe, however, this built-in command does something that is not exposed though the Revit API.

 

In that case, you might have to drive the existing built-in command programmatically, e.g., by calling PostCommand.

 

The problem with that is that in many cases you cannot fully automate the user input, if any is required.

 

Please confirm my assumptions so far and explore further if possible.

 

I hope this helps.

 

Looking forward to further discussions on this and finding out how we can solve this.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 8
jeremytammik
in reply to: a.sabatier

jeremytammik
Autodesk
Autodesk

I just noticed another thread on this topic, never completed, though, asking:

 

Does the Revit API provide the bind linked file method?

 

https://forums.autodesk.com/t5/revit-api-forum/does-the-revit-api-provide-the-bind-linked-file-metho...

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

I just noticed another thread on this topic, never completed, though, asking:

 

Does the Revit API provide the bind linked file method?

 

https://forums.autodesk.com/t5/revit-api-forum/does-the-revit-api-provide-the-bind-linked-file-metho...

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 4 of 8
jeremytammik
in reply to: a.sabatier

jeremytammik
Autodesk
Autodesk

Wow.

 

I found three more discussions on this topic, all of them lacking a final conclusion:

 

 

 

 

I am checking with the development team for you now.

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

Wow.

 

I found three more discussions on this topic, all of them lacking a final conclusion:

 

 

 

 

I am checking with the development team for you now.

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 8
a.sabatier
in reply to: jeremytammik

a.sabatier
Contributor
Contributor

Hi

 

Thanks for your answer.

 

I manage to create my RevitLinkType and to place an instance in my project.

 

Then I'd like to programmaticaly bind this instance in my project (it should create a group) and then I'll explode that group!

 

I've never use postcommand so if it's too complicated I'll try another way to do it (without having to play with linked files..).

 

0 Likes

Hi

 

Thanks for your answer.

 

I manage to create my RevitLinkType and to place an instance in my project.

 

Then I'd like to programmaticaly bind this instance in my project (it should create a group) and then I'll explode that group!

 

I've never use postcommand so if it's too complicated I'll try another way to do it (without having to play with linked files..).

 

Message 6 of 8
jeremytammik
in reply to: a.sabatier

jeremytammik
Autodesk
Autodesk

According to the other discussion threads on this topic, PostCommand may not work for 'bind link', and no known workaround has been mentioned yet, so I would wait first and see what the development team have to say about this...

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

According to the other discussion threads on this topic, PostCommand may not work for 'bind link', and no known workaround has been mentioned yet, so I would wait first and see what the development team have to say about this...

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 7 of 8
jeremytammik
in reply to: a.sabatier

jeremytammik
Autodesk
Autodesk

Dear Alexandre,

 

Thank you for your patience.

 

I heard back from the development team; they say:

 

This is currently not possible through the API. This seems like a good thing for Revit Ideas, especially if so many people are asking for it. Please submit an idea for this to the Revit Idea Station, if there is none there already, and vote for the existing one, if there is. Thank you!

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

Dear Alexandre,

 

Thank you for your patience.

 

I heard back from the development team; they say:

 

This is currently not possible through the API. This seems like a good thing for Revit Ideas, especially if so many people are asking for it. Please submit an idea for this to the Revit Idea Station, if there is none there already, and vote for the existing one, if there is. Thank you!

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 8 of 8
a.sabatier
in reply to: jeremytammik

a.sabatier
Contributor
Contributor

ok.

I'll make a wish then!

Thanks for your time.

 

[Edit] Link to vote

0 Likes

ok.

I'll make a wish then!

Thanks for your time.

 

[Edit] Link to vote

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

Post to forums  

Autodesk Design & Make Report