我正在为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;
答案 0 :(得分:0)
您不会从uidoc.Selection
中获取计划的选定单元格,因为其中包含了选择的元素。您可以从表中获取数据,并在DataGridView
(WinForms)或DataGrid
(WPF)中创建自己的数据。然后,您知道用户选择了哪些单元格。