public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { // Get Revit Environment UIApplication uiApp = commandData.Application; Document doc = uiApp.ActiveUIDocument.Document; UIDocument uidoc = uiApp.ActiveUIDocument; // Initialize a new Dictionary containing 4 string fields for parameter values Dictionary<ElementId, Tuple<string, string, string, string>> Parameters = new Dictionary<ElementId, Tuple<string, string, string, string>>(); // Walk thru selected elements foreach (ElementId elementid in uidoc.Selection.GetElementIds()) { // Get the element Element element = doc.GetElement(elementid); // Walk thru all parameters foreach (Autodesk.Revit.DB.Parameter param in element.Parameters) { // If the parameter hasn't been added yet, // Add a new entry to the dictionary if (!Parameters.ContainsKey(param.Id)) Parameters.Add(param.Id, new Tuple<string, string, string, string> ( param.Definition.Name, param.StorageType.ToString(), param.AsValueString(), param.IsReadOnly.ToString()) ); } } // Create a new instance of the parameter List Dialog ParameterList parameterListDialog = new ParameterList(); // Walk thru the sorted (by name) dictionary foreach (KeyValuePair<ElementId, Tuple<string, string, string, string>> kvp in Parameters.OrderBy(val => val.Value.Item1)) { // Create a ListViewItem containing all four values as subitems System.Windows.Forms.ListViewItem lvi = new System.Windows.Forms.ListViewItem(); lvi.Text = kvp.Key.IntegerValue.ToString(); lvi.SubItems.Add(kvp.Value.Item1); lvi.SubItems.Add(kvp.Value.Item2); lvi.SubItems.Add(kvp.Value.Item3); lvi.SubItems.Add(kvp.Value.Item4); // Add the ListViewItem to the List View parameterListDialog.parameters.Items.Add(lvi); } // Show the Dialog parameterListDialog.ShowDialog(); // Return Success return Result.Succeeded; }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { // Get Revit Environment uiApp = commandData.Application; Document doc = uiApp.ActiveUIDocument.Document; UIDocument uidoc = uiApp.ActiveUIDocument; AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; // Initialize a new Dictionary containing 4 string fields for parameter values Dictionary <ElementId, Tuple <string, string, string, string> > Parameters = new Dictionary <ElementId, Tuple <string, string, string, string> >(); // Walk thru selected elements foreach (ElementId elementid in uidoc.Selection.GetElementIds()) { // Get the element Element element = doc.GetElement(elementid); // Walk thru all parameters foreach (Autodesk.Revit.DB.Parameter param in element.Parameters) { // If the parameter hasn't been added yet, // Add a new entry to the dictionary if (!Parameters.ContainsKey(param.Id)) { Parameters.Add(param.Id, new Tuple <string, string, string, string> ( param.Definition.Name, param.StorageType.ToString(), param.AsValueString(), param.IsReadOnly.ToString()) ); } } } // Create a new instance of the parameter List Dialog ParameterList parameterListDialog = new ParameterList(); // Walk thru the sorted (by name) dictionary foreach (KeyValuePair <ElementId, Tuple <string, string, string, string> > kvp in Parameters.OrderBy(val => val.Value.Item1)) { // Create a ListViewItem containing all four values as subitems System.Windows.Forms.ListViewItem lvi = new System.Windows.Forms.ListViewItem(); lvi.Text = kvp.Key.IntegerValue.ToString(); lvi.SubItems.Add(kvp.Value.Item1); lvi.SubItems.Add(kvp.Value.Item2); lvi.SubItems.Add(kvp.Value.Item3); lvi.SubItems.Add(kvp.Value.Item4); // Add the ListViewItem to the List View parameterListDialog.parameters.Items.Add(lvi); } // Show the Dialog parameterListDialog.ShowDialog(); // Return Success return(Result.Succeeded); }