本文整理汇总了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;
}
示例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()));
}
示例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));
}
}
示例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());
}
}
示例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;
}
示例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
{
//.........这里部分代码省略.........
示例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());
}
}
示例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());
}
}
示例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;
}
}
}