Revit API : "PickObject" not displaying dialog window

647 views Asked by At

I just did what is written here, but I got a problem with __window__.Topmost = True.

(So, I'm running directly from the Shell)

Here is my complete code :

def Test(self) :
   __window__.Hide()
   sel = __revit__.ActiveUIDocument.Selection
   pickedRef = sel.PickObject(ObjectType.Element, "Please select a group");
   __window__.Show()
   __window__.Topmost = True
   return pickedRef

Indeed, if I do that, I got an error message saying that 'return' is outside function. If I change the 'return' line with something else, like elem = Element.GetGeometryObjectFromReference(pickedRef), then it says that there is an unexpected indent (of course I checked indentation, should be ok normally).

Finally, if I comment the __window__.Topmost line, then I got no error message.

Do you also experience problems with that ?

But then my biggest issue is that in the end, I get to select an element, but I see no dialog window popping up with the expected message "please select a group"). Where does that come from ? I guess the "topmost" command just brings back the shell on top, so it doesn't come from that...

Any clue ?

Thanks a lot !

1

There are 1 answers

1
Cyril Waechter On BEST ANSWER

I answered to your comment in french on my website : here

PickObject Method is not supposed to make any window popping up. It shows an help message at bottom left corner, check this image : ! Revit extract with message

Here is a working code :

def pickobject():
    from Autodesk.Revit.UI.Selection import ObjectType
    __window__.Hide()
    picked = uidoc.Selection.PickObject(ObjectType.Element, "Select object")
    __window__.Show()
    __window__.Topmost = True
    return picked

Moreover, you are not supposed to add "self" in this context. It will return the following error : Traceback (most recent call last): File "", line 1, in TypeError: pickobject() takes exactly 1 argument (0 given)