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


C# Parameter.AsDouble方法代码示例

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


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

示例1: GetParameterValue

        /// <summary>
        /// Helper to return parameter value as string.
        /// One can also use param.AsValueString() to
        /// get the user interface representation.
        /// </summary>
        public static string GetParameterValue( Parameter param )
        {
            string s;
              switch( param.StorageType )
              {
            case StorageType.Double:
              //
              // the internal database unit for all lengths is feet.
              // for instance, if a given room perimeter is returned as
              // 102.36 as a double and the display unit is millimeters,
              // then the length will be displayed as
              // peri = 102.36220472440
              // peri * 12 * 25.4
              // 31200 mm
              //
              //s = param.AsValueString(); // value seen by user, in display units
              //s = param.AsDouble().ToString(); // if not using not using LabUtils.RealString()
              s = RealString( param.AsDouble() ); // raw database value in internal units, e.g. feet
              break;

            case StorageType.Integer:
              s = param.AsInteger().ToString();
              break;

            case StorageType.String:
              s = param.AsString();
              break;

            case StorageType.ElementId:
              s = param.AsElementId().IntegerValue.ToString();
              break;

            case StorageType.None:
              s = "?NONE?";
              break;

            default:
              s = "?ELSE?";
              break;
              }
              return s;
        }
开发者ID:jeremytammik,项目名称:AdnRevitApiLabsXtra,代码行数:47,代码来源:LabUtils.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: _getParam

 private static Value _getParam(Parameter p)
 {
     switch (p.StorageType)
     {
         case StorageType.ElementId:
             return Value.NewContainer(p.AsElementId());
         case StorageType.String:
             return Value.NewString(p.AsString());
         case StorageType.Integer:
         case StorageType.Double:
             switch (p.Definition.ParameterType)
         {
             case ParameterType.Length:
                 return Value.NewContainer(Units.Length.FromFeet(p.AsDouble(), dynSettings.Controller.UnitsManager));
             case ParameterType.Area:
                 return Value.NewContainer(Units.Area.FromSquareFeet(p.AsDouble(), dynSettings.Controller.UnitsManager));
             case ParameterType.Volume:
                 return Value.NewContainer(Units.Volume.FromCubicFeet(p.AsDouble(), dynSettings.Controller.UnitsManager));
             default:
                 return Value.NewNumber(p.AsDouble());
         }
         default:
             throw new Exception(string.Format("Parameter {0} has no storage type.", p));
     }
 }
开发者ID:parchjs,项目名称:Dynamo,代码行数:25,代码来源:FamilyInstance.cs

示例4: _getParam

 private static FScheme.Value _getParam(FamilySymbol fi, Parameter p)
 {
     if (p.StorageType == StorageType.Double)
     {
         return FScheme.Value.NewNumber(p.AsDouble());
     }
     else if (p.StorageType == StorageType.Integer)
     {
         return FScheme.Value.NewNumber(p.AsInteger());
     }
     else if (p.StorageType == StorageType.String)
     {
         return FScheme.Value.NewString(p.AsString());
     }
     else
     {
         return FScheme.Value.NewContainer(p.AsElementId());
     }
 }
开发者ID:kscalvin,项目名称:Dynamo,代码行数:19,代码来源:FamilyType.cs

示例5: ParameterToString

    /// <summary>
    /// Helper function: return a string form of a given parameter.
    /// </summary>
    public static string ParameterToString(Parameter param)
    {
      string val = "none";

      if (param == null)
      {
        return val;
      }

      // To get to the parameter value, we need to pause it depending on its storage type 

      switch (param.StorageType)
      {
        case StorageType.Double:
          double dVal = param.AsDouble();
          val = dVal.ToString();
          break;
        case StorageType.Integer:
          int iVal = param.AsInteger();
          val = iVal.ToString();
          break;
        case StorageType.String:
          string sVal = param.AsString();
          val = sVal;
          break;
        case StorageType.ElementId:
          ElementId idVal = param.AsElementId();
          val = idVal.IntegerValue.ToString();
          break;
        case StorageType.None:
          break;
      }
      return val;
    }
开发者ID:FlintSable,项目名称:RevitTrainingMaterial,代码行数:37,代码来源:2_DbElement.cs

示例6: 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

示例7: _getParam

 private static Expression _getParam(FamilyInstance fi, Parameter p)
 {
     if (p.StorageType == StorageType.Double)
     {
         return Expression.NewNumber(p.AsDouble());
     }
     else if (p.StorageType == StorageType.Integer)
     {
         return Expression.NewNumber(p.AsInteger());
     }
     else if (p.StorageType == StorageType.String)
     {
         return Expression.NewString(p.AsString());
     }
     else
     {
         return Expression.NewContainer(p.AsElementId());
     }
 }
开发者ID:Dewb,项目名称:Dynamo,代码行数:19,代码来源:dynFamilies.cs

示例8: _getParam

 private static Value _getParam(FamilyInstance fi, Parameter p)
 {
     if (p.StorageType == StorageType.Double)
     {
         switch (p.Definition.ParameterType)
         {
             case ParameterType.Length:
                 return Value.NewContainer(Units.Length.FromFeet(p.AsDouble()));
                 break;
             case ParameterType.Area:
                 return Value.NewContainer(Units.Area.FromSquareFeet(p.AsDouble()));
                 break;
             case ParameterType.Volume:
                 return Value.NewContainer(Units.Volume.FromCubicFeet(p.AsDouble()));
                 break;
             default:
                 return Value.NewNumber(p.AsDouble());
                 break;
         }
     }
     else if (p.StorageType == StorageType.Integer)
     {
         return Value.NewNumber(p.AsInteger());
     }
     else if (p.StorageType == StorageType.String)
     {
         return Value.NewString(p.AsString());
     }
     else
     {
         return Value.NewContainer(p.AsElementId());
     }
 }
开发者ID:Zhengzi,项目名称:Dynamo,代码行数:33,代码来源:FamilyInstance.cs

示例9: writeValueByStorageType

 private void writeValueByStorageType(Parameter p, TextWriter writer, Document doc)
 {
     if (null != p)
     {
         switch (p.StorageType)
         {
             case StorageType.Double:
                 {
                     writer.Write(p.AsDouble());
                     break;
                 }
             case StorageType.Integer:
                 {
                     writer.Write(p.AsInteger());
                     break;
                 }
             case StorageType.String:
                 {
                     writer.Write(p.AsString());
                     break;
                 }
             case StorageType.ElementId:
                 {
                     Element elem = doc.get_Element(p.AsElementId());
                     if (null == elem)
                         writer.Write("NULL ELEMENT FOUND");
                     else
                         writer.Write(elem.Name);
                     break;
                 }
             default:
                 writer.Write("N/A");
                 break;
         }
     }
 }
开发者ID:jrivera777,项目名称:RevitLibrary,代码行数:36,代码来源:ReadElements.cs


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