Revit二次开发示例:DeleteDimensions
2014-03-17 17:01
429 查看
在本例中,创建一个命令,实现删除所选中的尺寸标注。
#region Namespaces using System; using System.Collections.Generic; using System.Diagnostics; using Autodesk.Revit.ApplicationServices; using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Selection; #endregion namespace DeleteDimensions { [Autodesk.Revit.Attributes.Transaction(TransactionMode.Manual)] [Autodesk.Revit.Attributes.Regeneration(RegenerationOption.Manual)] [Autodesk.Revit.Attributes.Journaling(JournalingMode.NoCommandData)] public class Command : IExternalCommand { public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { ElementSet selections = commandData.Application.ActiveUIDocument.Selection.Elements; ElementSet dimsToDelete = new ElementSet(); if (0 == selections.Size) { message = "Please select dimensions"; return Result.Failed; } foreach (Element e in selections) { Dimension dimensionTemp = e as Dimension; if (null != dimensionTemp && !dimensionTemp.Pinned) { dimsToDelete.Insert(dimensionTemp); } } if (0 == dimsToDelete.Size) { message = "There are no unpinned dimensions currently selected"; return Result.Failed; } Transaction transation = new Transaction(commandData.Application.ActiveUIDocument.Document, "External Tool"); transation.Start(); foreach (Element e in dimsToDelete) { commandData.Application.ActiveUIDocument.Document.Delete(e.Id); } transation.Commit(); return Result.Succeeded; } } }
相关文章推荐
- 外媒曝Snapchat“被追”全过程:腾讯最先出手 脸书谷歌跟风
- Spring MVC数据绑定大全
- Android来电铃声默认设置的实现方法与怎么设置语音来电的默认铃声
- Linux进程地址空间之初探:一
- c#存储过程入门,创建和调用
- ld: symbol dyld_stub_binding_helper not found, normally in crt1.o/dylib1.o/bundle1.o for architecture i386
- 虚拟机设定固定ip
- Intent和BroadCast(二)
- Intent和BroadCast(一)
- 导入Android项目要求删除@Override…
- unix 发展史及必须会的shell命令
- jquery选择器
- 只用于块级元素的css
- 一个Highcharts的例子
- Plancha plancha pelo ghd de alisar el cabello GHD Pink no está simplemente haciendo la diferencia en el Reino Unido y también en Estados Unidos el
- JavaScript substring substr slice
- SringMVC 注解标记备忘
- eclise 部署web工程报 There are no resources that can be added or removed from the server.
- awk和cut分割字符区别