API usage of "get_Geometry" command to retrieve element geometry

Hi everyone,
A bit of a noob question, but I realy have to figure this one out:
When I get the geometry of an element, I have to use the “get_Geometry(options)” syntax. (The same goes for bounding boxes). Why is that? What is the rule of thumb for applying the “get_” command and what does the “options” parameter mean?
Also, why the geometry solids are being output as a single object list?

Thanks!

You can read about Geometry Options here.
But in one sentence: “the options class customizes the type of output you receive”.

1 Like

Thanks!
Any idea about the other issues with retrieving geometry?

hi @ilia.s, below is a sample usage of get_Geometry method. It is collecting Solid geometry and extracting Faces data from Room elements.

# dynamo version - 1.3.4

import clr
clr.AddReference("RevitAPI");
clr.AddReference("RevitNodes")

import Autodesk, Revit;
clr.ImportExtensions(Revit.Elements);
clr.ImportExtensions(Revit.GeometryConversion);
from Autodesk.Revit.DB import *

rooms = UnwrapElement(IN[0]);
result =[];


for room in rooms:
	# geo of room
	geo = room.get_Geometry(Options())
	# get enum
	enum = geo.GetEnumerator()
	# skip one
	next = enum.MoveNext()
	# current geo
	solid = enum.Current
	# get faces
	faces = solid.Faces
	count = 0;
	sub = []
	# each face
	for face in faces:
		count +=1;
		# omit first two (top,btn)
		if count>2:
			# face to dyn obj
			sub.append(face.ToProtoType()[0])
			# curves
			#sub.append(face.GetEdgesAsCurveLoops()[0])
	result.append(sub)
OUT = result

room-surfaces

1 Like

Similarly, you can use the Geometry property like this:

geo = room.Geometry[Options()]

I’m not sure why you can use both the method and the property…

1 Like

Thanks!

Thank you!
Could you please elaborate on the usage of enums? What exactly do hey extract?

hi, @ilia.s, get_Geometry return value is a (kind of) list but it is unsubscriptable which means you can’t use indexing syntax like geo[0] to access list’s items.

But you can use loop or list concatenation or GetEnumerator to access this return value. So, here i used Enumerator and access the list’s item Solid object.

More info about Enumerator: https://docs.microsoft.com/en-us/dotnet/api/system.collections.ienumerable.getenumerator?view=netframework-4.8

1 Like

Awesome! Thanks.