Tuesday, March 20, 2007

Revit 2008 API: Pick/Select

Oh, how long were we made to suffer? well, perhaps just the 2 years that the API existed - but it was painful! It was impossible to do what seemed most trivial in any other API... to be able to interactively pick something! Nope, not in Revit - if you wanted something picked, you better have had it picked in advance!

But no more! Finally we have two methods which bring a little bit of interactivity to your Revit application:

  • Pick (single element)
  • WindowSelect()

These methods will give control back to the user to do what they need to do, and add any selected elements to the "SelectedElementsSet". It's limited in that you can't pick a location on the screen - only an element - so while there is still more growth needed here, this represents a good first step.

I think it will also lead to more interactive Revit applications (rather than simple tools) - prior to now you could only work with the pre-selected element set. While this didn't completely preclude multiple pick application scenarios, it certainly made them more awkward.

(In this series of postings, I'll continue to provide short commentary on what's new in the Revit 2008 API, and why I think it's interesting).

2 comments:

Natxo said...

Hi,

Just a question. These two methods could be used within a control modeless. I mean like a button that let's the user select or pick some objets and once is done the dialog returns to be active.

Thanks in advance,

Matt Mason said...

Natxo,

Hi.

I've had no luck yet getting PickOne or WindowSelect to work while there is any kind of dialog active.

I've been meaning to try some more complicated tricks - but to date, I've only been able to get it to work when I close my dialogs, do the selection, then re-open the dialogs.

Best Regards,
Matt