user1384026
user1384026

Reputation: 31

Revit 2016 API "Selection Watcher Using Idling Event"

I'm new to the Revit Api and looking for another way to get a selected element other than using the idling event. All the reading I've done, mainly on thebuidingcoder says that this seems to be the only way. Is there another way?

Upvotes: 1

Views: 939

Answers (2)

Daren Thomas
Daren Thomas

Reputation: 70324

If you are trying to do something when the selection changes, you might want to check out the following blog post by Jeremy Tammik: Element Selection Changed Event.

The basic idea is to subscribe to an event as opposed to polling (the IdleEvent method you mentioned or using a timer). Since the Revit API doesn't actually have such an event, a clever guy - let's call him Vilo - came up with the idea to subscribe to the PanelEvent of the Modify panel. This is ingenious! Read the blog post for more information (and sample code!) on how to do this!!

Upvotes: 1

Jeremy Tammik
Jeremy Tammik

Reputation: 8304

That is absolutely not the only way. Selecting an element has nothing whatsoever to do with the Idling event. What utter nonsense!

You can pick an element interactively using the Selection.PickObject method.

You can also retrieve the elements pre-selected before launching the command from the Selection.GetElementIds method.

If you are new to the Revit API, the first thing you should do is work through the getting started material, especially the the DevTV and My First Revit Plugin tutorials.

That answers this question of yours immediately, and many more besides:

http://thebuildingcoder.typepad.com/blog/about-the-author.html#2

Upvotes: 2

Related Questions