highlight and tag linked elements

highlight and tag linked elements

Ning_Zhou
Advocate Advocate
4,593 Views
33 Replies
Message 1 of 34

highlight and tag linked elements

Ning_Zhou
Advocate
Advocate

in normal Revit UI you can select linked elements and these selected guys will be automatically highlighted after selection, what about in reverse order? say i have IDs of the linked elements and i want these elements being highlighted, furthermore, i want tag these guys or do similar things to them within host model, possible? in fact,  IDs of the linked elements are from exported Revit's clashing report.

4,594 Views
33 Replies
Replies (33)
Message 21 of 34

jeremytammik
Autodesk
Autodesk

Dear @m.vallee,

 

Are you saying that the approach you demonstrate does *not* achieve what you would like it to?

 

Thank you for letting us know and pointing out the idea, at least.

 

I don't know for sure whether your exact need is covered by any of the idea station entries.

 

You can find all entries concerning linked elements by going to the Idea Station and using the advanced search with the search phrase "linked element".

 

That brings up seven entries for me right now.

 

Cheers,

 

Jeremy



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

Message 22 of 34

m.vallee
Advocate
Advocate

Yes exactly, my code sample does not achieve what I would like it to do.

 

My plugin needs to create selection filters when rule-based filters cannot be made for the chosen parameter.

 

When there is a linked file, rule-based filters also apply on linked models, but selection filters do not : I think it is for the same reason you're describing in this post : there is a lack in the API regarding what can be done with IDs of elements that belong to linked files.

 

I tried to find the Revit idea station wish list item you seemed to mention, Jeremy, (wish list item REVIT-90539 [API wish: highlight linked elements -- 10027136]) but with no success. I understand it is an Autodesk internal wish list, not the Revit idea station wish list which is publicly available.

0 Likes
Message 23 of 34

jeremytammik
Autodesk
Autodesk

Thank you for the clarification. Now I see.

 

Yes, the wish list item is an internal development database issue.

 

Cheers,

 

Jeremy



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

0 Likes
Message 24 of 34

m.vallee
Advocate
Advocate

Hi,

 

Any new info regarding this topic ?

 

I also found out this quite strange thing :

  • suppose you have a shared parameter in the host document and in the linked files (so same Guid but different Id)
  • you define a rule-based filter (using the host document parameter Id for creation) => it applies correctly on the linked elements. The views are filtered/colored as wanted
  • BUT if you try the ElementPasses method on a filter rule and give a linked element that should pass it, it fails...
    FilterElement fe;
    ParameterFilterElement pfe = fe as ParameterFilterElement;
    
    if ((null != pfe && pfe.GetRules().First().ElementPasses(room))
    {
       // fails
    }
     

Please tell me if I am not clear enough.

 

Thanks for your help.

 

Maxime

 

0 Likes
Message 25 of 34

jeremytammik
Autodesk
Autodesk

Dear Maxime,

 

Thank you for your update.

 

I added a note of your request for a status update and additional query to the development issue REVIT-90539 [WISH: API : highlight linked elements -- 10027136].

 

Cheers,

 

Jeremy



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

Message 26 of 34

tubagezll
Explorer
Explorer

@jeremytammik @Ning_Zhou,vote for this functionality.

0 Likes
Message 28 of 34

carolina.machado
Advocate
Advocate

Hey Jeremy!

 

Do you have any updates on this subject?

 

Thanks,

Carolina.

0 Likes
Message 29 of 34

jeremytammik
Autodesk
Autodesk

Dear Carolina et al,

 

Ilia Ivanov just presented a solution that works for him in his new thread on 'Tagging Linked Elements using Revit API':

 

https://forums.autodesk.com/t5/revit-api-forum/tagging-linked-elements-using-revit-api/m-p/8669001

  

Re: Tagging Linked Elements using Revit API -- Hello, I have done it:

 

 

  RevitLinkInstance link = doc.GetElement(
    tag.TaggedElementId.LinkInstanceId)
      as RevitLinkInstance;
      
  Reference refer = new Reference(
    link.GetLinkDocument()
      .GetElement(tag.TaggedElementId.LinkedElementId))
    .CreateLinkReference(link);

 

 

I hope that satisfies your requirements as well.

 

Please confirm.

 

Thank you!

 

Best regards,

 

Jeremy

 



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

Message 30 of 34

m.vallee
Advocate
Advocate

Hi @jeremytammik ,

 

Thanks for the update.

 

This must solve the "tagging" linked elements' problem, that's all.

 

You still cannot add a linked element to a selection set so that it is highlighted.

 

And that doesn't explain nor fix the strange behaviours observed when applying rule-based filters on linked documents (see my previous post).

 

If not already done, I think Autodesk dev team should really consider replacing ElementId with LinkElementId whereever possible in the API. This class would enable us to specify all types of elements ids, from the host document as well as from any linked document.

 

Best regards.

Maxime

Message 31 of 34

carolina.machado
Advocate
Advocate

Dear Jeremy,

 

Thank you for coming back to this post to give us this answer! 
I have already solved my issue and forgot to write here the solution I've found.
Using the Revit Lookup and a post from your blog I noticed that the Stable Representation of references in linked instances comform to the following pattern:

 

revitLinkInstance.UniqueId + ":0:RVTLINK/" + revitLinkType.UniqueId + ":" + element.Id.ToString()

 

Using this string it is possible to get the Reference through Reference.ParseFromStableRepresentation method. And then use the reference to tag this element.

 

Cheers,

 

Carolina.

Message 32 of 34

jeremytammik
Autodesk
Autodesk

Dear Carolina and Maxime, @carolina.machado and @m.vallee,

 

Thank you for your updates and confirmation that tagging linked elements can be solved using the two different approaches, both via RevitLinkInstance + CreateLinkReference and using the ParseFromStableRepresentation method.

 

Regarding the wish to highlight a linked element, I would suggest that you vote for the associated wish in the Revit Idea Station, if you have not already done so:

 

https://forums.autodesk.com/t5/revit-ideas/highlight-element-selection-in-linked-files/idi-p/7619701

 

You can add a comment to that repeating your suggestion to use LinkElementId wherever possible in the API.

 

To drive the other issue forward, concerning the strange behaviour observed when applying rule-based filters on linked documents, it might help if you can submit a minimal reproducible case that I can share with the development team. With that in hand, I would raise a new separate development issue for that question.

 

Best regards,

 

Jeremy

 



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

Message 33 of 34

DanielKP2Z9V
Advocate
Advocate

I'm having the same problem, @jeremytammik please add my vote (if that's how it works) to add uidoc selection of elements in linked models to the Revit API. 

0 Likes
Message 34 of 34

jeremy_tammik
Alumni
Alumni

Hi. Sorry, cannot. You have to add it yourself. I can only vote for myself.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open