123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- /////////////////////////////////////////////
- //Copyright (c) 2016, SAGA
- //All rights reserved.
- //文件名称: WallExtend.cs
- //文件描述: 墙操作常用扩展方法
- //创 建 者: 刘森
- //创建日期: 2016-05-03
- //版 本 号:1.0.0.0
- /////////////////////////////////////////////
- using System.Collections.Generic;
- using System.Linq;
- using Autodesk.Revit.DB;
- namespace SAGA.RevitUtils.Extends
- {
- public static class WallExtend
- {
- /// <summary>
- /// 墙底部标高
- /// </summary>
- /// <param name="wall"></param>
- /// <returns></returns>
- public static Level GetBaseLevel(this Wall wall)
- {
- ElementId id = wall.GetBaseLevelId();
- if (id != ElementId.InvalidElementId && id != null)
- {
- return wall.Document.GetElement(wall.GetBaseLevelId()) as Level;
- }
- return null;
- }
- /// <summary>
- /// 墙面积(㎡)
- /// </summary>
- /// <returns></returns>
- public static double GetArea(this Wall wall)
- {
- return wall.GetParameterDouble(BuiltInParameter.HOST_AREA_COMPUTED).FromApi(DisplayUnitType.DUT_SQUARE_METERS);
- }
- /// <summary>
- /// 墙底部标高Id
- /// </summary>
- /// <param name="wall"></param>
- /// <returns></returns>
- public static ElementId GetBaseLevelId(this Wall wall)
- {
- return wall.GetParameterElementId(BuiltInParameter.WALL_BASE_CONSTRAINT);
- }
- /// <summary>
- /// 墙顶部标高
- /// </summary>
- /// <param name="wall"></param>
- /// <returns></returns>
- public static Level GetTopLevel(this Wall wall)
- {
- ElementId id = wall.GetTopLevelId();
- if (id != ElementId.InvalidElementId && id != null)
- {
- return wall.Document.GetElement(wall.GetTopLevelId()) as Level;
- }
- return null;
- }
- /// <summary>
- /// 墙顶部标高Id
- /// </summary>
- /// <param name="wall"></param>
- /// <returns></returns>
- public static ElementId GetTopLevelId(this Wall wall)
- {
- return wall.GetParameterElementId(BuiltInParameter.WALL_HEIGHT_TYPE);
- }
- /// <summary>
- /// 墙底部偏移
- /// </summary>
- /// <returns></returns>
- public static double GetBaseOffSet(this Wall wall)
- {
- return wall.GetParameterDouble(BuiltInParameter.WALL_BASE_OFFSET);
- }
- /// <summary>
- /// 获取底部高度
- /// </summary>
- /// <param name="wall"></param>
- /// <returns></returns>
- public static double GetBaseStaticHeight(this Wall wall)
- {
- return wall.GetBaseLevel().Elevation + wall.GetBaseOffSet();
- }
- /// <summary>
- /// 获取顶部高度
- /// </summary>
- /// <param name="wall"></param>
- /// <returns></returns>
- public static double GetTopStaticHeight(this Wall wall)
- {
- return wall.GetTopLevel().Elevation + wall.GetTopOffSet();
- }
- /// <summary>
- /// 墙顶部偏移
- /// </summary>
- /// <param name="wall"></param>
- /// <returns></returns>
- public static double GetTopOffSet(this Wall wall)
- {
- return wall.GetParameterDouble(BuiltInParameter.WALL_TOP_OFFSET);
- }
- /// <summary>
- /// 设置墙底部偏移
- /// </summary>
- /// <param name="offSet">偏移值(英寸)</param>
- /// <returns></returns>
- public static void SetBaseOffSet(this Wall wall, double offSet)
- {
- wall.SetParameter(BuiltInParameter.WALL_BASE_OFFSET, offSet);
- }
- /// <summary>
- /// 设置墙顶部偏移
- /// </summary>
- /// <param name="wall"></param>
- /// <param name="offset">顶部偏移(英寸)</param>
- public static void SetTopOffSet(this Wall wall, double offset)
- {
- wall.SetParameter(BuiltInParameter.WALL_TOP_OFFSET, offset);
- }
- public static void SetMaterial(this WallType wallTyp, ElementId materialId)
- {
- CompoundStructure compoundStructure = wallTyp.GetCompoundStructure();
- List<CompoundStructureLayer> layerList = compoundStructure.GetLayers().ToList();
- int coreIndex = compoundStructure.GetLastCoreLayerIndex();
- compoundStructure.SetMaterialId(coreIndex, materialId);
- wallTyp.SetCompoundStructure(compoundStructure);
- }
- }
- }
|