首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >Start transaction not working with Revit 2014

Start transaction not working with Revit 2014

作者头像
hbbliyong
发布于 2018-03-06 10:54:11
发布于 2018-03-06 10:54:11
1.1K0
举报
文章被收录于专栏:hbbliyonghbbliyong
代码语言:javascript
复制
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;
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2014-03-12 ,如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档