我正在开发一个Dynamo图形,它使用Python节点通过导入CAD几何图形来创建带楼梯平台的楼梯。你可以在迪纳摩论坛的帖子here上看到图表和其他信息
当设置为基本级别1(到级别2)时,它可以正常工作,但任何更高的级别都可以正常工作,它在应该创建的位置上创建一个完整级别,并给出一个错误:Warning1Warning2
任何较低的(B1到标高1),它会给出一个错误,并且不会创建楼梯。PythonScriptError
调整Revit和Dynamo设置、CAD文件或将CAD导入放置在不同的级别上都不会带来好运。Python脚本是唯一剩下的东西:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import StairsRun
from Autodesk.Revit.DB.Architecture import StairsLanding
from Autodesk.Revit.DB import CurveLoop
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
doc = DocumentManager.Instance.CurrentDBDocument
class StairsFailurePreprocessor( IFailuresPreprocessor ):
def PreprocessFailures(self, failuresAccessor):
return FailureProcessingResult.Continue
baseLevel = UnwrapElement(IN[0])
nextLevel = UnwrapElement(IN[1])
b1Curves = IN[2]
r1Curves = IN[3]
p1Curves = IN[4]
b2Curves = IN[5]
r2Curves = IN[6]
p2Curves = IN[7]
elCurves = IN[8]
TransactionManager.Instance.ForceCloseTransaction()
newStairsScope = StairsEditScope(doc, 'New Stairs')
newStairsId = newStairsScope.Start(baseLevel.Id, nextLevel.Id)
trans = Transaction(doc, 'Add Runs and Landings to Stairs')
trans.Start()
bdryCurves1 = list(b1Curves)
riserCurves1 = list(r1Curves)
pathCurves1 = list(p1Curves)
bdryCurves2 = list(b2Curves)
riserCurves2 = list(r2Curves)
pathCurves2 = list(p2Curves)
landingLoop = CurveLoop.Create(elCurves)
r1Count = len(r1Curves)
r2Count = len(r2Curves)
newRun1 = Autodesk.Revit.DB.Architecture.StairsRun.CreateSketchedRun(doc, newStairsId, baseLevel.Elevation, bdryCurves1, riserCurves1, pathCurves1)
newLanding = Autodesk.Revit.DB.Architecture.StairsLanding.CreateSketchedLanding(doc, newStairsId, landingLoop, newRun1.TopElevation)
newRun2 = Autodesk.Revit.DB.Architecture.StairsRun.CreateSketchedRun(doc, newStairsId, newLanding.BaseElevation, bdryCurves2, riserCurves2, pathCurves2)
trans.Commit()
newStairsScope.Commit(StairsFailurePreprocessor())
OUT = newStairsId
感谢您的帮助
谢谢, 洛鲁
标高为0。否则将是标高+标高
newRun1=StairsRun.CreateSketchedRun(doc,newStairsId,0,bdryCurves,riserCurves,pathCurves)
相关问题 更多 >
编程相关推荐