Start transaction not working with Revit 2014

简介: You're right, it's not being used correctly. The Transaction needs to take place inside the Idling event.
You're right, it's not being used correctly.

The Transaction needs to take place inside the Idling event.

The button click handler and Idling event handler should look something like this in Revit 2014:



void revitApp_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
{
UIApplication uiapp = sender as UIApplication;

UIDocument uidoc = uiapp.ActiveUIDocument;

ElementSet elems = uidoc.Selection.Elements;

if (elems != null)
{
label1.Text = elems.Size.ToString() + " items selected.";
}
else
{
label1.Text = "No elements selected.";
}

if (shouldRun)
{
using (Transaction trans = new Transaction(uidoc.Document, "Hide elements"))
{
trans.Start();
uidoc.Document.ActiveView.HideElements((from Element el in elems select el.Id).ToList());
uidoc.RefreshActiveView();
trans.Commit();
}

shouldRun = false;
}
}

private void button1_Click(object sender, EventArgs e)
{
shouldRun = true;
}

 

目录
相关文章
|
数据库 数据库管理
【异常解决】svn报“Previous operation has not finished; run ‘cleanup‘ if it was interrupted”的错误解决方案
【异常解决】svn报“Previous operation has not finished; run ‘cleanup‘ if it was interrupted”的错误解决方案
451 0
|
Android开发
意外导致了gradle project sync failed. Basic functionality will not work properly
意外导致了gradle project sync failed. Basic functionality will not work properly
意外导致了gradle project sync failed. Basic functionality will not work properly
TortoiseSVN报错:“Previous operation has not finished; run 'clean up' if it was interrupted“ 的解决方法
TortoiseSVN报错:“Previous operation has not finished; run 'clean up' if it was interrupted“ 的解决方法
334 0
TortoiseSVN报错:“Previous operation has not finished; run 'clean up' if it was interrupted“ 的解决方法
svn报错:“Previous operation has not finished; run ‘cleanup‘ if it was interrupted“ 的解决办法
svn报错:“Previous operation has not finished; run ‘cleanup‘ if it was interrupted“ 的解决办法
251 0
svn报错:“Previous operation has not finished; run ‘cleanup‘ if it was interrupted“ 的解决办法
IDEA:cannot start process,the working directory ‘***‘ does not exist
IDEA:cannot start process,the working directory ‘***‘ does not exist
PAT (Advanced Level) Practice - 1014 Waiting in Line(30 分)
PAT (Advanced Level) Practice - 1014 Waiting in Line(30 分)
122 0