Revit有一个空闲事件,只要你对Revit的操作一结束,它就会触发
这个事件在UIApplication里添加,如
uiapp.Idling += new System.EventHandler<Autodesk.Revit.UI.Events.IdlingEventArgs>(myfun);
但是请不要在myfun 里弹窗或相似操作,因为弹窗后,你点击确定后,Revit又空闲了,就会再次
触发这个事件,就死循环了。。。
下面是一个用空闲事件改编Revit里的一个文字的类容的例子
先要在Revit里创建一个文字,并且输入一个int的数字,这个鼠标动一下,文字类容就会加1
private void myfun(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
{
UIApplication m_uiapp = sender as UIApplication;
Autodesk.Revit.DB.Document m_doc = m_uiapp.ActiveUIDocument.Document;
Transaction trans = new Transaction(m_doc, "空闲事件");
trans.Start();
ElementId id = new ElementId(313046);//
文字Element的Id,需要修改的,改为读者rvt里的文字Id
TextNote tn = m_doc.GetElement(id) as TextNote;
string str = tn.Text;
int i = 0;
int.TryParse(str, out i);
tn.Text = (i + 1).ToString();
trans.Commit();
}
博主会经常更新一些技术文章,请大家多多关注,多多交流
更多技术交流,请加qq群480950299
6112

被折叠的 条评论
为什么被折叠?



