Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Display doesn't update selection highlighting after SelectSet.Clear + SelectSet.Select()

DRoam
Mentor

Display doesn't update selection highlighting after SelectSet.Clear + SelectSet.Select()

DRoam
Mentor
Mentor

I've been having this issue for a while. After certain user actions, my add-in is supposed to change which parts are highlighted on-screen by clearing the current select set and selecting the components that are supposed to be highlighted. But for some reason, a large percentage of the time the display just does not update. After a while I realized that the select set actually IS being updated, because if I right-click and do "Open", the correct components (the ones that are supposed to be highlighted, but aren't) open, and the ones that are still highlighted do not.

 

Unfortunately, I haven't got a clue as to how to reproduce this. It seems completely random. I was hoping that someone else knows why this might be happening and how to force the display to update and only highlight what is truly selected.

 

I thought it might be a "ScreenUpdating" thing, so I disabled that before the selection change and re-enabled it after, but that didn't make any difference.

 

Any solutions or clues would be greatly appreciated.

0 Likes
Reply
Accepted solutions (2)
1,034 Views
8 Replies
Replies (8)

DRoam
Mentor
Mentor

This was actually easier to reproduce than I expected. In the attached assembly, there are 3 parts. "Rule0" is supposed to iterate though each part and select them one by one. It does, and the browser highlight updates to reflect this, but the graphics highlight does not. It stays stuck on the first one, even after the rule is done.

 

@MjDeck, is this a known issue? Is there a fix or workaround?

 

FYI, I'm using Inventor 2020.3.

 

0 Likes

MjDeck
Autodesk
Autodesk
Accepted solution

@DRoam, I see the problem in 2020.3, but it's fixed in 2021. I'll try to get more details.


Mike Deck
Software Developer
Autodesk, Inc.

MjDeck
Autodesk
Autodesk
Accepted solution

@DRoam , you can work around the problem in 2020.3 by adding a call to DoEvents:

	assyDoc.SelectSet.Clear
	ThisApplication.UserInterfaceManager.DoEvents()
	assyDoc.SelectSet.Select(occ)

This issue has internal number INVGEN-28723. I'll see if we can get the fix into an update for 2020.


Mike Deck
Software Developer
Autodesk, Inc.

DRoam
Mentor
Mentor

Great, thanks so much. Just before you posted that I discovered that the following seems to work as well:

 

	assyDoc.SelectSet.Clear
	ThisApplication.ActiveView.Update()
	assyDoc.SelectSet.Select(occ)

 

Is there any advantage or disadvantage to one way over the other? It seems like DoEvents would generally be faster; is that a reasonable assumption?

0 Likes

MjDeck
Autodesk
Autodesk

DoEvents is more open-ended. It will process any messages that happen to be in the Windows queue. There might be more than just a view update waiting. I'd say DoEvents might be better because it helps keep the system interactive. But View.Update is more specific, and it should be faster.


Mike Deck
Software Developer
Autodesk, Inc.

LukeDavenport
Collaborator
Collaborator
Hi Droam,
1) Clear the selection set
2) Update the view
3) Rebuild the selection set
4) Update the view
Does that work?
Luke

DRoam
Mentor
Mentor

@MjDeck wrote:

DoEvents is more open-ended. It will process any messages that happen to be in the Windows queue. There might be more than just a view update waiting. I'd say DoEvents might be better because it helps keep the system interactive. But View.Update is more specific, and it should be faster.


That's helpful, thanks. Your knowledge and expertise are much appreciated, as always.

 

Please do post here if a fix gets ported to a 2020 update. While the workaround seems acceptable in this case, I would guess I'm not the only person who had a preexisting workflow get broken by this, so a fix would be nice.

0 Likes

DRoam
Mentor
Mentor

@LukeDavenport wrote:
Hi Droam,
1) Clear the selection set
2) Update the view
3) Rebuild the selection set
4) Update the view
Does that work?
Luke

Hi Luke, thanks for the suggestion! I did indeed find that doing what you suggested works. However, I think I might go with DoEvents as Mike suggested. Also, in my tests, whether using ActiveView.Update or DoEvents, it's only necessary to call that after clearing the selection set (in step 2 in your example), and doing it afterwards (step 4 in your example) isn't necessary.

 

Thanks anyway for the input!

0 Likes