gpt4 book ai didi

python - 从折线获取曲线以创建细节线

转载 作者:太空宇宙 更新时间:2023-11-03 20:47:59 25 4
gpt4 key购买 nike

我正在尝试创建一个脚本,可以从选择中创建详细信息线。

虽然每条线大约有 5 英尺大,但脚本显示以下错误:

Exception : Autodesk.Revit.Exceptions.ArgumentsInconsistentException: Curve length is too small for Revit's tolerance (as identified by Application.ShortCurveTolerance) Parameter name: endpoints

我的代码是:

#Import Autodesk stuffs
import clr
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI.Selection import *

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

# Import iron python packages
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager


app = __revit__.Application
Ui = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document
view = doc.ActiveView

#TransactionManager.Instance.ForceCloseTransaction()
#t = Transaction(doc, "Create CAD Copy")
#t.Start()

from Autodesk.Revit.UI import Selection


selection = [ doc.GetElement( elId ) for elId in __revit__.ActiveUIDocument.Selection.GetElementIds() ]
curve = []
opt = Options()

allGeom =[]
solidGeoms=[]
for i in selection:
geo = i.get_Geometry(opt)
for a in geo:
geo = a.GetInstanceGeometry()
for g in geo:
allGeom.append(g)

Lines=filter(lambda x : type(x)==Line,allGeom)

polylines1=filter(lambda x : type(x)==PolyLine,allGeom)
polylines2=filter(lambda x : type(x)==PolyLine,allGeom)

polypoints1=[]

for i in polylines1:
a = i.GetCoordinates()
polypoints1.Add(a)


pointlist1=[]
for i in polypoints1:
j=i
i.RemoveAt(0)
pointlist1.append(i)
print(pointlist1)


polypoints2=[]

for i in polylines2:
a = i.GetCoordinates()
polypoints2.Add(a)


pointlist2=[]
for i in polypoints2:
j=i
m=i.Count
i.RemoveAt((m-1))
pointlist2.append(i)
print(pointlist2)

line=[]
for i in pointlist1:
for j in pointlist2:
for a in i:
for b in j:
line.append(Line.CreateBound(a,b))

最佳答案

四个嵌套的 for 循环将生成大量的行。我无法想象你真的需要所有这些。您可以添加一个断言,保证 ab 之间的最小距离始终大于(例如,十分之一英寸)约。 2.5毫米。我敢打赌这个断言一定会火。换句话说,您的某些线路可能比 5 英尺短。也许有些长度甚至为零?

关于python - 从折线获取曲线以创建细节线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56444333/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com