New family Parameters (Familyparameter) can be added to a family document through the Familymanager.addparameter () method. It has three different signatures and the most popular one accepts parameters of the parameter name, parameter group (Bui ltinparametergroup), Parameter type ParameterType () and a flag to indicate if the familyparameter applies to instance or Type.
The familyparameter can also is associated with a Dimension through it Label property when necessary.
The following method can create a familyparameter, set its value, and associate it with a Dimension:
public static void Rawaddfamilyparamterandsetvalue (Dimension Dim, Familymanager Famman, familytype ft, string n Ame, Builtinparametergroup Group, parametertype type, bool Isinstance, object value) {Familyparameter F p = famman.addparameter (name, group, type, isinstance); if (value!= null) rawsetfamilyparametervalue (Famman, FT, FP, value); if (value! = null) FP. SetValue (Famman, FT, value); if (Dim! = null) Dim. Label = FP; public static void Rawsetfamilyparametervalue (Familymanager FM, familytype ft, familyparameter FP, object value) {Familytype CURFAMTYPE = FM. Currenttype; Fm. Currenttype = ft; try {switch (FP). Storagetype) {case StorageType.None:break; Case StorageType.Double:if (value. GetType (). Equals (typeof (String))) {FM. Set (FP, double. Parse (value as String)); } else {FM. Set (FP, convert.todouble (value)); } break; Case StorageType.Integer:if (value. GetType (). Equals (typeof (String))) {FM. Set (FP, Int. Parse (value as String)); } else {FM. Set (FP, Convert.ToInt32 (value)); } break; Case StorageType.ElementId:if (value. GetType (). Equals (typeof (ElementID))) {FM. Set (FP, value as ElementID); } else if (value. GetType (). Equals (typeof (String))) { Fm. Set (FP, new ElementID (int). Parse (value as String)); } else {FM. Set (FP, New ElementID (Convert.ToInt32 (value))); } break; Case STORAGETYPE.STRING:FM. Set (FP, value. ToString ()); Break }} catch {throw new Exception ("Invalid Value input!"); } finally {FM. Currenttype = Curfamtype; } }
The Help Method Rawsetfamilyparametervalue () has been introduced before. The Familyparameter Writer can generate it in no time. If necessary the extension method can be generated as well and being used in the method Rawaddfamilyparamterandsetvalue () INS Tead.
Familyparameter Creator of Revitaddinwizard can take care of all these.
Parameter of Revit Api–19:add familyparameter (familymanager.addparameter)