Parameter of Revit Api–19:add familyparameter (familymanager.addparameter)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.