Beispiel #1
0
        /// <summary>
        /// Returns a random value +/- 25% around a target value
        /// </summary>
        /// <param name="item">The FamilyParameterValue to target</param>
        /// <returns></returns>
        internal static double GetRandomItemValue(FamilyParameterModel item)
        {
            SingleRandom random = SingleRandom.Instance;

            double value       = item.RevitValue + 0.01; //TO DO - Needs CHanging
            double plus        = (value + 0.25 * value); // plus minus values - around the current value +-25%
            double minus       = (value - 0.25 * value);
            double randomValue = random.NextDouble() * (plus - minus) + minus;

            //if (randomValue == 0) randomValue = random.NextDouble() * 10;
            if (randomValue > 10)
            {
                randomValue = Math.Round(randomValue);                      //Round the value if it is not a single digit (inches and feet can be singe digit)
            }
            return(randomValue);
        }
        //Create a checkbox FamilyParameterModel item
        internal static FamilyParameterModel FamilyParameterItem(FamilyType ft, FamilyParameter fp, List <FamilyParameter> paramLabel, List <FamilyParameter> paramFormula)
        {
            //Collect data depending on the type of paramter
            FamilyParameterModel newItem = new FamilyParameterModel(); //Create new FamilyParamterModel

            newItem.SuppressUpdate();                                  //When setting the first time, suppress the back-update coming from the UI because of difference in precision
            newItem.Name            = fp.Definition.Name;              //The name of the Parameter
            newItem.StorageType     = fp.StorageType;
            newItem.ParamType       = GetParameterType(fp);
            newItem.DisplayUnitType = GetDisplayUnitType(fp);                      //Set the DisplayUnitType for this parameter
            newItem.Precision       = Utils.GetPrecision(newItem.DisplayUnitType); //Properties.Settings.Default.Precision;  //The precision set by the User in the Settings
            newItem.Type            = fp.Definition.ParameterType.ToString();      //The parameter type
            newItem.Associated      = !fp.AssociatedParameters.IsEmpty;            //If the parameter is being associated
            newItem.BuiltIn         = fp.Id.IntegerValue < 0;
            newItem.Modifiable      = fp.UserModifiable;
            newItem.Formula         = fp.IsDeterminedByFormula;
            newItem.Label           = paramLabel.Any(f => f.Id == fp.Id);
            newItem.Reporting       = fp.IsReporting;
            newItem.UsedInFormula   = paramFormula.Any(f => f.Id == fp.Id);
            newItem.ReadOnly        = fp.IsReadOnly;
            newItem.Shared          = fp.IsShared;
            newItem.TypeOrInstance  = fp.IsInstance ? "Instance" : "Type";
            newItem.IsUsed          = (newItem.Associated || newItem.Label || newItem.UsedInFormula); //Used if any of the three is true
            newItem.Editable        = newItem.IsUsed && !newItem.Formula && !newItem.Reporting;       //If the Parameter is used or if the parameter is not defined by Formula, allow the user to edit
            newItem.Visible         = Properties.Settings.Default.ToggleVisibility;                   //Set the visibility in the UI (user defined Tag property for ALL Tags, regardless of their specific conditions)
            newItem.TagVisible      = Properties.Settings.Default.ToggleTagsVisibility;               //Set the Tags visibility

            newItem.RevitValue = GetParameterValue(ft, fp);                                           //Set the Revit internal value for the Parameter

            if (newItem.RevitValue == 0.0)
            {
                newItem.Value   = Utils.GetDutValueTo(newItem.StorageType, newItem.DisplayUnitType, newItem.RevitValue);                //The unit specific value in double
                newItem.UIValue = ValueConvertUtils.StringFromDoubleConvert(newItem.DisplayUnitType, newItem.Precision, newItem.Value); //The string representation of the value
            }

            return(newItem);
        }
        //Returns a single FamilyParameterModel
        internal static FamilyParameterModel GetFamilyParameterModel(FamilyType ft, FamilyParameter fp, List <FamilyParameter> paramLabel, List <FamilyParameter> paramFormula)
        {
            FamilyParameterModel fpmodel = FamilyParameterItem(ft, fp, paramLabel, paramFormula);

            return(fpmodel);
        }
Beispiel #4
0
 /// <summary>
 /// Returns the opposite value for a boolean
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 internal static double GetRandomBooleanValue(FamilyParameterModel item)
 {
     return(item.RevitValue == 1 ? 0 : 1);
 }