AsValueString() and SetValueString()

AsValueString() and SetValueString()

AsValueString() and SetValueString() are Parameter class methods. The two methods are only applied to value type parameters, which are double or integer parameters representing a measured quantity.

Use the AsValueString() method to get the parameter value as a string with the unit of measure. For example, the Base Offset value, a wall parameter, is a Double value. Usually the value is shown as a string like -20'0" in the Element Properties dialog box:

Figure 28: AsValueString and SetValueString sample

Using the AsValueString() method, you get the -20'0" string value directly. Otherwise you get a double value like -20 without the units of measure if you use the AsDouble() method.

Use the SetValueString() method to change the value of a value type parameter instead of using the Set() method. The following code sample illustrates how to change the parameter value using the SetValueString() method:

Code Region 8-5: Using Parameter.SetValueString()

public bool SetWithValueString(Parameter foundParameter)
{
        bool result = false;
        if (!foundParameter.IsReadOnly)
        {
                //If successful, the result is true
                        result = foundParameter.SetValueString("-22\'3\"");
        }
        return result;
}