Search code examples
revitpythonshellpyrevit

Revit API: 'Hidden' methods?


While using Revit API and browsing the "RevitAPI.chm" file (and browsing examples on the internet), I have noticed that some methods exist while not being listed neither in the "RevitAPI.chm" file nor suggested when using RevitPythonShell.

I explain. Let's say for instance that I have a "Space" Object, obtained with

s = FilteredElementCollector(doc).OfClass(SpatialElement).ToElements()

If I do, let's say (assuming s[0] is a valid Space object):

s[0].Geometry

I got an 'indexer object':

<indexer# object at 0x0000000000000049>

But if I do:

s[0].get_Geometry(Options())

Then I got my GeometryElement object. The same behavior goes with get_BoundingBox, for instance.

Now, that's fine, but the only way I could know about these get_something methods is by seeing examples (either on the "RevitAPI.chm", or on forums etc.). So that's kind of strange, isn't it? In the sense that these methods aren't actually listed.

So I guess my questions would be:

  • Is it the normal behavior? (or should I normally just get a GeometryElement object by using s[0].Geometry, for instance?)
  • If yes, ... why ? :D
  • What are these 'indexers' ?

Thanks! Arnaud.

PS: Using Revit 2017, tests made with RevitPythonShell and pyRevit


Solution

  • The methods prefixed by a lowercase get_ are automatically generated getter methods. The official Revit API provides and documents the BoundingBox property on the Element class. Rather inelegantly, this so-called property takes an argument. Therefore, the C# .NET implementation generates a property getter function for it.