• Revit二次开发之获得项目族预览图


     

    Revit二次开发之获得项目族预览图

    using Autodesk.Revit.UI;
    using Autodesk.Revit.DB;
    using Autodesk.Revit.Attributes;
    using System.Windows.Media.Imaging;
    using Autodesk.Revit.UI.Selection;
     
    namespace HelloWorld
    {
        [Transaction(TransactionMode.Manual)]
        [Regeneration(RegenerationOption.Manual)]
        public class Test : IExternalCommand
        {
            public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
            {
                UIDocument uidoc = commandData.Application.ActiveUIDocument;
                Document doc = uidoc.Document;
                Reference refer = uidoc.Selection.PickObject(ObjectType.Element,new Filter(), "拾取目标构件");
     
                FamilyInstance instance = doc.GetElement(refer) as FamilyInstance;
                FamilySymbol symbol = instance.Symbol;
     
                //可以将image保存或是传递给PictreBox
                System.Drawing.Image image = symbol.GetPreviewImage(new System.Drawing.Size(100,100));
                
                return Result.Succeeded;
            }
        }
        //过滤器
        public class Filter : ISelectionFilter
        {
            public bool AllowElement(Element elem)
            {
                return elem.Category.Name == "管道附件" & elem.Name == "钢管_沟槽_同径90度弯头_DN25-600";
            }
     
            public bool AllowReference(Reference reference, XYZ position)
            {
                return false;
            }
        }
     
    }
  • 相关阅读:
    【python接口自动化】httpUtils
    mac上安装chromedriver
    python自动化测试报告(excel篇)
    Fiddler 手机抓包介绍
    Fiddler 简单介绍
    Python splinter 环境搭建
    Python pip 常用命令
    Python Yaml 学习
    Jmeter
    Python3 操作Excel
  • 原文地址:https://www.cnblogs.com/liaocheng/p/6029102.html
Copyright © 2020-2023  润新知