Back in the old days, it was easy to set any parameter value in macro. This was the code I was using in Revit 2014:
element.parameter("Any Parameter Name").set("value")
This was working for Build-in Parameters, Sheared Parameters and Project Parameters. When I migrated some macros to Revit 2017 this formula wasn’t working any more. After some search I found a solution. Unfortunately for every parameter type it’s different.
Build-in Parameters:
Build-in Parameters can be set by referencing to parameter Definition name.
in VB.Net
element.parameter(BuiltInParameter.DEFINITION_NAME).[set]("value")
in Python for Windows Comments parameter:
element.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).Set("value")
Parameter Definition Name one can find using Revit Lookup or in API help.
Example in VB.Net from my amended macro for sheet parameters: Drawn By, Checked By and Sheet Issue Date:
m_vs.parameter(BuiltInParameter.SHEET_DRAWN_BY).[set](curSheet.sheetDrawn) m_vs.parameter(BuiltInParameter.SHEET_CHECKED_BY).[set](curSheet.sheetChecked) m_vs.parameter(BuiltInParameter.SHEET_ISSUE_DATE).[Set](curSheet.sheetDate)
Shared Parameters:
Shared Parameters can be set by referencing their GUID number.
in VB.Net:
element.parameter(New Guid("guid-wierd-number").[set]("value")
in Python in Dynamo it DOESN’T WORK:
from System import Guid NewGuid = Guid("7839a188-7b93-457a-9c33-0a4940183f18") element.Parameter[NewGuid].Set("value")
Guid Number for Shared Parameters can be found in Shared Parameter file i.e
Code example in VB.Net from my amended macro:
m_vs.parameter(New Guid("3c5aa4ef-99ff-4a51-abfe-7f7129b9fed4")).[Set](curSheet.documentType)
Project Parameters:
Project Parameters can be set by referencing in the formula parameter’s Definition by itself.
in VB.Net:
Dim ParameterList As IList(Of Parameter) Parameterlist = element.GetParameters("Parameter Name") Dim Parameter As Parameter Parameter = ParameterList(0) element.parameter(Parameter.Definition).[set]("value")
in Python in Dynamo it DOESN’T WORK:
ParameterList = element.GetParameters("Parameter Name") Parameter = ParameterList[0] element.get_Parameter[Parameter.Definition].Set("value")
Is unsubscriptable with get_Parameter or expects BuiltInParamter.
Any one knows how to make it work in Python in Dynamo?
Hi and thanks for the thread. I am a complete newbie at this but I have dived in and created a VB.NET macro that I need to add data from an excel spreadsheet to create sheets from a list and also populate project parameter fields. Such as “S+D_Sheet Category” which is a string etc.
If I have the following:
m_vs = ViewSheet.Create(curDoc, tblock.Id)
m_vs.parameter(“S+D_Sheet Category”).[Set](curSheet.sortCategory)
This doesn’t work and says “Conversion from string “S+D_Sheet Category” to type ‘integer’ is not valid.
How do I assign values within a List to project parameters?
I can share the complete code if necessary.
Thanks in advance!
Hi,
I’m sorry but I wasn’t checking this site for months.
I suppose you are referring to a Project Parameter which is sorting your sheets so you should use this formula:
Dim ParameterList As IList(Of Parameter)
Parameterlist = element.GetParameters(“Parameter Name”)
Dim Parameter As Parameter
Parameter = ParameterList(0)
element.parameter(Parameter.Definition).[set](“value”)
You need to point to a Parameter.Definition and this is not a sting.
“Parameter Name” replace with “S+D_Sheet Category”.
if this wont work I would suggest to use ArchSmarter Sheet and View Maker. I converted it to work with Revit 2017 long time ago and I added a Project Parameter to it.
I can share it if you steel need it.
Best,
Pablo