当前位置: 首页>>代码示例>>C#>>正文


C# Room.get_Parameter方法代码示例

本文整理汇总了C#中Room.get_Parameter方法的典型用法代码示例。如果您正苦于以下问题:C# Room.get_Parameter方法的具体用法?C# Room.get_Parameter怎么用?C# Room.get_Parameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Room的用法示例。


在下文中一共展示了Room.get_Parameter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShareParameterExists

 /// <summary>
 /// Check to see whether specified parameter exists in room object.
 /// </summary>
 /// <param name="roomObj">Room object used to get parameter</param>
 /// <param name="paramName">parameter name to be checked</param>
 /// <param name="sharedParam">shared parameter returned</param>
 /// <returns>true, the parameter exists; false, the parameter doesn't exist</returns>
 public static bool ShareParameterExists(Room roomObj, String paramName, ref Parameter sharedParam)
 {
     // get the parameter
     try
     {
         sharedParam = roomObj.get_Parameter(paramName);
     }
     catch
     {
     }
     return (null != sharedParam);
 }
开发者ID:AMEE,项目名称:revit,代码行数:19,代码来源:RoomsData.cs

示例2: GetProperty

        /// <summary>
        /// Get the room property value according the parameter name
        /// </summary>
        /// <param name="activeDoc">Current active document.</param>
        /// <param name="room">an instance of room class</param>
        /// <param name="paraEnum">the parameter used to get parameter value</param>
        /// <param name="useValue">convert parameter to value type or not.
        /// if true, the value of parameter will be with unit.
        /// if false, the value of parameter will be without unit.</param>
        /// <returns>the string value of property specified by shared parameter</returns>
        public static String GetProperty(Document activeDoc, Room room, BuiltInParameter paraEnum, bool useValue)
        {
            String propertyValue = null;  //the value of parameter

            // Assuming the build in parameter is legal for room.
            // if the room is not placed, some properties are not available, i.g. Level name, Area ...
            // trying to retrieve them will throw exception;
            // however some parameters are available, e.g.: name, number
            Parameter param;
            try
            {
                param = room.get_Parameter(paraEnum);
            }
            catch (Exception)
            {
                // throwing exception for this parameter is acceptable if it's a unplaced room
                if (null == room.Location)
                {
                    propertyValue = "Not Placed";
                    return propertyValue;
                }
                else
                {
                    throw new Exception("Illegal built in parameter.");
                }
            }

            // get the parameter via the built in parameter
            if (null == param)
            {
                return "";
            }

            // get the parameter's storage type and convert parameter to string
            StorageType storageType = param.StorageType;
            switch (storageType)
            {
                case StorageType.Integer:
                    int iVal = param.AsInteger();
                    propertyValue = iVal.ToString();
                    break;
                case StorageType.String:
                    propertyValue = param.AsString();
                    break;
                case StorageType.Double:
                    // AsValueString will make the return string with unit, it's appreciated.
                    if (useValue)
                    {
                        propertyValue = param.AsValueString();
                    }
                    else
                    {
                        propertyValue = param.AsDouble().ToString();
                    }
                    break;
                case StorageType.ElementId:
                    Autodesk.Revit.DB.ElementId elemId = param.AsElementId();
                    Element elem = activeDoc.get_Element(elemId);
                    propertyValue = elem.Name;
                    break;
                default:
                    propertyValue = param.AsString();
                    break;
            }

            return propertyValue;
        }
开发者ID:AMEE,项目名称:revit,代码行数:77,代码来源:RoomsData.cs

示例3: UpdateNewRoom

        /// <summary>
        /// Update new room with values in spreadsheet, currently there are three columns need to be set.
        /// </summary>
        /// <param name="newRoom">New room to be updated.</param>
        /// <param name="index">The index of row in spreadsheet, use values of this row to update the new room.</param>
        private void UpdateNewRoom(Room newRoom, int row)
        {
            String[] constantColumns = { RoomsData.RoomName, RoomsData.RoomNumber, RoomsData.RoomComments };
            for (int col = 0; col < constantColumns.Length; col++)
            {
                // check to see whether the column exists in table
                if (m_spreadRoomsTable.Columns.IndexOf(constantColumns[col]) != -1)
                {
                    // if value is not null or empty, set new rooms related parameter.
                    String colValue = m_spreadRoomsTable.Rows[row][constantColumns[col]].ToString();
                    if (String.IsNullOrEmpty(colValue))
                    {
                        continue;
                    }

                    switch (constantColumns[col])
                    {
                        case RoomsData.RoomName:
                            newRoom.Name = colValue;
                            break;
                        case RoomsData.RoomNumber:
                            newRoom.Number = colValue;
                            break;
                        case RoomsData.RoomComments:
                            Parameter commentParam = newRoom.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS);
                            if (null != commentParam)
                            {
                                commentParam.Set(colValue);
                            }
                            break;
                        default:
                            // no action for other parameter
                            break;
                    }
                }
            }
        }
开发者ID:AMEE,项目名称:revit,代码行数:42,代码来源:RoomScheduleForm.cs

示例4: SetExternalRoomIdToRoomId

 /// <summary>
 /// Set shared parameter (whose name is "External Room ID") value to Room.Id.IntegerValue
 /// </summary>
 /// <param name="room">The room used to get the room which to be updated</param>
 private static bool SetExternalRoomIdToRoomId(Room room)
 {
     try
     {
         Parameter shareParam = room.get_Parameter(RoomsData.SharedParam);
         if (null != shareParam)
         {
             return shareParam.Set(room.Id.IntegerValue.ToString());
         }
     }
     catch
     {
         // none
     }
     return false;
 }
开发者ID:AMEE,项目名称:revit,代码行数:20,代码来源:EventsReactor.cs

示例5: GetProperty

        /// <summary>
        /// get the room property and Department property according the property name
        /// </summary>
        /// <param name="room">a instance of room class</param>
        /// <param name="paraEnum">the property name</param>
        public String GetProperty(Room room, BuiltInParameter paraEnum)
        {
            String propertyValue = null;  //the value of parameter

            // get the parameter via the parameterId
            Parameter param = room.get_Parameter(paraEnum);
            if (null == param)
            {
                return "";
            }
            // get the parameter's storage type
            StorageType storageType = param.StorageType;
            switch (storageType)
            {
                case StorageType.Integer:
                    int iVal = param.AsInteger();
                    propertyValue = iVal.ToString();
                    break;
                case StorageType.String:
                    String stringVal = param.AsString();
                    propertyValue = stringVal;
                    break;
                case StorageType.Double:
                    Double dVal = param.AsDouble();
                    dVal = Math.Round(dVal, 2);
                    propertyValue = dVal.ToString();
                    break;
                default:
                    break;
            }
            return propertyValue;
        }
开发者ID:AMEE,项目名称:revit,代码行数:37,代码来源:RoomsData.cs


注:本文中的Room.get_Parameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。