public void Execute(UIApplication app)
        {
            UIDocument uidoc = app.ActiveUIDocument;
            Document   doc   = uidoc.Document;

            string baseLevel = Properties.Settings.Default.BaseLevelName;
            string topLevel  = Properties.Settings.Default.TopLevelName;
            float  scale     = Properties.Settings.Default.Scale;
            double overhang  = UnitUtils.ConvertToInternalUnits(Properties.Settings.Default.Overhang, UnitTypeId.Meters);;

            XYZ        slopeVector = BuildRoofForm.SlopeVector;
            RoofDesign roofDesign  = BuildRoofForm.RoofDesign;
            double     slope       = RoofSelector.GetSlopeByType(roofDesign);

            HouseBuilder elementPlacer = new HouseBuilder(doc, baseLevel, topLevel, scale);

            try
            {
                using (Transaction transaction = new Transaction(doc, "Roof Command"))
                {
                    transaction.Start();
                    elementPlacer.CreateRoof(overhang, slope, slopeVector, roofDesign);
                    transaction.Commit();
                }
            }
            catch { }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Create a generic roof in the Top Level.
 /// </summary>
 /// <param name="slopeDirection">
 /// The slope will only be apllied on the edges that is orthogonal to the Slope Direction Vector.
 /// Note tha a 0 vector is ortoghonal to all vectors.
 /// </param>
 /// <param name="slope">
 /// The slope of the the roof.
 /// </param>
 /// <param name="roofDesign">
 /// The roof type that will be created.
 /// </param>
 /// <returns>
 /// Returns the created FootPrintRoof.
 /// </returns>
 public FootPrintRoof CreateRoof(double slope, XYZ slopeDirection, RoofDesign roofDesign)
 {
     return(CreateRoof(0, slope, slopeDirection, roofDesign));
 }
        public void Execute(UIApplication app)
        {
            UIDocument uidoc = app.ActiveUIDocument;
            Document   doc   = uidoc.Document;

            float  scale = 0;
            double overhang = 0;
            string levelName = "", topLevelName = "";

            try
            {
                scale        = Properties.Settings.Default.Scale;
                overhang     = UnitUtils.ConvertToInternalUnits(Properties.Settings.Default.Overhang, UnitTypeId.Meters);
                levelName    = Properties.Settings.Default.BaseLevelName;
                topLevelName = Properties.Settings.Default.TopLevelName;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                PlaceElementsForm.CloseForm();
            }

            string     path       = PlaceElementsForm.filePath;
            XYZ        roofVector = PlaceElementsForm.roofSelector.SlopeVector;
            RoofDesign roofDesign = PlaceElementsForm.roofSelector.RoofStyle;
            double     slope      = RoofSelector.GetSlopeByType(roofDesign);

            HouseBuilder builder = new HouseBuilder(doc, levelName, topLevelName, scale);

            string errorMessage = "";

            using (Transaction transaction = new Transaction(doc, "Contruir JSON"))
            {
                transaction.Start();
                try
                {
                    builder.BuildJSON(path);
                }
                catch (Exception e)
                {
                    errorMessage += $"\nErro ao construir elementos do JSON: \"{e.Message}\"";
                }
                try
                {
                    builder.CreateFloor(Properties.Settings.Default.FloorName);
                }
                catch (Exception e)
                {
                    errorMessage += $"\nErro ao construir piso: \"{e.Message}\"";
                }
                try
                {
                    builder.CreateCeiling(Properties.Settings.Default.CeilingName);
                }
                catch (Exception e)
                {
                    errorMessage += $"\nErro ao construir laje: \"{e.Message}\"";
                }
                try
                {
                    builder.ClassifyRooms();
                }
                catch (Exception e)
                {
                    errorMessage += $"\nErro ao classificar ambientes: \"{e.Message}\"";
                }
                transaction.Commit();
            }
            using (Transaction transaction = new Transaction(doc, "Contruir Telhado"))
            {
                transaction.Start();

                try
                {
                    builder.CreateRoof(overhang, slope, roofVector, roofDesign);
                }
                catch (Exception e)
                {
                    errorMessage += $"\nErro ao construir telhado: \"{e.Message}\"";
                }
                transaction.Commit();
            }

            if (errorMessage.Length > 1)
            {
                MessageBox.Show(errorMessage, "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            PlaceElementsForm.CloseForm();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a generic roof in the Top Level.
        /// </summary>
        /// <param name="overhang">
        /// The value of the overhang. The overhang will be applied in all sides.
        /// If this value is 0, the user may not pass the slopeDirection argument.
        /// </param>
        /// <param name="slopeDirection">
        /// The slope will only be apllied on the edges that is orthogonal to the Slope Direction Vector.
        /// Note tha a 0 vector is ortoghonal to all vectors.
        /// </param>
        /// <param name="slope">
        /// The slope of the the roof.
        /// </param>
        /// <param name="roofDesign">
        /// The roof type that will be created.
        /// </param>
        /// <returns>
        /// Returns the created FootPrintRoof.
        /// </returns>
        public FootPrintRoof CreateRoof(double overhang, double slope, XYZ slopeDirection, RoofDesign roofDesign)
        {
            FootPrintRoof footPrintRoof  = null;
            CurveArray    footPrintCurve = hb.GetHousePerimeter();

            Polygon polygon = new Polygon(footPrintCurve);

            polygon.Normalize();
            footPrintCurve = polygon.CurveArray;

            switch (roofDesign)
            {
            case RoofDesign.Hip:
                CreateHipRoof(footPrintCurve, overhang, slope, slopeDirection);
                break;

            case RoofDesign.Gable:
                CreateGableRoof(footPrintCurve, overhang, slope, slopeDirection);
                break;

            case RoofDesign.HiddenButterfly:
                CreateHiddenButterflyRoof(footPrintCurve, slope, slopeDirection);
                break;
            }
            return(footPrintRoof);
        }
Exemplo n.º 5
0
        public void CreateRoof(double slope, XYZ slopeDirection, RoofDesign roofDesign)
        {
            RoofCreator rc = new RoofCreator(doc, baseLevel, topLevel, this, revitDB);

            rc.CreateRoof(slope, slopeDirection, roofDesign);
        }