Hướng dẫn set parameter dynamo python - đặt tham số dynamo python
Có một vài cách khác nhau để thiết lập các tham số trong Revit và mỗi cách có một cách truy cập tương ứng khác nhau.
Các tham số chia sẻ, dự án và gia đình được gọi là 'tham số tùy chỉnh' vì người dùng có thể định nghĩa chúng như họ muốn; Chúng ta sẽ xem xét các công cụ xây dựng riêng biệt. Mỗi loại tham số tùy chỉnh có một cách truy cập khác nhau trong một dự án.custom parameters' as users can define them as they wish; we'll look at BuiltInParameters separately. Each kind of custom parameter has a different way of being accessed within a project.
Cuối cùng, các tham số tùy chỉnh có thể được thực hiện theo danh mục cụ thể, vì vậy chúng chỉ có thể hợp lệ cho các danh mục Revit (ví dụ: một tham số chỉ áp dụng cho các tờ). Xác định cái nào là Để bắt đầu với việc truy cập một tham số bằng mã, trước tiên chúng tôi cần xác định loại tham số nào mà bạn muốn truy cập. Thực hiện theo các bước này để tìm ra những gì bạn đang làm việc với:
Một cách tuyệt vời khác để hiểu loại tham số nào bạn đang xử lý là sử dụng RevitLookup miễn phí Addin cho Revit. Điều này cho phép bạn đọc (gần như) mọi giá trị có thể nhìn thấy và vô hình cho bất kỳ yếu tố Revit nào.RevitLookUp addin for Revit. This lets you read (almost) every visible and invisible value for any Revit element. Nhập khẩu & nbsp; clr nhập & nbsp; sys # nhập revit api clr.addreference ('revitapi') từ & nbsp; autodesk.revit.db & nbsp; Nhập & NBSP; .DesignScript.Geometry & nbsp; Nhập & nbsp;* # Nhận tệp tài liệu hiện tại của Revit. DOC = documentManager.Instance.CurrentDBDocument # Nhận ứng dụng hiện tại Ứng dụng = documentManager.Instance.CurrentUiappLication.Application #get Ứng dụng giao diện người dùng UIAPP = documentManager.Instance.CienUIAPLICATION app # Các phần tử đầu vào động = & nbsp; unwrapelement (trong [0]) parabartype = trong [1] đường kính # Danh sách trống p1 = [] p2 = [] p3 = [] # Đặt mã của bạn bên dưới dòng này # Tra cứu Tham số cho & nbsp; i & nbsp; in & nbsp; phạm vi (0, len (phần tử), 1): p1.Append (yếu tố [i] .lookupparameter (parabartype)) ]. # Bắt đầu Revit Giao dịch Transformanager.Instance.EnsureInTransaction (Doc) # Đặt tham số. cho & nbsp; j & nbsp; in & nbsp; phạm vi (0, len (phần tử), 1): p1 [j] .set (đường kính # Kết thúc Revit Giao dịch Transtermanager.Instance.TransactionTaskDone () out = các phần tử import clr import sys # import Revit API clr.AddReference('RevitAPI') from Autodesk.Revit.DB import * # import Revit API UI clr.AddReference('RevitAPIUI') from Autodesk.Revit.UI import * # import Revit Services clr.AddReference('RevitServices') import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager # import ProtoGeometry clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import * # get Revit's current Document file. doc = DocumentManager.Instance.CurrentDBDocument # get the current application app = DocumentManager.Instance.CurrentUIApplication.Application #get the user interface application uiapp = DocumentManager.Instance.CurrentUIApplication app = uiapp.Application # Dynamo input elements = UnwrapElement(IN[0]) ParaBarType = IN[1] DiameterBarType = IN[2] ParaSpacing = IN[3] ValueSpacing = IN[4] ParaHookType = IN[5] ValueHookType = IN[6] # Empty list p1 = [] p2 = [] p3 = [] # Place your code below this line # look up parameter for i in range(0,len(elements),1): p1.append(elements[i].LookupParameter(ParaBarType)) p2.append(elements[i].LookupParameter(ParaSpacing)) #p3.append(elements[i].LookupParameter("ParaHookType")) # start Revit transaction TransactionManager.Instance.EnsureInTransaction(doc) # set parameter. for j in range(0,len(elements),1): p1[j].Set(DiameterBarType) p2[j].Set(ValueSpacing/304.8) p3[j].Set(ValueHookType) # end Revit transaction TransactionManager.Instance.TransactionTaskDone() OUT = elements ad xem giúp e ạ |