zoukankan      html  css  js  c++  java
  • 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()

  • 相关阅读:
    Chromium(Chrome) frame structure detail
    Chromium(Chrome) Sandbox Details
    ECMA6 New Features
    Asynchronous programming in javascript
    Restful OData Protocol
    java 历年版本特征(简化)
    λ 演算学习
    远程访问其他主机的Mysql(Ubuntu)
    NoSQL基础学习
    Apache solr 6.6.0安装
  • 原文地址:https://www.cnblogs.com/xied/p/13406705.html
Copyright © 2011-2022 走看看