04 - Step-by-Step: Parameter Engine and the Params class
Practice transforming C# properties into interactive UI elements.
1. Create a Params Class
- Open a script in VS Code.
- At the bottom of the file (outside other classes), add:
public class Params {
public double OffsetDistance { get; set; } = 12.0;
} - Save (Ctrl+S) and return to the Parameters tab in Paracore.
2. Add Revit Types (Single & Lists)
- In VS Code, add these properties to your
Paramsclass:public WallType TargetType { get; set; }
public List<WallType> AllTypes { get; set; } - Save and observe the new UI fields.
- Click the Compute button next to these parameters to populate them from your Revit model.
3. Advanced Filtering ([RevitElements])
- Add a filtered property:
[RevitElements(Category = "Doors")]
public FamilySymbol? DoorType { get; set; } - Save, click Compute, and verify that only Door Symbols appear.
4. Custom Providers (_Options and _Filter)
- Add a curated list property and its provider:
public List<Wall> GenericWalls { get; set; }
public List<Wall> GenericWalls_Options =>
new FilteredElementCollector(Doc).OfClass(typeof(Wall)).Cast<Wall>()
.Where(w => w.Name.Contains("Generic")).ToList(); - Add a filtered list property and its predicate:
public List<Room> LargeRooms { get; set; }
public bool LargeRooms_Filter(Room r) => r.Area > 20.0; - Save, click Compute, and observe the filtered lists.
Next Exercise: 05 - Parameter Defaults and Cache