simple business process of UI
Inheritance: System.Windows.Forms.Form
Example #1
0
        /// <summary>
        /// create simple AreaReinforcement on vertical straight rectangular wall
        /// </summary>
        /// <param name="wall"></param>
        /// <returns>is successful</returns>
        private bool CreateAreaReinOnWall(Wall wall)
        {
            //make sure selected is basic wall
            if (wall.WallType.Kind != WallKind.Basic)
            {
                TaskDialog.Show("Revit", "Selected wall is not a basic wall.");
                return(false);
            }

            GeomHelper    helper = new GeomHelper();
            Reference     refer  = null;
            IList <Curve> curves = new List <Curve>();

            //check whether wall is vertical rectangular and analytical model shape is line
            if (!helper.GetWallGeom(wall, ref refer, ref curves))
            {
                ApplicationException appEx = new ApplicationException(
                    "Your selection is not a structural straight rectangular wall.");
                throw appEx;
            }

            AreaReinDataOnWall       dataOnWall = new AreaReinDataOnWall();
            CreateSimpleAreaReinForm createForm = new
                                                  CreateSimpleAreaReinForm(dataOnWall);

            //allow use select parameters to create
            if (createForm.ShowDialog() == DialogResult.OK)
            {
                DocCreator creator = m_revit.Application.ActiveUIDocument.Document.Create;

                //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
                IList <Curve> curveList = new List <Curve>();
                foreach (Curve curve in curves)
                {
                    curveList.Add(curve);
                }
                ElementId         areaReinforcementTypeId = AreaReinforcementType.CreateDefaultAreaReinforcementType(m_revit.Application.ActiveUIDocument.Document);
                ElementId         rebarBarTypeId          = RebarBarType.CreateDefaultRebarBarType(m_revit.Application.ActiveUIDocument.Document);
                ElementId         rebarHookTypeId         = RebarHookType.CreateDefaultRebarHookType(m_revit.Application.ActiveUIDocument.Document);
                AreaReinforcement areaRein = AreaReinforcement.Create(m_revit.Application.ActiveUIDocument.Document, wall, curveList, majorDirection, areaReinforcementTypeId, rebarBarTypeId, rebarHookTypeId);
                dataOnWall.FillIn(areaRein);
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// create simple AreaReinforcement on vertical straight rectangular wall
        /// </summary>
        /// <param name="wall"></param>
        /// <returns>is successful</returns>
        private bool CreateAreaReinOnWall(Wall wall)
        {
            //make sure selected is basic wall
            if (wall.WallType.Kind != WallKind.Basic)
            {
                MessageBox.Show("Selected wall is not a basic wall.");
                return(false);
            }

            GeomHelper helper = new GeomHelper();
            Reference  refer  = null;
            CurveArray curves = null;

            //check whether wall is vertical rectangular and analytical model shape is line
            if (!helper.GetWallGeom(wall, ref refer, ref curves))
            {
                ApplicationException appEx = new ApplicationException(
                    "Your selection is not a structural straight rectangular wall.");
                throw appEx;
            }

            AreaReinDataOnWall       dataOnWall = new AreaReinDataOnWall();
            CreateSimpleAreaReinForm createForm = new
                                                  CreateSimpleAreaReinForm(dataOnWall);

            //allow use select parameters to create
            if (createForm.ShowDialog() == DialogResult.OK)
            {
                DocCreator creator = m_revit.Application.ActiveUIDocument.Document.Create;

                //define the Major Direction of AreaReinforcement,
                //we get direction of first Line on the Floor as the Major Direction
                Line firstLine = (Line)(curves.get_Item(0));
                Autodesk.Revit.DB.XYZ majorDirection = new Autodesk.Revit.DB.XYZ(
                    firstLine.get_EndPoint(1).X - firstLine.get_EndPoint(0).X,
                    firstLine.get_EndPoint(1).Y - firstLine.get_EndPoint(0).Y,
                    firstLine.get_EndPoint(1).Z - firstLine.get_EndPoint(0).Z);

                //create AreaReinforcement by NewAreaReinforcement function
                AreaReinforcement areaRein = creator.NewAreaReinforcement(wall, curves, majorDirection);
                dataOnWall.FillIn(areaRein);
                return(true);
            }
            return(false);
        }
Example #3
0
        /// <summary>
        /// create simple AreaReinforcement on horizontal floor
        /// </summary>
        /// <param name="floor"></param>
        /// <returns>is successful</returns>
        private bool CreateAreaReinOnFloor(Floor floor)
        {
            GeomHelper    helper = new GeomHelper();
            Reference     refer  = null;
            IList <Curve> curves = new List <Curve>();

            //check whether floor is horizontal rectangular
            //and prepare necessary to create AreaReinforcement
            if (!helper.GetFloorGeom(floor, ref refer, ref curves))
            {
                ApplicationException appEx = new ApplicationException(
                    "Your selection is not a horizontal rectangular slab.");
                throw appEx;
            }

            AreaReinDataOnFloor      dataOnFloor = new AreaReinDataOnFloor();
            CreateSimpleAreaReinForm createForm  =
                new CreateSimpleAreaReinForm(dataOnFloor);

            //allow use select parameters to create
            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
                ElementId         areaReinforcementTypeId = AreaReinforcementType.CreateDefaultAreaReinforcementType(m_revit.Application.ActiveUIDocument.Document);
                ElementId         rebarBarTypeId          = RebarBarType.CreateDefaultRebarBarType(m_revit.Application.ActiveUIDocument.Document);
                ElementId         rebarHookTypeId         = RebarHookType.CreateDefaultRebarHookType(m_revit.Application.ActiveUIDocument.Document);
                AreaReinforcement areaRein = AreaReinforcement.Create(m_revit.Application.ActiveUIDocument.Document, floor, curves, majorDirection, areaReinforcementTypeId, rebarBarTypeId, rebarHookTypeId);

                //set AreaReinforcement and it's AreaReinforcementCurves parameters
                dataOnFloor.FillIn(areaRein);
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// create simple AreaReinforcement on horizontal floor
        /// </summary>
        /// <param name="floor"></param>
        /// <returns>is successful</returns>
        private bool CreateAreaReinOnFloor(Floor floor)
        {
            GeomHelper helper = new GeomHelper();
            Reference  refer  = null;
            CurveArray curves = null;

            //check whether floor is horizontal rectangular
            //and prepare necessary to create AreaReinforcement
            if (!helper.GetFloorGeom(floor, ref refer, ref curves))
            {
                ApplicationException appEx = new ApplicationException(
                    "Your selection is not a horizontal rectangular slab.");
                throw appEx;
            }

            AreaReinDataOnFloor      dataOnFloor = new AreaReinDataOnFloor();
            CreateSimpleAreaReinForm createForm  =
                new CreateSimpleAreaReinForm(dataOnFloor);

            //allow use select parameters to create
            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.get_Item(0));
                Autodesk.Revit.DB.XYZ majorDirection = new Autodesk.Revit.DB.XYZ(
                    firstLine.get_EndPoint(1).X - firstLine.get_EndPoint(0).X,
                    firstLine.get_EndPoint(1).Y - firstLine.get_EndPoint(0).Y,
                    firstLine.get_EndPoint(1).Z - firstLine.get_EndPoint(0).Z);

                //crete AreaReinforcement by NewAreaReinforcement function
                DocCreator        creator  = m_revit.Application.ActiveUIDocument.Document.Create;
                AreaReinforcement areaRein = creator.NewAreaReinforcement(floor, curves, majorDirection);

                //set AreaReinforcement and it's AreaReinforcementCurves parameters
                dataOnFloor.FillIn(areaRein);
                return(true);
            }
            return(false);
        }
Example #5
0
        /// <summary>
        /// create simple AreaReinforcement on vertical straight rectangular wall
        /// </summary>
        /// <param name="wall"></param>
        /// <returns>is successful</returns>
        private bool CreateAreaReinOnWall(Wall wall)
        {
            //make sure selected is basic wall
            if (wall.WallType.Kind != WallKind.Basic)
            {
                MessageBox.Show("Selected wall is not a basic wall.");
                return false;
            }

            GeomHelper helper = new GeomHelper();
            Reference refer = null;
            CurveArray curves = null;
            //check whether wall is vertical rectangular and analytical model shape is line
            if (!helper.GetWallGeom(wall, ref refer, ref curves))
            {
                ApplicationException appEx = new ApplicationException(
                    "Your selection is not a structural straight rectangular wall.");
                throw appEx;
            }

            AreaReinDataOnWall dataOnWall = new AreaReinDataOnWall();
            CreateSimpleAreaReinForm createForm = new
                CreateSimpleAreaReinForm(dataOnWall);

            //allow use select parameters to create
            if (createForm.ShowDialog() == DialogResult.OK)
            {
                DocCreator creator = m_revit.Application.ActiveUIDocument.Document.Create;

                //define the Major Direction of AreaReinforcement,
                //we get direction of first Line on the Floor as the Major Direction
                Line firstLine = (Line)(curves.get_Item(0));
                Autodesk.Revit.DB.XYZ majorDirection = new Autodesk.Revit.DB.XYZ (
                    firstLine.get_EndPoint(1).X - firstLine.get_EndPoint(0).X,
                    firstLine.get_EndPoint(1).Y - firstLine.get_EndPoint(0).Y,
                    firstLine.get_EndPoint(1).Z - firstLine.get_EndPoint(0).Z);

                //create AreaReinforcement by NewAreaReinforcement function
                AreaReinforcement areaRein = creator.NewAreaReinforcement(wall, curves, majorDirection);
                dataOnWall.FillIn(areaRein);
                return true;
            }
            return false;
        }
Example #6
0
        /// <summary>
        /// create simple AreaReinforcement on horizontal floor
        /// </summary>
        /// <param name="floor"></param>
        /// <returns>is successful</returns>
        private bool CreateAreaReinOnFloor(Floor floor)
        {
            GeomHelper helper = new GeomHelper();
            Reference refer = null;
            CurveArray curves = null;

            //check whether floor is horizontal rectangular
            //and prepare necessary to create AreaReinforcement
            if (!helper.GetFloorGeom(floor, ref refer, ref curves))
            {
                ApplicationException appEx = new ApplicationException(
                    "Your selection is not a horizontal rectangular slab.");
                throw appEx;
            }

            AreaReinDataOnFloor dataOnFloor = new AreaReinDataOnFloor();
            CreateSimpleAreaReinForm createForm =
                new CreateSimpleAreaReinForm(dataOnFloor);

            //allow use select parameters to create
            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.get_Item(0));
                Autodesk.Revit.DB.XYZ majorDirection = new Autodesk.Revit.DB.XYZ (
                    firstLine.get_EndPoint(1).X - firstLine.get_EndPoint(0).X,
                    firstLine.get_EndPoint(1).Y - firstLine.get_EndPoint(0).Y,
                    firstLine.get_EndPoint(1).Z - firstLine.get_EndPoint(0).Z);

                //crete AreaReinforcement by NewAreaReinforcement function
                DocCreator creator = m_revit.Application.ActiveUIDocument.Document.Create;
                AreaReinforcement areaRein = creator.NewAreaReinforcement(floor, curves, majorDirection);

                //set AreaReinforcement and it's AreaReinforcementCurves parameters
                dataOnFloor.FillIn(areaRein);
                return true;
            }
            return false;
        }