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


C# Parameter.AsValueString方法代码示例

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


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

示例1: ElementIdParameterAsString

        /// <summary>
        /// Returns a string value corresponding to an ElementId Parameter.
        /// </summary>
        /// <param name="parameter">The parameter.</param>
        /// <returns>The string.</returns>
        public static string ElementIdParameterAsString(Parameter parameter)
        {
            ElementId value = parameter.AsElementId();
            if (value == ElementId.InvalidElementId)
                return null;

            string valueString = null;
            // All real elements in Revit have non-negative ids.
            if (value.IntegerValue >= 0)
            {
                // Get the family and element name.
                Element paramElement = ExporterCacheManager.Document.GetElement(value);
                valueString = (paramElement != null) ? paramElement.Name : null;
                if (!string.IsNullOrEmpty(valueString))
                {
                    ElementType paramElementType = paramElement is ElementType ? paramElement as ElementType :
                        ExporterCacheManager.Document.GetElement(paramElement.GetTypeId()) as ElementType;
                    string paramElementTypeName = (paramElementType != null) ? ExporterIFCUtils.GetFamilyName(paramElementType) : null;
                    if (!string.IsNullOrEmpty(paramElementTypeName))
                        valueString = paramElementTypeName + ": " + valueString;
                }
            }
            else 
            {
                valueString = parameter.AsValueString();
            }

            if (string.IsNullOrEmpty(valueString))
                valueString = value.ToString();

            return valueString;
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:37,代码来源:PropertyUtil.cs

示例2: Stream

        private void Stream(ArrayList data, Parameter param)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(Parameter)));

            data.Add(new Snoop.Data.Object("Definition", param.Definition));

            try {   // this only works for certain types of Parameters
                data.Add(new Snoop.Data.String("Display unit type", param.DisplayUnitType.ToString()));
            }
            catch (System.Exception) {
                data.Add(new Snoop.Data.String("Display unit type", "N/A"));
            }
            try
            {   // this only works for certain types of Parameters
              data.Add(new Snoop.Data.Object("Element", param.Element));
            }
            catch (System.Exception ex)
            {
              data.Add(new Snoop.Data.Exception("Element", ex));
            }
            try
            {   // this only works for certain types of Parameters
              data.Add(new Snoop.Data.String("GUID", param.GUID.ToString()));
            }
            catch (System.Exception ex)
            {
              data.Add(new Snoop.Data.Exception("GUID", ex));
            }
            try
            {   // this only works for certain types of Parameters
              data.Add(new Snoop.Data.Bool("HasValue", param.HasValue));
            }
            catch (System.Exception ex)
            {
              data.Add(new Snoop.Data.Exception("HasValue", ex));
            }
            try
            {   // this only works for certain types of Parameters
              data.Add(new Snoop.Data.ElementId("ID", param.Id,m_activeDoc));
            }
            catch (System.Exception ex)
            {
              data.Add(new Snoop.Data.Exception("ID", ex));
            }
            try
            {   // this only works for certain types of Parameters
              data.Add(new Snoop.Data.Bool("IsShared", param.IsShared));
            }
            catch (System.Exception ex)
            {
              data.Add(new Snoop.Data.Exception("IsShared", ex));
            }

            data.Add(new Snoop.Data.String("Storage type", param.StorageType.ToString()));

            if (param.StorageType == StorageType.Double)
                data.Add(new Snoop.Data.Double("Value", param.AsDouble()));
            else if (param.StorageType == StorageType.ElementId)
                data.Add(new Snoop.Data.ElementId("Value", param.AsElementId(), m_app.ActiveUIDocument.Document));
            else if (param.StorageType == StorageType.Integer)
                data.Add(new Snoop.Data.Int("Value", param.AsInteger()));
            else if (param.StorageType == StorageType.String)
                data.Add(new Snoop.Data.String("Value", param.AsString()));

            data.Add(new Snoop.Data.String("As value string", param.AsValueString()));
        }
开发者ID:halad,项目名称:RevitLookup,代码行数:66,代码来源:CollectorExtParams.cs

示例3: Execute

        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            #region TEST_1
            #if TEST_1
              //
              // you cannot create your own parameter, because the
              // constuctor is for internal use only. This is due
              // to the fact that a parameter cannot live on its own,
              // it is linked to a definition and needs to be hooked
              // up properly in the Revit database system to work
              // ... case 1245614 [Formatting units strings]:
              //
              bool iReallyWantToCrash = false;
              if( iReallyWantToCrash )
              {
            Parameter p = new Parameter();
            p.Set( 1.0 );
            string s = p.AsDouble().ToString();
            string t = p.AsValueString();
            Debug.WriteLine( "Value " + s );
            Debug.WriteLine( "Value string " + t );
              }
            #endif // TEST
              #endregion // TEST_1

              UIDocument uidoc = commandData.Application.ActiveUIDocument;
              Document doc = uidoc.Document;

              // Loop through all pre-selected elements:

              foreach( ElementId id in uidoc.Selection.GetElementIds() )
              {
            Element e = doc.GetElement( id );

            string s = string.Empty;

            // set this variable to false to analyse the element's own parameters,
            // i.e. instance parameters for a family instance, and set it to true
            // to analyse a family instance's type parameters:

            bool analyseTypeParameters = false;

            if( analyseTypeParameters )
            {
              if( e is FamilyInstance )
              {
            FamilyInstance inst = e as FamilyInstance;
            if( null != inst.Symbol )
            {
              e = inst.Symbol;
              s = " type";
            }
              }
              else if( e is Wall )
              {
            Wall wall = e as Wall;
            if( null != wall.WallType )
            {
              e = wall.WallType;
              s = " type";
            }
              }
              // ... add support for other types if desired ...
            }

            // Loop through and list all UI-visible element parameters

            List<string> a = new List<string>();

            #region 4.1.a Iterate over element parameters and retrieve their name, type and value:

            foreach( Parameter p in e.Parameters )
            {
              string name = p.Definition.Name;
              string type = p.StorageType.ToString();
              string value = LabUtils.GetParameterValue2( p, uidoc.Document );
              //bool read_only = p.Definition.IsReadOnly; // 2013
              bool read_only = p.IsReadOnly; // 2014
              a.Add( string.Format(
            "Name={0}; Type={1}; Value={2}; ValueString={3}; read-{4}",
            name, type, value, p.AsValueString(),
            ( read_only ? "only" : "write" ) ) );
            }

            #endregion // 4.1.a

            string what = e.Category.Name
              + " (" + e.Id.IntegerValue.ToString() + ")";

            LabUtils.InfoMsg( what + " has {0} parameter{1}{2}", a );

            // If we know which param we are looking for, then:
            // A) If a standard parameter, we can get it via BuiltInParam
            // signature of Parameter method:

            try
            {
//.........这里部分代码省略.........
开发者ID:jeremytammik,项目名称:AdnRevitApiLabsXtra,代码行数:101,代码来源:Labs4.cs

示例4: GetParameterInformation

        /// <summary>
        /// Extract the parameter information.
        /// By Dan Tartaglia.
        /// </summary>
        public string GetParameterInformation(
            Parameter para,
            Document doc)
        {
            string defName = "";

              // Use different method to get parameter
              // data according to the storage type

              switch( para.StorageType )
              {
            // Determine the parameter type

            case StorageType.Double:

              // Convert the number into Metric

              defName = para.AsValueString();
              break;

            case StorageType.ElementId:

              // Find out the name of the element

              Autodesk.Revit.DB.ElementId id
            = para.AsElementId();

              defName = ( id.IntegerValue >= 0 )
            ? doc.GetElement( id ).Name
            : id.IntegerValue.ToString();

              break;

            case StorageType.Integer:
              if( ParameterType.YesNo
            == para.Definition.ParameterType )
              {
            if( para.AsInteger() == 0 )
            {
              defName = "False";
            }
            else
            {
              defName = "True";
            }
              }
              else
              {
            defName = para.AsInteger().ToString();
              }
              break;

            case StorageType.String:
              defName = para.AsString();
              break;

            default:
              defName = "Unexposed parameter";
              break;
              }
              return defName;
        }
开发者ID:jeremytammik,项目名称:GetRevisionData,代码行数:66,代码来源:Command.cs

示例5: GetParameterValue

 // jeremy
 //public static Object GetParameterValue(Parameter parameter) // jeremy
 /// <summary>
 /// get parameter's value
 /// </summary>
 /// <param name="parameter">parameter of Element</param>
 /// <returns>parameter's value include unit if have</returns>
 public static string GetParameterValue(Parameter parameter)
 {
     switch (parameter.StorageType)
     {
         case StorageType.Double:
             //get value with unit, AsDouble() can get value without unit
             return parameter.AsValueString();
         case StorageType.ElementId:
             return parameter.AsElementId().IntegerValue.ToString();
         case StorageType.Integer:
             //get value with unit, AsInteger() can get value without unit
             return parameter.AsValueString();
         case StorageType.None:
             return parameter.AsValueString();
         case StorageType.String:
             return parameter.AsString();
         default:
             return "";
     }
 }
开发者ID:AMEE,项目名称:revit,代码行数:27,代码来源:Para.cs


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