简体   繁体   English

如何从工作表中删除ScheduleInstance?

[英]How to delete ScheduleInstance from sheet?

As we know we have method ViewSheet.DeleteViewPort() method to remove ViewPort from sheet, but i can not find method to remove ScheduleInstance from Sheet, I also try doc.Delete(elementId) method, but it's not work . 众所周知,我们有ViewSheet.DeleteViewPort()方法可以从图纸中删除ViewPort,但是我找不到从Sheet中删除ScheduleInstance的方法,我也尝试了doc.Delete(elementId)方法,但是它不起作用。 So how i can delete it from sheet ??? 那么我如何从工作表中删除呢?

Document.Delete works for me: 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.");
  }
}

Are you calling Commit on your transaction? 您要在交易中致电Commit吗?

Also it's ScheduleSheetInstance , not ScheduleInstance . 同样是ScheduleSheetInstance ,而不是ScheduleInstance

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM