Reference a geometry of generic model

So I wan’t to get a geometrical reference of a generic model. I’m able to get solids but how to get a reference to its faces? I’m inspired by this post of @MartinSpence Multiple Spot Coordinates

import clr

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

doc = DocumentManager.Instance.CurrentDBDocument

opts = Options()
opts.ComputeReferences = True

floorSolid = UnwrapElement(IN[0]).get_Geometry(opts)

df = []

for i in floorSolid:
	df.append(i.GetInstanceGeometry())

OUT = df[0]

Like so:

import clr

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#clr.AddReference('RevitNodes')
#import Revit
#clr.ImportExtensions(Revit.Elements)
#clr.ImportExtensions(Revit.GeometryConversion)

doc = DocumentManager.Instance.CurrentDBDocument

opts = Options()
opts.ComputeReferences = True

gElem = UnwrapElement(IN[0]).get_Geometry(opts)

df = []

for gObj in gElem:
	if isinstance(gObj,GeometryInstance):
		for iObj in gObj.SymbolGeometry:
			if isinstance(iObj, Solid):
				for f in iObj.Faces:
					df.append(f.Reference)		


OUT = df
2 Likes

Thank you Sir! This is the part I’ve missed SymbolGeometry . Or rather didn’t knew about… How did you learned about this? Because I’ve called with dir() all attributes and that thing is not there…

You are welcome!
I highly recommend RevitApiDocs:

https://www.revitapidocs.com/2015/7a3b5ac1-c66d-9f81-a11d-9bcd4e026295.htm

1 Like

Thanks! I’ve knew about the docs, but there’s less to non explanation about what goes where… And for a newbie with python it’s very problematic because there’s nobody to explain… :roll_eyes:

Well, sometimes it is a bit of a trial and error. For me it would also be more logical to use GetInstanceGeometry rather than SymbolGeometry - but it did not work…

There is not much info about Python in RevitAPI context…usually you have to translate C# solutions (from eg. The Building Coder or official API forums).

It gets bit easier with time :wink:

1 Like