Hello,
I want to make a script that dimensions my floors in a sectionview.
I found a script that does close to what I want:
This script takes a set of faces to dimension and a line to refer to the position of the dimension.
Now I have made in python a script that finds the floors in the active view, then I extract the top and bottom faces from the floors.
So I can create a dimension between the floors and the floor thicknesses.
I get an error because when I try to get the RevitFaceReference is only shows null values.
I use this to get RevitFaceReference, I need this to make a dimension.
for face in faces:
try:
ref = face.Tags.LookupTag(“RevitFaceReference”)
elementlist.Append(ref)
except:
elementlist.Append(ReferenceArray())
But when I use the dynamo nodes to extract faces the script works
Works:
Does not work
I think the problem lies in my script where I extract the faces from the floors
My script to extract the faces from 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.DB import Options
from Autodesk.Revit.UI import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument
#Functies
#Maakt list als het geen list is
def fun_make_list(input):
input_list = input if isinstance(input, list) else [input]
return input_list
#Krijg parameter waarde
def fun_getparameter(element, parametername):
param = element.LookupParameter(parametername)
if param.StorageType == StorageType.String:
return param.AsString()
else:
return param.AsValueString()
#Set parameters
def fun_setparameter(element, parametername, value):
element.LookupParameter(parametername).Set(value)
#Flatten list
def fun_flattenlist(flist):
return [val for sublist in flist for val in sublist]
floors = FilteredElementCollector(doc, doc.ActiveView.Id).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsNotElementType().ToElements()
breedplaat = [x for x in floors if "breedplaat" in fun_getparameter(x, "Type")]
breedplaat = UnwrapElement(breedplaat)
option = Autodesk.Revit.DB.Options()
option.ComputeReferences = True
solid = [x.get_Geometry(option) for x in breedplaat]
solid = fun_flattenlist(solid)
geo = [i.Convert() for i in solid]
polysurface = [PolySurface.BySolid(i) for i in geo]
surface = [PolySurface.Surfaces(i) for i in polysurface]
faces = []
for i in surface:
faces_sub = []
for j in i:
opp = j.Area
faces_sub.append(opp)
max_value = max(faces_sub)
max_2_values = sorted( [x for x in faces_sub], reverse=True )[:2]
for k in i:
if k.Area == max_2_values[0] or k.Area == max_2_values[1]:
faces.append(k)
#Start transaction
TransactionManager.Instance.EnsureInTransaction(doc)
#End transaction
TransactionManager.Instance.TransactionTaskDone()
OUT = faces