Restriction on Selection of Elements (Not to use PickObject)

arpankumar.macwan
Enthusiast
Enthusiast

Restriction on Selection of Elements (Not to use PickObject)

arpankumar.macwan
Enthusiast
Enthusiast

Hi,

I am using Modeless form and once the Form is open I want to put some restriction on selection of Element.

I know Using PickObject method with Selection filter we can achieve this. But I do not want to use Pick object method because I am using Selection Change Event to get notified.

 

Once the Modeless form open, I want to restrict user to select Element from predefined list of elements only. So whenever user select any element , it will be only from list of elements. He should not be able to select any other element.

 

Once the modeless form is closed, Revit should reset all these restriction.

 

Thanks,

Arpan Macwan

 

 

0 Likes
Reply
Accepted solutions (1)
526 Views
4 Replies
Replies (4)

jeremy_tammik
Autodesk
Autodesk
Accepted solution

First of all, if you are in a modeless form, you cannot use the Revit API at all, off-hand.

 

You need to implement an external event to access a valid Revit API context.

 

This is demonstrated by the ModelessDialog/ModelessForm_ExternalEvent DSK sample.

 

Secondly, if you wish to pick an element, you have to use PickObject or one of its sibling methods.

 

Third, you can very well restrict the allowed used selection to a specific list of element ids by implementing an appropriate selection filter. Implement a selection filter that takes the required list and refuse to select any other elements by returning false from AllowElement:

 

https://www.revitapidocs.com/2022/9c967926-c396-6e6b-97a2-b6882d71b69e.htm

  

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

arpankumar.macwan
Enthusiast
Enthusiast

Okay, so the only option to limit user from selecting elements out of given list of elements is using SelectionFilter in PickObject.

In Modeless form, I can never limit user from selecting elements out side of pre-defined list of elements. Right?

jeremy_tammik
Autodesk
Autodesk

Slight corrections:

 

The only option to prompt the user to select elements interactively is using PickObject and its sibling methods.

 

Therefore, the rest of your statement is superfluous, tautological.

  

Secondly:

  

You cannot pick elements in a modeless form at all. The Revit API is single threaded, and the API cannot be used at all except in a valid Revit API context.

 

So, in a modeless form, the user cannot select elements at all, period.

  

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

arpankumar.macwan
Enthusiast
Enthusiast

Thanks @jeremy_tammik  for the knowledge.

0 Likes