Offset textbox validations in view range

Offset textbox validations in view range

Anonymous
Not applicable
717 Views
1 Reply
Message 1 of 2

Offset textbox validations in view range

Anonymous
Not applicable

I wander is there a function which validates the offset value in view range window?
I want to create my custom view range properties window, and I have created some custom validations for the offset textbox.
But when the user changes Project Unit, my validations become incorrect.
Any ideas?


                      Untitled.png

0 Likes
Accepted solutions (1)
718 Views
1 Reply
Reply (1)
Message 2 of 2

RPTHOMAS108
Mentor
Mentor
Accepted solution

My understanding of your query is as follows:

 

User can input any unit string regardless of project settings (metric/imperial) to get a value related to current project settings and you'd like to be able to parse that and either convert it to your desired units for checking top is greater than bottom etc. or to internal units for setting parameters.

 

If that is the case then on the UnitFormatUtils class there is a method TryParse which will try and interpret the input string (works exactly the same as Double.TryParse etc.). Example code taken from RevitAPI.chm file is below:

 

double GetLengthInput(Document document, String userInputLength)
{
    double dParsedLength = 0;
    Units units = document.GetUnits();
    // try to parse a user entered string (i.e. 100 mm, 1'6")
    bool parsed = UnitFormatUtils.TryParse(units, UnitType.UT_Length, userInputLength, out dParsedLength);
    if (parsed == true)
    {
        string msg = string.Format("User Input: {0}\r\nParsed value: {1}", userInputLength, dParsedLength);
        TaskDialog.Show("Parsed Data", msg);
    }

    return dParsedLength;
}