我们知道我们有方法ViewSheet.DeleteViewPort()方法从工作表中删除ViewPort,但我找不到从Sheet中删除ScheduleInstance的方法,我也尝试doc.Delete(elementId)方法,但它不起作用。那我怎么能从表格中删除它
答案 0 :(得分:1)
Document.Delete
适合我:
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
using (var tr = new Transaction(doc, "Delete"))
{
if (tr.Start() == TransactionStatus.Started)
{
ICollection<ElementId> ids = uiDoc.Selection.GetElementIds();
doc.Delete(ids);
tr.Commit();
}
else
{
throw new UserException("Transaction can not be started.");
}
}
您是否在交易中致电Commit
?
也是ScheduleSheetInstance
,而不是ScheduleInstance
。