get_Geometry function

I couldn’t find “get_Geometry” method in revitapidocs. But it is functioning in python. From where those codes coming from. Please help.

1 Like

@shibujoseukken , hi

Dynamo is not pure python, espacily the “get_…” is from C#…

KR

Andreas

check out! :slight_smile:

Is there any alternative for get_ functions?

@shibujoseukken ,

in which context? python, dynamo, designscript ?

python which we can use in Dynamo or where i can find get_ based functions? It is not available in revitapidocs.com.

Hi @shibujoseukken.
As I know get_Geometry is a method of Revit Python Wrapper.

    def get_element(self, wrapped=True):
        """ Element of Reference """
        element = self.doc.GetElement(self.id)
        return element if not wrapped else Element(element)

    def get_geometry(self):
        """ GeometryObject from Reference """
        ref = self._revit_object
        return self.doc.GetElement(ref).GetGeometryObjectFromReference(ref)

https://revitpythonwrapper.readthedocs.io/en/latest/db/reference.html?highlight=get_Geometry

1 Like

Hello,
The methods prefixed by a lowercase get_ are automatically generated getter methods (properties).
.NET properties are backed by a pair of .NET methods for reading and writing the property.
The C# compiler automatically names them as get_<PropertyName> and set_<PropertyName>

So, in Python (with .Net), a property that has a parameter can be written like this (2 ways)

opt = Options()
geo_set = element.get_Geometry(opt)
## OR 
opt = Options()
geo_set = element.Geometry[opt]
6 Likes

The overloaded methods are also viewable if you open the RevitAPI.dll in VS :slight_smile:

2 Likes

as per revitapidocs, the function name is GeometryElement. But in the example, they eliminated ‘Element’. How do we know whether we need to eliminate it or not.

GeometryElement is the type of the return value (Geometry property)

1 Like

The property is called Geometry, so that’s what we use when calling it. What that property stores, and what we retrive by using the get_ prefix, is a GeometryElement.
This is a bit more obvious in the C# example lower down on that page. Specifically this line:
Autodesk.Revit.DB.GeometryElement geomElem = beam.get_Geometry(options);

In C# you have to declare what type of object you are going to assign to a variable, whereas in Python, this is handled for us automatically.
As a result, we can think of that line of code in two steps:

  1. Autodesk.Revit.DB.GeometryElement geomElem
    We tell the computer that the variable geomElem is going to be a GeometryElement. If we try to assign it a different object type - string, integer, ElementId, etc. - it will throw an error.
  2. geomElem = beam.get_Geometry(options);
    We assign our variable geomElem the value stored in the beam object’s Geometry property, which is a GeometryElement.

Generally speaking, if you see get in the syntax section of a property like we do here, you can retrieve what that property stores by putting .get_ in front of the name of that property - in our case Geometry.

4 Likes

You were too fast for me haha

2 Likes