600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > python revit二次开发_Revit二次开发06

python revit二次开发_Revit二次开发06

时间:2022-05-31 22:40:55

相关推荐

python revit二次开发_Revit二次开发06

关于Revit模型旋转的问题

RevitPythonshell直接可以运行的

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

# AlexDong

# 1220274707@

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 mit() != mitted:

#print("t --RollBack")

t.RollBack()

add=0

for aa in selection:

#print(aa)

rotateSelectedElement(45,add)

add += 1

#mit()

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。