本文整理汇总了C#中Parameter.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Parameter.Set方法的具体用法?C# Parameter.Set怎么用?C# Parameter.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parameter
的用法示例。
在下文中一共展示了Parameter.Set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetParaNullId
/// <summary>
/// set certain parameter of given element to int value
/// </summary>
/// <param name="elem">given element</param>
/// <param name="paraIndex">BuiltInParameter</param>
/// <param name="value"></param>
/// <returns></returns>
public static bool SetParaNullId(Parameter para)
{
Autodesk.Revit.DB.ElementId id = new ElementId(-1);
if (!para.IsReadOnly)
{
para.Set(id);
return true;
}
return false;
}
示例2: _setParam
private static FScheme.Value _setParam(FamilySymbol ft, Parameter p, FScheme.Value valueExpr)
{
if (p.StorageType == StorageType.Double)
{
p.Set(((FScheme.Value.Number)valueExpr).Item);
}
else if (p.StorageType == StorageType.Integer)
{
p.Set((int)((FScheme.Value.Number)valueExpr).Item);
}
else if (p.StorageType == StorageType.String)
{
p.Set(((FScheme.Value.String)valueExpr).Item);
}
else if (valueExpr.IsNumber)
{
p.Set(new ElementId((int)(valueExpr as FScheme.Value.Number).Item));
}
else
{
p.Set((ElementId)((FScheme.Value.Container)valueExpr).Item);
}
return FScheme.Value.NewContainer(ft);
}
示例3: _setParam
private static Value _setParam(Element ft, Parameter p, Value valueExpr)
{
if (p.StorageType == StorageType.Double)
{
p.Set(((Value.Number) valueExpr).Item);
}
else if (p.StorageType == StorageType.Integer)
{
p.Set((int) ((Value.Number) valueExpr).Item);
}
else if (p.StorageType == StorageType.String)
{
p.Set(((Value.String) valueExpr).Item);
}
else if (p.StorageType == StorageType.ElementId)
{
p.Set((ElementId) ((Value.Container) valueExpr).Item);
}
else if (valueExpr.IsNumber)
{
p.Set(new ElementId((int) (valueExpr as Value.Number).Item));
}
else
{
p.Set((ElementId) ((Value.Container) valueExpr).Item);
}
return Value.NewContainer(ft);
}
示例4: 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
{
//.........这里部分代码省略.........
示例5: SetParameterValue
/// <summary>
/// set parameter's value
/// </summary>
/// <param name="parameter">parameter of a Material</param>
/// <param name="value">
/// value will be set to parameter
/// </param>
public static void SetParameterValue(Parameter parameter, Object value)
{
//first,check whether this parameter is read only
if(parameter.IsReadOnly)
{
return;
}
switch (parameter.StorageType)
{
case StorageType.Double:
//set value with unit, Set() can set value without unit
parameter.SetValueString(value as string);
break;
case StorageType.ElementId:
Autodesk.Revit.DB.ElementId elementId = (Autodesk.Revit.DB.ElementId)(value);
parameter.Set(elementId);
break;
case StorageType.Integer:
//set value with unit, Set() can set value without unit
parameter.SetValueString(value as string);
break;
case StorageType.None:
parameter.SetValueString(value as string);
break;
case StorageType.String:
parameter.Set(value as string);
break;
default:
break;
}
}
示例6: _setParam
private static Expression _setParam(FamilyInstance ft, Parameter p, Expression valueExpr)
{
if (p.StorageType == StorageType.Double)
{
p.Set(((Expression.Number)valueExpr).Item);
}
else if (p.StorageType == StorageType.Integer)
{
p.Set((int)((Expression.Number)valueExpr).Item);
}
else if (p.StorageType == StorageType.String)
{
p.Set(((Expression.String)valueExpr).Item);
}
else if (valueExpr.IsNumber)
{
p.Set(new ElementId((int)(valueExpr as Expression.Number).Item));
}
else
{
p.Set((ElementId)((Expression.Container)valueExpr).Item);
}
return Expression.NewContainer(ft);
}