利用Revit闲事事件 “commandData.Application.Idling” 简单做一个钟表秒针转动的代码。
Revit二次开发-钟表秒针转动模型
int i = 0;
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
commandData.Application.Idling += Application_Idling;
return Result.Succeeded;
}
private void Application_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
{
var uiapp = sender as UIApplication;
var doc = uiapp.ActiveUIDocument.Document;
using (Transaction tr = new Transaction(doc, "钟表指针"))
{
//模型线id
var modelline = ((doc.GetElement(new ElementId(214944)) as ModelLine).Location as LocationCurve).Curve as Line;
Thread.Sleep(1000);//延迟一秒执行
tr.Start();
ElementTransformUtils.RotateElement(doc, new ElementId(214944), modelline.StartPoint().GoesDirExtend(XYZ.BasisZ, 10), -6.0.AngleToRadius());//旋转构件,6°
tr.Commit();
}
i++;
if (i > 59)
{
uiapp.Idling -= Application_Idling;
}
}
分享一个自制Revit插件,本人是个BIM工程师,该插件是根据自己做工程一些经验和对插件功能的频繁度,自己整合开发功能,初衷是提高效率。
目前MagicTools的功能包括通用功能、土建、机电、审图、出图功能。还有好多功能都想做,如果有好的需求也可以提,后续有新增继续增加上去,努力弄个实用的插件,希望能帮到真正有需要的BIMer。
如有需要的可以加企鹅群:630552940
插件下载地址,免费试用
链接:https://pan.baidu.com/s/1qNnagumXlN6yrIBvRr1dNA?pwd=bljw
提取码:bljw