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: 

Programmatically Finish PickObjects Selection

2 REPLIES 2
Reply
Message 1 of 3
rvtquestions
305 Views, 2 Replies

Programmatically Finish PickObjects Selection

rvtquestions
Advocate
Advocate

When utilizing a multi-selection mode via the Revit API such as: 

uidoc.Selection.PickObjects()

A manual "Finish" click is required to close the selection mode.

rvtquestions_0-1693410522659.png

 

Question

I am wondering if there is a way to programmatically click or finish this step for us? My use case for this results from the need to perform several selections of different objects at a time and continuing onto functions such as basic get/set operations on those selections until the user decides to end. As a basic example:

  1. Run command (via keyboard shortcut)
  2. select objects
  3. Click finish (At this stage I would love to press a key or have a flag that finishes the selection programmatically)
  4. Perform some operations on selected elements such as set a parameter
  5. Repeat from step 2 or until command is terminated.

 

Problem

The current "problem" is that the manual click of finishing a selection slows down the process for what I am trying to achieve. I know to a certain extent with a single selection mode, a pick and perform operation is possible until exited from a while loop but in the case of pick objects, again the finish prompt is required and the pickobjects is desired mostly because it allows quick window selection of multiple objects at a time.

0 Likes

Programmatically Finish PickObjects Selection

When utilizing a multi-selection mode via the Revit API such as: 

uidoc.Selection.PickObjects()

A manual "Finish" click is required to close the selection mode.

rvtquestions_0-1693410522659.png

 

Question

I am wondering if there is a way to programmatically click or finish this step for us? My use case for this results from the need to perform several selections of different objects at a time and continuing onto functions such as basic get/set operations on those selections until the user decides to end. As a basic example:

  1. Run command (via keyboard shortcut)
  2. select objects
  3. Click finish (At this stage I would love to press a key or have a flag that finishes the selection programmatically)
  4. Perform some operations on selected elements such as set a parameter
  5. Repeat from step 2 or until command is terminated.

 

Problem

The current "problem" is that the manual click of finishing a selection slows down the process for what I am trying to achieve. I know to a certain extent with a single selection mode, a pick and perform operation is possible until exited from a while loop but in the case of pick objects, again the finish prompt is required and the pickobjects is desired mostly because it allows quick window selection of multiple objects at a time.

Tags (3)
Labels (3)
2 REPLIES 2
Message 2 of 3

jeremy_tammik
Autodesk
Autodesk

Speaking from an official Revit API point of view, the answer is quick and simple:

  

No.

  

Speaking from the point of view of a hard-core Windows API hacking programmer, the answer is:

  

If it is a PC running Windows or some other common OS, absolutely everything is possible. So, yes, of course! Hack it, man. You can use the Windows API or possibly some higher-level .NET library to find the desired button and simulate a Click event on that.

  

Maybe you can use an even higher-level functionality such as some end-user Windows automation tool, e.g., AutoHotkey, with no programming required at all:

  

  

This is absolutely not recommended or officially supported. However, I can imagine that others would be interested in such a solution as well.

  

So, I am looking forward to hearing how you end up solving this. As always, please test very rigorously before passing this on to your end users!

  

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

Speaking from an official Revit API point of view, the answer is quick and simple:

  

No.

  

Speaking from the point of view of a hard-core Windows API hacking programmer, the answer is:

  

If it is a PC running Windows or some other common OS, absolutely everything is possible. So, yes, of course! Hack it, man. You can use the Windows API or possibly some higher-level .NET library to find the desired button and simulate a Click event on that.

  

Maybe you can use an even higher-level functionality such as some end-user Windows automation tool, e.g., AutoHotkey, with no programming required at all:

  

  

This is absolutely not recommended or officially supported. However, I can imagine that others would be interested in such a solution as well.

  

So, I am looking forward to hearing how you end up solving this. As always, please test very rigorously before passing this on to your end users!

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 3
rvtquestions
in reply to: rvtquestions

rvtquestions
Advocate
Advocate

Thank you @jeremy_tammik for the reply. I imagined a greater Windows API or automation may be required. I will definitely keep that option open. With that said, I was thinking a little more about this and one solution that may solve this somewhat, albeit not perfect, would be to reverse the operations a bit with the use of GetElementIds() instead of prompting a selection first. So the order of operations would be:

  • Select elements or even window select a bunch of objects
  • Run command (via shortcut)
  • command will receive the selection via GetElementIds() and filter the selection programmatically if needed
  • Command will continue to run operations desired such as setting a parameter to selected elements
  • To Repeat, the user would go on selecting and calling the command via keyboard shortcut

So mechanically speaking, this may be a quirky workaround to avoid having to click a finish button. The user would just select, hit command shortcut, rinse and repeat vs. the original run command shortcut, select, click finish, rinse and repeat. While not what I was originally hoping for, I suppose this may be one solution to save one step each time. I am still open to hearing any solutions others may have! 

0 Likes

Thank you @jeremy_tammik for the reply. I imagined a greater Windows API or automation may be required. I will definitely keep that option open. With that said, I was thinking a little more about this and one solution that may solve this somewhat, albeit not perfect, would be to reverse the operations a bit with the use of GetElementIds() instead of prompting a selection first. So the order of operations would be:

  • Select elements or even window select a bunch of objects
  • Run command (via shortcut)
  • command will receive the selection via GetElementIds() and filter the selection programmatically if needed
  • Command will continue to run operations desired such as setting a parameter to selected elements
  • To Repeat, the user would go on selecting and calling the command via keyboard shortcut

So mechanically speaking, this may be a quirky workaround to avoid having to click a finish button. The user would just select, hit command shortcut, rinse and repeat vs. the original run command shortcut, select, click finish, rinse and repeat. While not what I was originally hoping for, I suppose this may be one solution to save one step each time. I am still open to hearing any solutions others may have! 

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

Post to forums  

Autodesk Design & Make Report