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

EaBIM

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
查看: 1162|回复: 1
打印 上一主题 下一主题

编程创建明细表(2013 新API用法)

[复制链接]

1514

主题

7465

帖子

1万

积分

admin

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

积分
12396

社区QQ达人

跳转到指定楼层
楼主
发表于 2014-1-15 12:41:30 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
创建明细表是Revit2013的一个比较重要的API功能增强点。可以用来创建明细表,

1。指定显示那个类别的对象;

2.  可以定制一个表中有那些列,列的宽度。

3.  也可以向明细表设置过滤器,选择那些对象可以在明细表中显示出来。

4.  明细表排序和分组。



下面代码段显示了如何创建一个房间明细表。代码摘自Revit 2013 SDK 中的ScheduleCreation 例子。

顺便说句: 你可以在这个页面下载到最新的Revit 2013 SDK,包含这个例子。 随产品发布的SDK不包含这个例子。

http://usa.autodesk.com/adsk/ser ... 3112&id=2484975



  1. [csharp] view plaincopy
  2. private ICollection<ViewSchedule> CreateSchedules(UIDocument uiDocument)  
  3. {  
  4.     Document document = uiDocument.Document;  
  5.   
  6.     Transaction t = new Transaction(document, "Create Schedules");  
  7.     t.Start();  
  8.   
  9.     List<ViewSchedule> schedules = new List<ViewSchedule>();  
  10.   
  11.     //Create an empty view schedule of wall category.  
  12.     ViewSchedule schedule = ViewSchedule.CreateSchedule(document, new ElementId(BuiltInCategory.OST_Walls), ElementId.InvalidElementId);  
  13.     schedule.Name = "Wall Schedule 1";  
  14.     schedules.Add(schedule);  
  15.   
  16.     //Iterate all the schedulable field gotten from the walls view schedule.  
  17.     foreach (SchedulableField schedulableField in schedule.Definition.GetSchedulableFields())  
  18.     {  
  19.         //Judge if the FieldType is ScheduleFieldType.Instance.  
  20.         if (schedulableField.FieldType == ScheduleFieldType.Instance)  
  21.         {  
  22.             //Get ParameterId of SchedulableField.  
  23.             ElementId parameterId = schedulableField.ParameterId;  
  24.   
  25.             //If the ParameterId is id of BuiltInParameter.ALL_MODEL_MARK then ignore next operation.  
  26.             if (ShouldSkip(parameterId))  
  27.                 continue;  
  28.   
  29.             //Add a new schedule field to the view schedule by using the SchedulableField as argument of AddField method of Autodesk.Revit.DB.ScheduleDefinition class.  
  30.             ScheduleField field = schedule.Definition.AddField(schedulableField);  
  31.   
  32.             //Judge if the parameterId is a BuiltInParameter.  
  33.             if (Enum.IsDefined(typeof(BuiltInParameter), parameterId.IntegerValue))  
  34.             {  
  35.                 BuiltInParameter bip = (BuiltInParameter)parameterId.IntegerValue;  
  36.                 //Get the StorageType of BuiltInParameter.  
  37.                 StorageType st = document.get_TypeOfStorage(bip);  
  38.                 //if StorageType is String or ElementId, set GridColumnWidth of schedule field to three times of current GridColumnWidth.   
  39.                 //And set HorizontalAlignment property to left.  
  40.                 if (st == StorageType.String || st == StorageType.ElementId)  
  41.                 {  
  42.                     field.GridColumnWidth = 3 * field.GridColumnWidth;  
  43.                     field.HorizontalAlignment = ScheduleHorizontalAlignment.Left;  
  44.                 }  
  45.                 //For other StorageTypes, set HorizontalAlignment property to center.  
  46.                 else  
  47.                 {  
  48.                     field.HorizontalAlignment = ScheduleHorizontalAlignment.Center;  
  49.                 }  
  50.             }  
  51.   
  52.   
  53.             //Filter the view schedule by volume  
  54.             if (field.ParameterId == new ElementId(BuiltInParameter.HOST_VOLUME_COMPUTED))  
  55.             {  
  56.                 double volumeFilterInCubicFt = 0.8 * Math.Pow(3.2808399, 3.0);  
  57.                 ScheduleFilter filter = new ScheduleFilter(field.FieldId, ScheduleFilterType.GreaterThan, volumeFilterInCubicFt);  
  58.                 schedule.Definition.AddFilter(filter);  
  59.             }  
  60.   
  61.             //Group and sort the view schedule by type  
  62.             if (field.ParameterId == new ElementId(BuiltInParameter.ELEM_TYPE_PARAM))  
  63.             {  
  64.                 ScheduleSortGroupField sortGroupField = new ScheduleSortGroupField(field.FieldId);  
  65.                 sortGroupField.ShowHeader = true;  
  66.                 schedule.Definition.AddSortGroupField(sortGroupField);  
  67.             }  
  68.         }  
  69.     }  
  70.   
  71.     t.Commit();  
  72.   
  73.     uiDocument.ActiveView = schedule;  
  74.   
  75.     return schedules;  
  76. }  
复制代码
作者:叶雄进文章来源:http://blog.csdn.net/joexiongjin/article/category/782739

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 转播转播 分享分享 分享淘帖 支持支持 反对反对
工作时间:工作日的9:00-12:00/13:30-18:00,节假日不在线,请勿留言

7

主题

823

帖子

1345

积分

BIM经理

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

积分
1345
2F
发表于 2014-2-20 14:12:12 | 只看该作者
路过!!! 不发表意见……
*滑块验证:
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

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