Geometry of elements in python script

Hi,
here an example

import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

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

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

#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

fecColumns = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_StructuralColumns).WhereElementIsNotElementType()
lst_rvtGeo = []
lst_DSGeo = []

opt = Options()
for e in fecColumns:
	geoSet = e.get_Geometry(opt) # get a set of Revit geometry
	for g in geoSet:
		if isinstance(g, DB.GeometryInstance):
			for gi in g.GetInstanceGeometry():
				if isinstance(gi, DB.Solid) and gi.Volume > 0:
					lst_rvtGeo.append(gi) # get Revit Geometry
					lst_DSGeo.append(gi.ToProtoType()) # convert to Proto Geometry
				else:
					pass
		elif isinstance(g, DB.Solid) and g.Volume > 0:
			lst_rvtGeo.append(g) # get Revit Geometry
			lst_DSGeo.append(g.ToProtoType()) # convert to Proto Geometry
		else:
			pass
opt.Dispose()

OUT = lst_rvtGeo, lst_DSGeo
4 Likes