Background: Trying to select a surface of a wall in a linked model. I used some python code from a packaged node by Dimitar Venkov and began modifying it to work with how I wanted it to work.
Inputs: IN(0) is a Link Instance
Current result: nothing is able to be selected, If I remove the ‘selection_filter’ from the PickObject I can pick a point on any object, not just those in the linked document.
Desired Outcome: Be able to select a point (or face) on a wall in the instance link and nothing else (don’t want to be able to pick items in the main document by accident). I am not the only one who uses these codes so I want to make it very user-friendly.
AllowReference method seems to be stated twice in the MySelectionFilter class for some reason. Classes inheriting ISelectionFilter must have two methods, AllowElement() and AllowReference() as documented here…
The ISelectionFilter’s purpose is to customise the filtering of the user selection, within each of the interfaces methods, you can add your own conditional logic. For example, if you want to only filter wall elements, then get the category of the Element being passed into AllowElement(Element element) method and return true if it is of the BuiltInCategory OST_WALLS. AllowReference() should return true if reference type is REFERENCE_TYPE_FOREIGN.
Thank you for your response. I’m new to python coding so learning by cannibalizing things from online and other codes. Based on your response, I adjusted the ISelectionFilter to the below for testing purpose but it’s still not letting me select the PointOnElement.
Updated Code with true on both returns for testing:
View of elevation code is running on (mouse is showing with the cross through it, unable to select any objects):
Couple things I have checked:
The wall is definitely a wall type
There is only one linked model so there is definitely no conflict with a different document/linked instance.
I tried category “OST_WALLS, OST_Walls, Walls, and WALLS”
This is great! is there any way to add the wall type to the filter as well? This already has a significant benefit but that would be the cherry on top.