Selection of linked elements does not look correct

Selection of linked elements does not look correct

michael-coffey
Advocate Advocate
1,754 Views
16 Replies
Message 1 of 17

Selection of linked elements does not look correct

michael-coffey
Advocate
Advocate

I'm using the new Selection.SetReferences Method from 2023 that now allows you to select elements in linked files.  The selecting is working, according to the filter count, but the elements do not look highlighted correctly or even at all.  Here is a macro to test in the 2024 Snowdon HVAC file, L2 view (turn on Rooms/turn off Spaces in view template):

public void SelectLinkedRooms()
{
	UIDocument uiDoc = this.ActiveUIDocument;
	Document doc = uiDoc.Document;
	
	var linkedRoomList = new List<Reference>();
	var revitLinkList = new FilteredElementCollector(doc).OfClass(typeof(RevitLinkInstance)).ToElements().Cast<RevitLinkInstance>().ToList();
	foreach (var linkInstance in revitLinkList)
    {
        // Skip linked doc if not loaded
        var linkedDoc = linkInstance.GetLinkDocument();
        if (linkedDoc == null) continue;

        // Get all rooms in linked document instance filtered by level id
        var linkedInstanceRoomList = new FilteredElementCollector(linkedDoc).WherePasses(new RoomFilter()).ToElements().Where(q => q.LevelId.IntegerValue == 593177).ToList();

        linkedRoomList.AddRange(linkedInstanceRoomList.Select(q => new Reference(q).CreateLinkReference(linkInstance)));
    }
	
	uiDoc.Selection.SetReferences(linkedRoomList);
}

It gets the rooms from every link file, creates references from them and then sends that into Selection.SetReferences.  The rooms should be show as shaded as if you had manually picked them.  Am I doing something wrong or is this a bug?  

0 Likes
1,755 Views
16 Replies
Replies (16)
Message 2 of 17

jeremy_tammik
Alumni
Alumni

Thank you for your observations. I asked the development team for you.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 17

jeremy_tammik
Alumni
Alumni

They took a look and say: I think there's a problem here.  The selection highlighting does not match the filter content, which, as you stated, seems to match the inputs.  It looks like the whole link gets highlighted.

  

Can you submit a complete minimal reproducible case for this for the devteam to enable in-house analysis and debugging? 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 4 of 17

michael-coffey
Advocate
Advocate

I think what I submitted in my first post is as minimal as it can get.

0 Likes
Message 5 of 17

jeremy_tammik
Alumni
Alumni

Yes. What it gains in minimality it lacks in completeness. Maybe the development team will be able to figure it out, though. I prefer serving them a complete minimal reproducible case with exact steps to reproduce. What exact steps can they take, please? Create new project, save as A, create another project, save as B, link A to B, add an element somewhere, etc.?

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 6 of 17

michael-coffey
Advocate
Advocate

Was a ticket created for Autodesk developers to fix this problem?

0 Likes
Message 7 of 17

jeremy_tammik
Alumni
Alumni

Dear Michael,

 

Thank you for your report, clear description and sample material.

 

Sorry to hear about this.

 

I logged the issue REVIT-211050 [API selection of linked rooms fails] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

This issue is important to me. What can I do to help?

 

This issue needs to be assessed by our engineering team and prioritised against all other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:

 

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact to Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

 

This information is crucial. Our engineering team has limited resources and must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.

 

Best regards,

 

Jeremy

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 8 of 17

jeremy_tammik
Alumni
Alumni

Dear Michael,

 

Thank you for your patience.

 

The development team analysed the ticket we submitted, renamed it to REVIT-211050 [API selection of elements from link instance is not highlighted properly], determined that a code fix is required, and created a new development ticket REVIT-212168 [API selection of elements from link instance is not highlighted properly] for that work to be performed. Just FYI. Please make a note of this number for future reference.

 

Best regards,

 

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 9 of 17

GaryOrrMBI
Collaborator
Collaborator

Just giving this a little bump.

 

I have a selection filter that selects elements in a model by user specified properties (a recreation of the AutoCAD selection filter if you will). I was able to adapt it to select linked elements fairly easily and, yes, I came across the same issue. The actual selection set is correct, but the entire link is highlighted, not just the selected element references.

 

I do have one little additional note: The utility that I built has a "Cancel" option and, if there is an existing selection set when the command was launched, it will be restored. My rebuild of this now includes the ability to restore Link Element References if that is what the user had selected before launching the utility... when that previous selection set is passed back into the selection function (if the user cancels) it highlights the selection(s) exactly as it was, IE: just the previously selected items from the link, not the entire link as we are experiencing when programmatically building the selection set list.

 

-G

 

Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
0 Likes
Message 10 of 17

jeremy_tammik
Alumni
Alumni

Thank you for the bump and semi-workaround. Afaict this has been fixed and scheduled for the next major release. No guarantees, though, as always. Happy weekend!

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 11 of 17

GaryOrrMBI
Collaborator
Collaborator
I'll cross my fingers... and I'll go ahead and cross my toes hoping that the fix can be built into service packs for 2023 and 2024 as well 🙂

Happy Coding,
-G
Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
0 Likes
Message 12 of 17

jeremy_tammik
Alumni
Alumni

I have asked them for you. There may be a possibility for Revit 2024. Revit 2023 is highly unlikely, IMHO. You would have to provide an extremely strong and convincing business case to make that happen, I imagine.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 13 of 17

GaryOrrMBI
Collaborator
Collaborator

@jeremy_tammik wrote:

I have asked them for you. There may be a possibility for Revit 2024. Revit 2023 is highly unlikely, IMHO. You would have to provide an extremely strong and convincing business case to make that happen, I imagine.

  


How about this: As a user of Revit (not just a programmer trying to make use of the most current API functions), we have decided that 2024 is too unreliable for us to trust on any of our projects so 2023 is our "current" software version. We are not alone in staying with 2023, there are many other firms that are doing so, therefore, logically, it would benefit a great number of your customers.

 

-G

😉

Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
0 Likes
Message 14 of 17

jeremy_tammik
Alumni
Alumni

Good news. The development team report:

    

  • REVIT-212168 CLOSED [Hotfix] [Selection] API selection of elements from link instance is not highlighted properly
  • Resolution: Fixed
  • Issue is fixed in Revit 2023.1.4 build 23.1.40.29 20240229_1515(x64) 
  • Issue is fixed in Revit 2024.1.2 build 24.2.10.36 20240301_1515(x64)

    

Cheers

  

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 15 of 17

michael-coffey
Advocate
Advocate

@jeremy_tammik Thank you for the update.  I would assume it would be fixed in the first release of Revit 2025 correct?

0 Likes
Message 16 of 17

jeremy_tammik
Alumni
Alumni

Hi Michael,

  

Yes, I would assume so too. I mentioned that in one of the previous answers to Gary. Thanks for double checking.

  

Cheers

  

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 17 of 17

GaryOrrMBI
Collaborator
Collaborator
Thanks for the update. Good to see that 23 was included in the fix.
I'll have to pull that function back up and take another look.

-G
Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
0 Likes