在本例中,创建一个命令,实现删除所选中的尺寸标注。

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

Revit二次开发示例:DeleteDimensions的更多相关文章

  1. Revit二次开发示例:HelloRevit

    本示例实现Revit和Revit打开的文件的相关信息. #region Namespaces using System; using System.Collections.Generic; using ...

  2. Revit二次开发示例:EventsMonitor

    在该示例中,插件在Revit启动时弹出事件监控选择界面,供用户设置,也可在添加的Ribbon界面完成设置.当Revit进行相应操作时,弹出窗体会记录事件时间和名称. #region Namespace ...

  3. Revit二次开发示例:ErrorHandling

    本示例介绍了Revit的错误处理.   #region Namespaces using System; using System.Collections.Generic; using Autodes ...

  4. Revit二次开发示例:ChangesMonitor

    在本示例中,程序监控Revit打开文件事件,并在创建的窗体中更新文件信息.   #region Namespaces using System; using System.Collections.Ge ...

  5. Revit二次开发示例:AutoStamp

    该示例中,在Revit启动时添加打印事件,在打印时向模型添加水印,打印完成后删除该水印.   #region Namespaces using System; using System.Collect ...

  6. Revit二次开发示例:ModelessForm_ExternalEvent

    使用Idling事件处理插件任务. #region Namespaces using System; using System.Collections.Generic; using Autodesk. ...

  7. Revit二次开发示例:Journaling

    关于Revit Journal读写的例子.   #region Namespaces using System; using System.Collections.Generic; using Sys ...

  8. Revit二次开发示例:DisableCommand

    Revit API 不支持调用Revit内部命令,但可以用RevitCommandId重写它们(包含任意选项卡,菜单和右键命令).使用RevitCommandId.LookupCommandId()可 ...

  9. Revit二次开发示例:DesignOptions

    本例只要演示Revit的类过滤器的用法,在对话框中显示DesignOption元素. #region Namespaces using System; using System.Collections ...

随机推荐

  1. 地位尴尬的WebForm、ASP.NET核心知识(10)

    WebForm之烦恼 1.winform式的开发方式 WebForm的开发方式中,只需要从工具箱中拖拽一个控件,再从.aspx.cs中写控件的事件逻辑,就好了. 微软为我们做了很多工作,很多东西不需要 ...

  2. 微信小程序开发教程(七)逻辑层——.js详解

    逻辑层,是事务逻辑处理的地方.对于小程序而言,逻辑层就是.js脚本文件的集合.逻辑层将数据进行处理后发送给视图层,同时接收视图层的事件反馈. 微信小程序开发框架的逻辑层是由JavaScript编写.在 ...

  3. Ubuntu下hadoop环境的搭建(伪分布模式)

    Ubuntu下hadoop环境的搭建(伪分布模式) 一.必要资源的下载 1.Java jdk(jdk-8u25-linux-x64.tar.gz)的下载 具体链接为: http://www.oracl ...

  4. 天梯赛 L2-007. (并查集) 家庭房产

    题目链接 题目描述 给定每个人的家庭成员和其自己名下的房产,请你统计出每个家庭的人口数.人均房产面积及房产套数. 输入格式: 输入第一行给出一个正整数N(<=1000),随后N行,每行按下列格式 ...

  5. 字符加密 cipher

    评测传送门 Description: Valentino 函数的定义: 对于一个由数字和小写字母组成的字符串 S,两个整数 K,M,将 S 视为一个 P 进制数,定义: Valentino(S, K, ...

  6. Nginx配置location及rewrite规则

    Nginx配置location及rewrite规则 示例: location  = / {   # 精确匹配 / ,主机名后面不能带任何字符串   [ configuration A ] } loca ...

  7. Html5使用history对象history.pushState()和history.replaceState()方法添加和修改浏览历史记录

    根据网上参考自己做个笔记:参考网址:http://javascript.ruanyifeng.com/bom/history.html history.pushState() HTML5为histor ...

  8. CSS overscroll-behavior

    overscroll-behavior新属性解决了在手机上弹出滚动的一些问题,具体内容查看网址:https://www.w3cplus.com/css/overscroll-behavior.html

  9. 03 Go 1.3 Release Notes

    Go 1.3 Release Notes Introduction to Go 1.3 Changes to the supported operating systems and architect ...

  10. Python开发环境(2):启动Eclipse时检测到PYTHONPATH发生改变

    OS:Windows 10家庭中文版,Eclipse:Oxygen.1a Release (4.7.1a),PyDev:6.3.2 4月25日,在Eclipse上安装了PyDev(前面博文有记录),并 ...