我正在为Revit 2019使用C#。我正在尝试通过更改特定名称的参数来更改计划中选定单元格的值。并且它工作正常,但是现在我需要根据表中选择的列名称来更改参数。当前代码示例为:
UIDocument uidoc = commandData.Application.ActiveUIDocument;
var selection = uidoc.Selection;
var ids = selection.GetElementIds();
var doc = uidoc.Document;
ViewSchedule view = doc.ActiveView as ViewSchedule;
if (view == null) {
return Result.Cancelled;
}
TableData table = view.GetTableData();
TableSectionData section = table.GetSectionData(SectionType.Body);
using (var transaction = new Transaction(doc, "Change param"))
{
transaction.Start();
foreach (var id in ids)
{
var el = doc.GetElement(id);
var param = el.LookupParameter("Number");
param.Set("TempValue");
}
transaction.Commit();
}
return Result.Succeeded;
您不会从uidoc中获得计划的选定单元格。选择是因为已选择了哪些元素。您可以从表中获取数据,并在DataGridView(WinForms)或DataGrid(WPF)中创建自己的数据。然后,您可以知道用户选择了哪些单元格。