Hello,
so i want to create a simple dimension, it almost works, but “XYZ” is for any reason not defined so whats going on?
import sys
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
#Preparing input from dynamo to revit
walls_ = FilteredElementCollector(doc).OfClass(Wall).ToElements()
dTypes = FilteredElementCollector(doc).OfClass(DimensionType).ToElements()
linearTypes = [d for d in dTypes if d.StyleType == DimensionStyleType.Linear]
linear = linearTypes[0]
line_ = UnwrapElement(IN[0]).Location.Curve
opt = Options()
opt.ComputeReferences = True
opt.IncludeNonVisibleObjects = True
opt.View = doc.ActiveView
references = ReferenceArray()
def isParallel(v1,v2):
return v1.CrossProduct(v2).IsAlmostEqualTo(XYZ(0,0,0))
for wall_ in walls_:
for obj in wall_.get_Geometry(opt):
if isinstance(obj, Solid):
solid = obj
for face in solid.Faces:
if isParallel(face.FaceNormal, line_.GetEndPoint(1) - line_.GetEndPoint(0)):
refernces.append(face.Reference)
else:
pass
else:
pass
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
nd = doc.Create.NewDimension(doc.ActivView, line_, references, linear)
TransactionManager.Instance.TransactionTaskDone()
OUT = "done"
KR
Andreas