【发布时间】:2021-02-25 01:50:53
【问题描述】:
在这段代码中,我试图通过边界线创建一个新维度作为参考,但它抛出了 InvalidOperationException: Invalid number of references。我想为边界的每一行添加一个新维度。
谁能帮帮我?
from Autodesk.Revit.DB import FilteredElementCollector, BuiltInCategory, Transaction, Plane
from Autodesk.Revit.UI import Selection
doc=__revit__.ActiveUIDocument.Document
uidoc=__revit__.ActiveUIDocument
filledregion_ids=uidoc.Selection.GetElementIds()
filledregion_elements=[]
for id in filledregion_ids:
filledregion_elements.append(doc.GetElement(id))
curve_ref_even=ReferenceArray()
curve_ref_odd=ReferenceArray()
count=0
boundcount=0
regcount=0
newplane=Plane.CreateByThreePoints(XYZ(100,0,0),XYZ(0,100,0),XYZ(0,0,0))
'''Getting filled regions'''
for region in filledregion_elements:
boundary=region.GetBoundaries()
for bound in boundary:
boundcount+=1
print(boundcount)
lastline=list(bound)[0]
for lines in bound:
if (count//2)==0:
curve_ref_even.Append(lines.Reference)
print(curve_ref_even)
if len(list(curve_ref_even))==2:
t= Transaction(doc, "Create dimension")
t.Start()
doc.Create.NewDimension(doc.ActiveView,lines,curve_ref_even)
t.Commit()
count+=1
else:
curve_ref_odd.Append(lines.Reference)
print(curve_ref_odd)
if len(list(curve_ref_odd))==2:
t= Transaction(doc, "Create dimension")
t.Start()
doc.Create.NewDimension(doc.ActiveView,lines,curve_ref_odd)
t.Commit()
count+=1
boundcount=0
count=0
【问题讨论】:
标签: ironpython revit-api