zoukankan      html  css  js  c++  java
  • Revit二次开发示例:DesignOptions

    本例只要演示Revit的类过滤器的用法,在对话框中显示DesignOption元素。

    #region Namespaces
    using System;
    using System.Collections;
    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 DesignOptionReader
    {
        [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)
            {
                try
                {
                    Application application = commandData.Application.Application;
                    ElementClassFilter filter = new ElementClassFilter(typeof(Autodesk.Revit.DB.DesignOption));
                    FilteredElementCollector collector = new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document);
                    collector.WherePasses(filter);
                    IEnumerator iter = collector.GetElementIdIterator();
                    Element element;
                    ElementSet designOptions = new ElementSet();
    
                    while (iter.MoveNext())
                    {
                        element = iter.Current as Element;
                        if (element.GetType().Equals(typeof(Autodesk.Revit.DB.DesignOption)))
                        {
                            designOptions.Insert(element);
                        }
                    }
    
                    if (designOptions.Size > 0)
                    {
                        DesignOptionsDialog dialog = new DesignOptionsDialog();
    
                        foreach (Element elem in designOptions)
                        {
                            dialog.DesignOptionsList.Items.Add(elem.Name);
                  
                        }
                        dialog.ShowDialog();
                    }
                    else
                    {
                        TaskDialog.Show("DesignOptions","There are no design options in this document");
                    }
    
                    
                }
                catch (Exception ex)
                {
                    message = ex.Message;
                    return Result.Failed;
                }
    
                return Result.Succeeded;
            }
        }
    }
  • 相关阅读:
    sql server常用
    Building Workspace has encountered a problem
    交换机端口安全Port-Security超级详解
    nginx网站502与504错误分析
    基于IP的nginx反向代理示例
    OpenMediaVault(OMV)安装omv-extras命令
    百度编辑器不能插入html标签解决方法
    如何解决关于ueditor编辑器过滤script/style标签的问题
    inux反选删除文件
    Linux下每天自动备份Mysql数据库发送到指定Email
  • 原文地址:https://www.cnblogs.com/xpvincent/p/3607629.html
Copyright © 2011-2022 走看看