• Revit二次开发06


    关于Revit模型旋转的问题

    RevitPythonshell直接可以运行的

    常见问题:缺少的库引用,Autodesk.Revit

    # AlexDong
    # 1220274707@qq.com

    import math

    selection = [doc.GetElement(x) for x in uidoc.Selection.GetElementIds()]

    def rotateSelectedElement(degrees_to_rotate,add):

    from Autodesk.Revit.UI.Selection import ObjectType

    app = __revit__.Application
    doc = __revit__.ActiveUIDocument.Document
    uidoc = __revit__.ActiveUIDocument

    t = Transaction(doc, 'This is my new transaction')

    converted_value = float(degrees_to_rotate) * (math.pi / 180.0)


    t.Start()

    el = selection[add].Id

    el_ID = doc.GetElement(el)

    el_bb = el_ID.get_BoundingBox(doc.ActiveView)

    el_bb_max = el_bb.Max
    el_bb_min = el_bb.Min

    el_bb_center = (el_bb_max + el_bb_min) / 2

    p1 = XYZ(el_bb_center[0], el_bb_center[1], 0)
    p2 = XYZ(el_bb_center[0], el_bb_center[1], 1)
    myLine = Line.CreateBound(p1, p2)

    # Rotate the selected element.
    ElementTransformUtils.RotateElement(doc, el, myLine, converted_value)

    # Close the transaction

    if t.Commit() != TransactionStatus.Committed:
    #print("t --RollBack")
    t.RollBack()


    add=0
    for aa in selection:
    #print(aa)
    rotateSelectedElement(45,add)
    add += 1
    #t.Commit()

  • 相关阅读:
    蓝翔杯子校内赛练习代码
    [蓝桥杯][算法训练VIP]猴子分苹果
    系统设计部分代码
    坐标离散化
    蒟蒻吃药计划-治疗系列 #round 1 机器分配+挖地雷
    蒟蒻吃药计划
    F小蒟蒻教你卡常
    最长不下降子序列
    最大子段和(DP)
    luogu P1216 (USACO1.5) Number Triangles
  • 原文地址:https://www.cnblogs.com/xied/p/13406705.html
Copyright © 2020-2023  润新知