Revit API遍历系统族布置喷头
系统族可以通过内参遍历,遍历出来是个FamilySymbol
喷头属于系统族,但不能通过NewDuct();类似这样的方法布置。
必须使用
NewFamilyInstance()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; using WinForm = System.Windows.Forms; using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes; using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.ApplicationServices; using Autodesk.Revit.DB.Structure;
using Autodesk.Revit.DB.ExtensibleStorage;
using Autodesk.Revit.DB.Plumbing;
using Autodesk.Revit.DB.Architecture; using System.Xml; namespace RevitCodes
{ [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class cmdSprinklers : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
UIApplication uiApp = commandData.Application;
Document doc = uiApp.ActiveUIDocument.Document;
Selection sel = uiApp.ActiveUIDocument.Selection; Transaction ts = new Transaction(doc, "http://revit.5d6d.com");
ts.Start(); //从系统族中过滤出喷头,是作为一个FamilySymbol存在的
FilteredElementCollector collector = new FilteredElementCollector(doc);
//此法可以只过滤系统类型
//collector.OfClass(typeof(FamilySymbol)).OfCategory(BuiltInCategory.OST_Sprinklers);
collector.OfCategory(BuiltInCategory.OST_Sprinklers);
FamilyInstance fi = null;//如果已经布置了,就是族实例
int iFi = ;
FamilySymbol symbol = null;//系统族是族符号
int iFs = ;
foreach (Element el in collector.ToElements())
{
fi = el as FamilyInstance;
if (fi != null)
iFi += ;
symbol = el as FamilySymbol;
if (symbol != null)
iFs += ;
}
TaskDialog.Show("count", iFi + "," + iFs);
if (fi != null)
doc.Create.NewFamilyInstance(new XYZ(, , ), fi.Symbol, StructuralType.Beam);
if (symbol != null)
doc.Create.NewFamilyInstance(new XYZ(, , ), symbol, StructuralType.Beam); ts.Commit(); return Result.Succeeded;
}
XYZ PointOnFace(PlanarFace face)
{
XYZ p = new XYZ(, , );
Mesh mesh = face.Triangulate(); for (int i = ; i < mesh.NumTriangles; ++i)
{
MeshTriangle triangle = mesh.get_Triangle(i);
p += triangle.get_Vertex();
p += triangle.get_Vertex();
p += triangle.get_Vertex();
p *= 0.3333333333333333;
break;
}
return p;
}
}
}
url:http://greatverve.cnblogs.com/p/api-Sprinklers.html
Revit API遍历系统族布置喷头的更多相关文章
- Revit API取得系统族普通族几何信息的方法
系统族,可以直接转化为对应的类(Wall,Duct)然后取得几何信息,普通族需要转化为FamilyInstance )) { TaskDialog.Show() ...
- Revit API 加载族并生成实例图元
在Revit API中加载族可以使用Doc.LoadFamily方法,传入要加载的族文件路径名,但是这种方式有一种缺点,就是如果族文件在当前工程中没有加载的话则返回成功,如果已经加载过,则返回失败,也 ...
- Revit API遍历全部风管,找到与风管相关的墙开洞
涉及向量计算,求相交等相关技术. ) { foreach (Face face in solid.Faces) ...
- Revit二次开发-根据Element获取系统族信息
Element element = doc.getElement(elementId); Autodesk.Revit.DB.Parameter familyType = element.get_Pa ...
- windows API 统计系统字体
最近工作中遇到一个需求,需要统计当前系统中包含的所有字体.在网上逛了一圈后发现了EnumFontFamiliesEx这个API好像就可以实现这个功能.这里将自己对这个API的理解做一个记录,算是对这块 ...
- Revit API过滤管道系统类型
管道只能通过PipeType过滤出来类型属性,只能是系统族的类型属性.管道实例过滤不能用族符号和族实例,要用Pipe using System; using System.Collections.Ge ...
- C#遍历系统所安装的打印机,使用WMI方式获取打印机的所有属性
有网友发消息来询问,C#如何遍历系统已经安装的所有打印机,并获得每个打印机的相关信息,如:端口,名称等等 C#里面,虽然在 System.Drawing.Printing 这个namespace下,提 ...
- ASP.NET Web API路由系统:路由系统的几个核心类型
虽然ASP.NET Web API框架采用与ASP.NET MVC框架类似的管道式设计,但是ASP.NET Web API管道的核心部分(定义在程序集System.Web.Http.dll中)已经移除 ...
- ASP.NET Web API路由系统:Web Host下的URL路由
ASP.NET Web API提供了一个独立于执行环境的抽象化的HTTP请求处理管道,而ASP.NET Web API自身的路由系统也不依赖于ASP.NET路由系统,所以它可以采用不同的寄宿方式运行于 ...
随机推荐
- CodeForces Contest #1110: Global Round 1
比赛传送门:CF #1110. 比赛记录:点我. 涨了挺多分,希望下次还能涨. [A]Parity 题意简述: 问 \(k\) 位 \(b\) 进制数 \(\overline{a_1a_2\cdots ...
- Windows运行命令
winver---------检查Windows版本 wmimgmt.msc----打开windows管理体系结构 wupdmgr--------windows更新程序 winver--------- ...
- usb的一些网址
一些关于usb的帖子.网址: usb gadget device g_ether.ko 做成usbnetwork http://bbs.csdn.net/topics/370120345 Linux ...
- 高通Trustzone and QSEE介绍
http://blog.csdn.net/iamliuyanlei/article/details/52625968
- 004_加速国内docker源下载速度
docker下载慢的不行.国内加速器地址 http://355dbe53.m.daocloud.iohttps://docker.mirrors.ustc.edu.cn https://hub-mir ...
- 002_CentOS-6.4-x86_64安装包的说明
http://mirrors.sohu.com/centos/6.6/isos/x86_64/?qq-pf-to=pcqq.group //souhu镜像下载地址 0_README.txt 25-Oc ...
- CentOS 5.x 键盘布局改为日语
CentOS 5.x 直接在系统设置界面修改键盘布局,可能不起作用,需要按如下步骤修改配置文件. 1. /etc/sysconfig/keyboard KEYTABLE="jp106&quo ...
- Java多态概述
多态 所谓多态,实际上就是一个对象的多种状态: 下面例子中,Tiger可以看做Tiger,也可以看做Animal Cat 可以看做Cat,也可以看做Animal Dog 可以看做Dog,也可以看做A ...
- python日常
1.远程访问远程访问Jupyter Notebook,本地浏览器不能打开,先查了防火墙的状态,然后将设置的端口进行allow,网址,仍然拒绝链接,而后通过远程访问Jupyter Notebook,然后 ...
- Vue 动态组件渲染问题分析
fire 读在最前面: 1.本文适用于有一定基础的vue开发者,需要了解基本的vue渲染流程 2.本文知识点涉及vue构造器以及选项策略合并.<component> 渲染逻辑 问题描述: ...