Creating dimension where is the error?

hello,

i try to put dimensions

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_ = UnwrapElement(IN[0])
dTypes = FilteredElementCollector(doc).OfClass(DimensionType).ToElements()
linearTypes = [d for d in dTypes if d.StyleType == DimensionStyleType.Linear]
linear = linearTypes[0]
line_ = UnwrapElement(IN[1])

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)):
                    references.Append(face.Reference)
                else:
                    pass
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
nd = doc.Create.NewDimension(doc.ActiveView, line_, references, linear)
TransactionManager.Instance.TransactionTaskDone()

OUT = "Done!"



where is the error

KR

Andreas

Hey,

I think you need to get the geometry curve from the detail line, then try to get the end points from there?

I don’t tend to use defs until I’ve got everything working, just because i find it harder to debug :slight_smile:

I also use dir() a lot :slight_smile:

Hope that helps,

Mark

1 Like