top of page
作家相片Yimin Chen

在Dynamo透過python節點將視圖放到圖紙上

不囉嗦,直接上程式碼

import clr

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

# Import RevitServices
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Current Revit Document
doc = DocumentManager.Instance.CurrentDBDocument

# Unwrap the inputs
sheet = UnwrapElement(IN[0])
view = UnwrapElement(IN[1])
point = IN[2]  # Point where the view will be placed on the sheet (as a list [x, y])

# Convert the point to XYZ
placement_point = XYZ(point[0], point[1], 0)

# Start a transaction
TransactionManager.Instance.EnsureInTransaction(doc)

for s in sheet:
# Create the viewport
	viewport = Viewport.Create(doc, s.Id, view.Id, placement_point)

# End the transaction
TransactionManager.Instance.TransactionTaskDone()

OUT = viewport

下面提供影片Demo



66 次查看0 則留言

Comments


bottom of page