Last active
March 28, 2026 22:45
-
-
Save ssippe/b4f89b18ab54de0d76c4e553590d4ce5 to your computer and use it in GitHub Desktop.
Revit BuiltInParameter Dumper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class Dumper | |
| { | |
| static IReadOnlyList<string> GetValues(BuiltInParameter builtInParameter, Document doc) | |
| { | |
| var values = new List<string>(); | |
| var i = 0; | |
| var targetType = FamilyUtil2.GetElementsElementType<ElementType>(doc) | |
| .FirstOrDefault(dt => dt.get_Parameter(builtInParameter)?.StorageType == StorageType.Integer); | |
| if (targetType == null) | |
| return Array.Empty<string>(); | |
| using (var tx = new Transaction(doc, "CreateReadConventionTestDimTypes")) | |
| { | |
| tx.Start(); | |
| var dupeTargetType = targetType.Duplicate("somerandomthing"); | |
| var param = dupeTargetType.get_Parameter(builtInParameter); | |
| while (true) | |
| { | |
| try | |
| { | |
| param.Set(i); | |
| } | |
| catch (Exception ex) | |
| { | |
| Debug.WriteLine($"exception values.Count={values.Count} i={i} ex={ex}"); | |
| return values; | |
| } | |
| var valueText = param.AsValueString() ?? string.Empty; | |
| if (values.Any(f => f.Equals(valueText) || valueText == i.ToString())) | |
| return values; | |
| values.Add(valueText); | |
| i++; | |
| } | |
| } | |
| } | |
| public static string DumpAll(Document doc) | |
| { | |
| var builtInParameters = EnumExt.GetValues<BuiltInParameter>(); | |
| var result = builtInParameters.Select(builtInParameter => new { builtInParameter, values = GetValues(builtInParameter, doc) }); | |
| var csvText = string.Join("\n", result.SelectMany(f => f.values.Select((value, valueIdx) => $"{f.builtInParameter},{(int)f.builtInParameter},{valueIdx},\"{value}\""))); | |
| return csvText; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment