Getting Faces and Solids gives errors for Walls and Floors

Hello,
Looks like you wrote f.get instead of floor.get in your loop

Cordially
christian.stan

1 Like

hi, yes you are right, but in this example it does not get a list, but an instance, so the execution goes into the else: part :wink:

1 Like

You will have to wait for people much more savvy than me in python (super beginner mode but it progresses slowly but surely (today I learned the Sets and the Union and Intersection methods)

Cordially
christian.stan

1 Like

Hello @danail.momchilov
I donĀ“t know what your goal is.
In this thread was shown, that all problems with converting to Dynamo geometry can be avoided by just using Revit geometry and not converting it at all. So why donĀ“t you just use the Revit geometry like i did? I did not convert it.

1 Like

Only now I realized what your general idea wasā€¦ sorry about that, it just took some timeā€¦ :smiley: thank you for your thread, I think it could really help a great deal, as I have been struggling with this issue for a long time on many of our workflows! :slight_smile:

hereā€™s what I did with floors:

import clr
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')

import System
from System import Array
from System.Collections.Generic import *

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

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

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

clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")

import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument

opt = Options()

outlist = []

floors = UnwrapElement(IN[0])

for floor in floors:
	templist = []
	solid = floor.get_Geometry(opt)
	for f in solid:
		faces = f.Faces
		for face in faces:
			try:
				if face.FaceNormal.Z == 1:
					outlist.append(face)
			except:
				pass
	
OUT = outlist

Since I only need the uppermost face of each floor, I would just check all face normals of the floorā€™s solids and only get the ones that have a Z component equal to 1. Did some testing to make sure I get the correct ones, by building small floors, that are kind of ā€˜wrappableā€™ (just to be able to visualize it) and it all seems fine :slight_smile:

1 Like