以下是Python节点的输入顺序:
IN [0] - 参数名称作为字符串。这将是你的参数的名称。
IN [1] - Group Name as String。这将是共享参数组名称。该参数将被存储在该组中。
IN [2] - 参数类型,它定义是否是一个是/否,文本,整数等参数类型。在左边有一个单独的Python节点,枚举项目中可用的所有参数类型,以便获取其中的一个。
IN [3] - 可见?这是一个布尔真/假,这将使参数用户可见(它将显示在元素的属性中)或不可见(用户不能看到参数,它只能通过API访问)
IN [4] - 元素类别。这是一个你想添加参数到ex的类别。通用模型或家具。
IN [5] - 参数组。这是在UI中显示时参数存储的组。当您选择一个元素时,每个参数都在一个组内。最常用的是图形,文本,标识等,但还有更多可用于放置您的参数。
IN [6] - 实例?这是一个布尔真/假,确定这将是一个实例或类型参数。
一旦你运行这个定义,它将在共享参数文件中创建参数,并将其添加到项目中。
参数类型节点的代码 Parameter Group node:
import clr clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import * # Import DocumentManager and TransactionManager clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager # Import RevitAPI clr.AddReference("RevitAPI") import Autodesk from Autodesk.Revit.DB import * import System #Assign your output to the OUT variable OUT = System.Enum.GetValues(ParameterType)
参数组节点Parameter Group node:
import clr clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import * # Import DocumentManager and TransactionManager clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager # Import RevitAPI clr.AddReference("RevitAPI") import Autodesk from Autodesk.Revit.DB import * import System #Assign your output to the OUT variable OUT = System.Enum.GetValues(BuiltInParameterGroup)
参数创建节点parameter creation node:
import clr clr.AddReference(‘ProtoGeometry’) from Autodesk.DesignScript.Geometry import * # Import DocumentManager and TransactionManager clr.AddReference(“RevitServices”) import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager # Import RevitAPI clr.AddReference(“RevitAPI”) import Autodesk from Autodesk.Revit.DB import * doc = DocumentManager.Instance.CurrentDBDocument uiapp = DocumentManager.Instance.CurrentUIApplication app = uiapp.Application from System.Collections.Generic import * # Import ToDSType(bool) extension method clr.AddReference(“RevitNodes”) import Revit clr.ImportExtensions(Revit.Elements) import System #The inputs to this node will be stored as a list in the IN variable. dataEnteringNode = IN _paramName = IN[0] _groupName = IN[1] _paramType = IN[2] _visible = IN[3] _category = IN[4] _paramGroup = IN[5] _instance = IN[6] def ParamBindingExists(_doc, _paramName, _paramType): map = doc.ParameterBindings iterator = map.ForwardIterator() iterator.Reset() while iterator.MoveNext(): if iterator.Key != None and iterator.Key.Name == _paramName and iterator.Key.ParameterType == _paramType: paramExists = True break else: paramExists = False return paramExists def RemoveParamBinding(_doc, _paramName, _paramType): map = doc.ParameterBindings iterator = map.ForwardIterator() iterator.Reset() while iterator.MoveNext(): if iterator.Key != None and iterator.Key.Name == _paramName and iterator.Key.ParameterType == _paramType: definition = iterator.Key break message = None if definition != None: map.Remove(definition) message = “Success” return message #”Start” the transaction TransactionManager.Instance.EnsureInTransaction(doc) message = None if ParamBindingExists(doc, _paramName, _paramType): if not RemoveParamBinding(doc, _paramName, _paramType) == “Success”: message = “Param Binding Not Removed Successfully” else: message = None try: file = app.OpenSharedParameterFile() except: message = “No Shared Parameter file found.” pass group = file.Groups.get_Item(_groupName) if group == None: group = file.Groups.Create(_groupName) if group.Definitions.Contains(group.Definitions.Item[_paramName]): _def = group.Definitions.Item[_paramName] else: _def = group.Definitions.Create(_paramName, _paramType, _visible) builtInCategory = System.Enum.ToObject(BuiltInCategory, _category.Id) cats = app.Create.NewCategorySet() cats.Insert(doc.Settings.Categories.get_Item(builtInCategory)) if _instance: bind = app.Create.NewInstanceBinding(cats) else: bind = app.Create.NewTypeBinding(cats) param = doc.ParameterBindings.Insert(_def, bind, _paramGroup) # “End” the transaction TransactionManager.Instance.TransactionTaskDone() #Assign your output to the OUT variable if message == None: OUT = “Success” else: OUT = message
http://www.360doc.com/content/16/0624/11/13726687_570358668.shtml