Tag Archives: VB.Net

Revit – Setting Parameters Values in Macro Programming (with VB.Net)

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?

 

Revit – VB.Net Macro to make Print (Sheet) Sets from Sheet’s parameter.

Back in 2015 when I started learning  programing macros in SharpDevelop in Revit to change  different parameter’s value like Sheet names, Room numbers or custom Parameters, I decided to find a time saving solution to something more serious.

In our office there was a need to create about 35 Sheet Sets for printing purposes from few hundreds of drawings in our project. Sheets created in our project were divided to series.  Because we wanted to have more descriptive information in project browser then just a simple Sheet number we added a custom Project Parameter to Sheets called “Drawing Sheet Series”. (i.e. Sheets begging with number 20 had this parameter set to “(20) General Arrangment”)

This way all the sheets in our project were divided.

As a beginner to start with this task I needed some help. I didn’t know how to alter Revit print settings. It wasn’t easy to understand Revit API help file but I found a useful macro at Boos Your BIM web page (link is hear) which is creating a Sheet Set from Sheets containing in their number specific letters.  In my case I needed to do it for all Sheets therefor changes were required. Additionally because it was written in C# and I was more fluent in VB.Net I decided to translate it.

Below you can find a final macro prepared for Revit 2015:

Continue reading Revit – VB.Net Macro to make Print (Sheet) Sets from Sheet’s parameter.