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;
}

 

目录
相关文章
|
7月前
|
SQL 数据库 开发者
Liquibase中MARK_RAN与EXECUTED:解析与实战应用.
**摘要:** 了解Liquibase,一个开源的数据库版本控制工具。本文聚焦Liquibase的两个关键概念:MARK_RAN和EXECUTED。这两个概念用于标记事务执行状态,防止重复操作,提升开发效率。MARK_RAN和EXECUTED通过简单添加关键字到SQL语句中实现,确保事务唯一执行,便于问题排查和管理。由木头左带你探索数据库版本控制的奥秘!
Liquibase中MARK_RAN与EXECUTED:解析与实战应用.
|
数据库 数据库管理
【异常解决】svn报“Previous operation has not finished; run ‘cleanup‘ if it was interrupted”的错误解决方案
【异常解决】svn报“Previous operation has not finished; run ‘cleanup‘ if it was interrupted”的错误解决方案
650 0
|
测试技术
loadrunner 运行脚本-Run-time Settings->General->Additional attributes设置
loadrunner 运行脚本-Run-time Settings->General->Additional attributes设置
104 0
|
网络安全 开发工具
【解决方案】A session ended very soon after starting. Check that the command in profile “XXX” is correct.
【解决方案】A session ended very soon after starting. Check that the command in profile “XXX” is correct.
1132 0
【解决方案】A session ended very soon after starting. Check that the command in profile “XXX” is correct.
|
C语言
无法从 repo.msys2.org : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds 获取文件
无法从 repo.msys2.org : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds 获取文件
151 0
We cannot activate inspection type for article master in transaction code MM41?
We cannot activate inspection type for article master in transaction code MM41?
We cannot activate inspection type for article master in transaction code MM41?
PAT (Advanced Level) Practice - 1014 Waiting in Line(30 分)
PAT (Advanced Level) Practice - 1014 Waiting in Line(30 分)
129 0
|
关系型数据库 Shell 网络安全

热门文章

最新文章