EaBIM一直以来积极响应国家“十二五”推进建筑业信息化的号召,对建筑领域的信息技术开展深入技术交流和探讨!致力于打造“BIM-建筑师-生态技术”三位一体综合资源交流共享平台,希望为BIM与可持续设计理念及技术的普及做出微小的贡献!!!

EaBIM

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
查看: 1076|回复: 5
打印 上一主题 下一主题

【Revit 技巧】根据共享参数来过滤满足条件的对象(代码)

[复制链接]

1514

主题

7465

帖子

1万

积分

admin

Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10

积分
12396

社区QQ达人

跳转到指定楼层
楼主
发表于 2014-1-9 13:12:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我们经常会添加自己的参数到对象中,一个参数可以添加到多个类别的对象。2011提供的过滤功能可以用参数的值来进行过滤。 下面代码可以对自定义参数按照参数值进行过滤。 我们经常会添加自己的参数到对象中,一个参数可以添加到多个类别的对象。2011提供的过滤功能可以用参数的值来进行过滤。

下面代码可以对自定义参数按照参数值进行过滤。

using System;
using System.Collections.Generic;
using System.Text;
//using System.Windows.Forms;

using Autodesk.Revit .DB;
using Autodesk.Revit.UI;
using Autodesk.Revit .ApplicationServices;
using Autodesk.Revit.Attributes ;

[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[RegenerationAttribute(Autodesk.Revit.Attributes.RegenerationOption.Manual)]

public class ParamFilterTest : IExternalCommand
{
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;

Wall wall = uidoc.Selection.PickObject(
Autodesk.Revit.UI.Selection.ObjectType.Element)
.Element as Wall;

Parameter parameter = wall.get_Parameter(
"MyShared");

ParameterValueProvider pvp
= new ParameterValueProvider(parameter.Id);

FilterStringEquals strEquals = new FilterStringEquals();

FilterStringRule sRule = new FilterStringRule(pvp, strEquals, "MyValue", true);

ElementParameterFilter filter
= new ElementParameterFilter(sRule);

FilteredElementCollector collector
= new FilteredElementCollector(doc);

collector.WherePasses(filter);
TaskDialog.Show("count", collector.ToElementIds().Count.ToString());

return Result.Succeeded;
本文转自柏慕进业  QQ2581830551  Q1群212782804  Q2群218790678  电话021-55669058  微博http://q.weibo.com

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 转播转播 分享分享 分享淘帖 支持支持 反对反对

相关帖子

工作时间:工作日的9:00-12:00/13:30-18:00,节假日不在线,请勿留言

5

主题

857

帖子

1390

积分

BIM经理

Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6

积分
1390
2F
发表于 2014-2-20 14:32:10 | 只看该作者
路过!!! 不发表意见……

14

主题

2892

帖子

2085

积分

BIM经理

Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6

积分
2085
6F
发表于 2016-2-23 09:53:03 | 只看该作者
顶!d=====( ̄▽ ̄*)b
*滑块验证:
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|EaBIM网 ( 苏ICP备2020058923号-1  苏公网安备32011502011255号

GMT+8, 2024-9-28 12:21

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表