示例#1
0
        /// <summary>
        /// get a datatable contains parameters'information of SpotDimension
        /// here, almost only get Type Parameters of SpotDimension
        /// </summary>
        /// <param name="spotDimension">the SpotDimension need to be dealt with</param>
        /// <returns>a DataTable store Parameter information</returns>
        public DataTable GetParameterTable(Autodesk.Revit.DB.SpotDimension spotDimension)
        {
            try
            {
                //check whether is null
                if (null == spotDimension)
                {
                    return(null);
                }

                //create an empty datatable
                DataTable parameterTable = CreateTable();

                //get DimensionType
                Autodesk.Revit.DB.DimensionType dimensionType = spotDimension.DimensionType;

                //begin to get Parameters and add them to a DataTable
                Parameter temporaryParam = null;
                string    temporaryValue = "";

                #region Get all SpotDimension element parameters

                //string formatter
                string formatter = "#0.000";

                //Property Category of SpotDimension
                AddDataRow("Category", spotDimension.Category.Name, parameterTable);

                //Leader Arrowhead
                temporaryParam =
                    dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_LEADER_ARROWHEAD);
                Autodesk.Revit.DB.ElementId elementId = temporaryParam.AsElementId();
                //if not found that element, add string "None" to DataTable
                if (-1 == elementId.IntegerValue)
                {
                    temporaryValue = "None";
                }
                else
                {
                    temporaryValue = m_document.GetElement(elementId).Name;
                }
                AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                //Leader Line Weight
                temporaryParam = dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_LINE_PEN);
                temporaryValue = temporaryParam.AsInteger().ToString();
                AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                //Leader Arrowhead Line Weight
                temporaryParam =
                    dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_TICK_MARK_PEN);
                temporaryValue = temporaryParam.AsInteger().ToString();
                AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                //Symbol
                temporaryParam = dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_SYMBOL);
                elementId      = temporaryParam.AsElementId();
                //if not found that element, add string "None" to DataTable
                if (-1 == elementId.IntegerValue)
                {
                    temporaryValue = "None";
                }
                else
                {
                    temporaryValue = m_document.GetElement(elementId).Name;
                }
                AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                //Text Size
                temporaryParam = dimensionType.get_Parameter(BuiltInParameter.TEXT_SIZE);
                temporaryValue =
                    (temporaryParam.AsDouble() / ToFractionalInches).ToString(formatter) + "''";
                AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                //Text Offset from Leader
                temporaryParam =
                    dimensionType.get_Parameter(BuiltInParameter.SPOT_TEXT_FROM_LEADER);
                temporaryValue =
                    (temporaryParam.AsDouble() / ToFractionalInches).ToString(formatter) + "''";
                AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                //Text Offset from Symbol
                temporaryParam =
                    dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_TEXT_HORIZ_OFFSET);
                temporaryValue =
                    (temporaryParam.AsDouble() / ToFractionalInches).ToString(formatter) + "''";
                AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                //for Spot Coordinates, add some other Parameters
                if ("Spot Coordinates" == spotDimension.Category.Name)
                {
                    //Coordinate Origin
                    temporaryParam =
                        dimensionType.get_Parameter(BuiltInParameter.SPOT_COORDINATE_BASE);
                    temporaryValue = temporaryParam.AsInteger().ToString();
                    AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                    //Top Value
                    temporaryParam =
                        dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_TOP_VALUE);
                    temporaryValue = s_topBottomValue[temporaryParam.AsInteger()];
                    AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                    //Bottom Value
                    temporaryParam =
                        dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_BOT_VALUE);
                    temporaryValue = s_topBottomValue[temporaryParam.AsInteger()];
                    AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                    //North / South s_indicator
                    temporaryParam =
                        dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_IND_NS);
                    temporaryValue = temporaryParam.AsString();
                    AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                    //East / West s_indicator
                    temporaryParam =
                        dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_IND_EW);
                    temporaryValue = temporaryParam.AsString();
                    AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
                }
                //for Spot Elevation, add some other Parameters
                else
                {
                    //Instance Parameter----Value
                    temporaryParam =
                        spotDimension.get_Parameter(BuiltInParameter.DIM_VALUE_LENGTH);
                    temporaryValue = temporaryParam.AsDouble().ToString(formatter) + "'";
                    AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                    //Elevation Origin
                    temporaryParam = dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_BASE);
                    temporaryValue = s_elevationOrigin[temporaryParam.AsInteger()];
                    AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                    //Elevation s_indicator
                    temporaryParam =
                        dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_IND_ELEVATION);
                    temporaryValue = temporaryParam.AsString();
                    AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
                }

                //Text Orientation
                temporaryParam =
                    dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_TEXT_ORIENTATION);
                temporaryValue = s_textOrientation[temporaryParam.AsInteger()];
                AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                //s_indicator as Prefix / Suffix
                temporaryParam = dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_IND_TYPE);
                temporaryValue = s_indicator[temporaryParam.AsInteger()];
                AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                //Text Font
                temporaryParam = dimensionType.get_Parameter(BuiltInParameter.TEXT_FONT);
                temporaryValue = temporaryParam.AsString();
                AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                //Text Background
                temporaryParam = dimensionType.get_Parameter(BuiltInParameter.DIM_TEXT_BACKGROUND);
                temporaryValue = s_textBackground[temporaryParam.AsInteger()];
                AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);

                #endregion
                return(parameterTable);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message, "A error in Function 'GetParameterTable':");
                return(null);
            }
        }
示例#2
0
 public static DimensionType Wrap(Autodesk.Revit.DB.DimensionType ele, bool isRevitOwned)
 {
     return(DimensionType.FromExisting(ele, isRevitOwned));
 }