I'm fairly new to coding, so this might be obvious.
Why do I get an error "name 'ObjectType' not defined" when I run this code:
picked = uidoc.Selection.PickObject(ObjectType.Element)
I'm using revit python shell (IronPython)
I'm fairly new to coding, so this might be obvious.
Why do I get an error "name 'ObjectType' not defined" when I run this code:
picked = uidoc.Selection.PickObject(ObjectType.Element)
I'm using revit python shell (IronPython)
It's because
ObjectType
is not defined anywhere in that statement's scope:Maybe you forgot an import statement?
You should import
ObjectType
into the current scope:I have just tried this out in the RevitPythonShell and have noticed, that it doesn't work, because the shell is still in the foreground. So, this technique will work for scripts that you add to the Ribbon, but not directly from the shell... I'm not quite sure how to fix this yet. Sorry.
EDIT: Use a function like this one to do the trick:
You can run this by pasting it into the editor pane at the bottom and hitting F5 or adding it to your Init-Script or whatever. And then just call
pickobject()
when you need to pick an Element.