revit二次开发笔记.docx

  1. 1、本文档共9页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Revit2016 二次开发笔记1.选中图元1.1事先选择某类图元(Wall)Autodesk.Revit.UI.UIApplication revit = commandData.Application;ElementSet collection = new ElementSet();ElementSet selWall = new ElementSet();foreach (ElementId elementId in revit.ActiveUIDocument.Selection.GetElementIds()){collection.Insert(revit.ActiveUIDocument.Document.GetElement(elementId)); //选中的原件}foreach (Element ele in sel){Wall wall = ele as Wall; //如果为墙if (wall !=null){SelWal.Insert(ele);}}1.2.通过交互方式1.2.1用矩形框选择图元所用方法:PickElementsByRectangle()using System.Collections.Generic; //声明引用命名空间,IlistUIDocument uidoc = commandData.Application.ActiveUIDocument;ElementSet collector = new ElementSet();IListElement elemList = uidoc.Selection.PickElementsByRectangle();//矩形框的应用string info = 所选图元:;foreach (Element elem in elemList){collector.Insert(elem);info += \n\t + elem.ToString();}TaskDialog.Show(Choose Items, info);return Result.Succeeded;1.2.2用点击选择图元所用方法:PickObject(ObjectType.Element)using Autodesk.Revit.UI.Selection; //声明引用命名空间,ObjectTypeUIDocument uidoc = commandData.Application.ActiveUIDocument;Reference hasPickOne = uidoc.Selection.PickObject(ObjectType.Element);Element elem = uidoc.Document.GetElement(hasPickOne.ElementId);string info = 所选图元:;info += \n\t + elem.GetType().ToString();TaskDialog.Show(Revit, info);还存在其它用法:Selection.PickObject (ObjectType, String) //string 为提示 PickObjects (ObjectType) //允许选择多个元素1.2.3选择及过滤UIDocument uidoc = commandData.Application.ActiveUIDocument;ISelectionFilter selFilter = new MassSelectionFilter();IListElement eList = uidoc.Selection.PickElementsByRectangle(selFilter) as IListElement;string info = 选择了以下的墙:;foreach(Element elem in eList){info += \n\t + elem.Name;}TaskDialog.Show(Revit, info);return Result.Succeeded;public class MassSelectionFilter : ISelectionFilter{public bool AllowElement(Element elem){return elem is Wall; //选择了墙}public bool AllowReference(Reference reference, XYZ position){throw new NotImplementedException();// 第二个条件}}2.加载族并创建实例UIApplication m_applica

文档评论(0)

js1180 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档