2

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 !

Community
  • 1
  • 1
Arnaud
  • 445
  • 4
  • 18

1 Answers1

3

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)

Cyril Waechter
  • 517
  • 4
  • 16
  • 2
    Ok indeed it appears at the left bottom ! About what was wrong though in my code : before the "Topmost" line, I had spaces and one tab, where for the other lines I had 2 tabs. I didn't know that python was also sensible to that ! Thanks again ! – Arnaud Nov 14 '14 at 08:03