Revit.SDK.Samples.CreateComplexAreaRein.CS.AreaReinData.FillIn C# (CSharp) Method

FillIn() public method

set the parameters to given AreaReinforcement
public FillIn ( AreaReinforcement areaRein ) : void
areaRein AreaReinforcement
return void
        public virtual void FillIn(AreaReinforcement areaRein)
        {
            int temp = (int)m_layoutRule;
            bool flag = ParameterUtil.SetParaInt(areaRein,
                BuiltInParameter.REBAR_SYSTEM_LAYOUT_RULE, temp);
            //if BuiltInParameter doesn't work
            if(!flag)
            {
                Parameter paraLayout = ParameterUtil.FindParaByName(
                    areaRein.Parameters, "Layout Rule");
                if (null != paraLayout)
                {
                    paraLayout.Set(temp);
                }
            }
            ChangeAreaReinCurves(areaRein);
        }

Usage Example

        ///<summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application
        /// which contains data related to the command,
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application
        /// which will be displayed if a failure or cancellation is returned by
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command.
        /// A result of Succeeded means that the API external method functioned as expected.
        /// Cancelled can be used to signify that the user cancelled the external operation
        /// at some point. Failure should be returned if the application is unable to proceed with
        /// the operation.</returns>
        public Autodesk.Revit.UI.Result Execute(ExternalCommandData revit,
                                                ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            Transaction trans = new Transaction(revit.Application.ActiveUIDocument.Document, "Revit.SDK.Samples.CreateComplexAreaRein");

            trans.Start();
            //initialize members
            m_revit      = revit;
            m_currentDoc = revit.Application.ActiveUIDocument;
            m_data       = new AreaReinData(revit.Application.ActiveUIDocument.Document);

            try
            {
                //check precondition and prepare necessary data to create AreaReinforcement.
                Reference     refer  = null;
                IList <Curve> curves = new List <Curve>();
                Floor         floor  = InitFloor(ref refer, ref curves);

                //ask for user's input
                AreaReinData dataOnFloor             = new AreaReinData(revit.Application.ActiveUIDocument.Document);
                CreateComplexAreaReinForm createForm = new
                                                       CreateComplexAreaReinForm(dataOnFloor);
                if (createForm.ShowDialog() == DialogResult.OK)
                {
                    //define the Major Direction of AreaReinforcement,
                    //we get direction of first Line on the Floor as the Major Direction
                    Line firstLine = (Line)(curves[0]);
                    Autodesk.Revit.DB.XYZ majorDirection = new Autodesk.Revit.DB.XYZ(
                        firstLine.GetEndPoint(1).X - firstLine.GetEndPoint(0).X,
                        firstLine.GetEndPoint(1).Y - firstLine.GetEndPoint(0).Y,
                        firstLine.GetEndPoint(1).Z - firstLine.GetEndPoint(0).Z);

                    //create AreaReinforcement by AreaReinforcement.Create() function
                    DocCreator        creator = m_revit.Application.ActiveUIDocument.Document.Create;
                    ElementId         areaReinforcementTypeId = AreaReinforcementType.CreateDefaultAreaReinforcementType(revit.Application.ActiveUIDocument.Document);
                    ElementId         rebarBarTypeId          = RebarBarType.CreateDefaultRebarBarType(revit.Application.ActiveUIDocument.Document);
                    ElementId         rebarHookTypeId         = RebarHookType.CreateDefaultRebarHookType(revit.Application.ActiveUIDocument.Document);
                    AreaReinforcement areaRein = AreaReinforcement.Create(revit.Application.ActiveUIDocument.Document, floor, curves, majorDirection, areaReinforcementTypeId, rebarBarTypeId, rebarHookTypeId);

                    //set AreaReinforcement and it's AreaReinforcementCurves parameters
                    dataOnFloor.FillIn(areaRein);
                    trans.Commit();
                    return(Autodesk.Revit.UI.Result.Succeeded);
                }
            }
            catch (ApplicationException appEx)
            {
                message = appEx.Message;
                trans.RollBack();
                return(Autodesk.Revit.UI.Result.Failed);
            }
            catch
            {
                message = "Unknow Errors.";
                trans.RollBack();
                return(Autodesk.Revit.UI.Result.Failed);
            }
            trans.RollBack();
            return(Autodesk.Revit.UI.Result.Cancelled);
        }
All Usage Examples Of Revit.SDK.Samples.CreateComplexAreaRein.CS.AreaReinData::FillIn