public GridCreationOptionForm(GridCreationOptionData opt)
        {
            m_gridCreationOption = opt;

            InitializeComponent();

            // Set state of controls
            InitializeControls();
        }
Exemple #2
0
        public virtual Result Execute(
            ExternalCommandData commandData,
            ref string msg,
            ElementSet elements)
        {
            UIApplication rvtuiapp = commandData.Application;
            UIDocument    rvtuidoc = rvtuiapp.ActiveUIDocument;

            _app = rvtuiapp.Application;
            _doc = rvtuidoc.Document;

            try
            {
                Document doc = commandData.Application.ActiveUIDocument.Document;

                CurveArray selectedCurves = GetSelectedCurves(_doc);                     // Get all selected lines and arcs

                GridCreationOptionData gridCreationOption = new GridCreationOptionData(!selectedCurves.IsEmpty);
                using (GridCreationOptionForm gridCreationOptionForm = new GridCreationOptionForm(gridCreationOption))
                {
                }
            }
        }
Exemple #3
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                Document document = commandData.Application.ActiveUIDocument.Document;

                // Get all selected lines and arcs
                CurveArray selectedCurves = GetSelectedCurves(commandData.Application.ActiveUIDocument.Document);

                // Show UI
                GridCreationOptionData gridCreationOption = new GridCreationOptionData(!selectedCurves.IsEmpty);
                using (GridCreationOptionForm gridCreationOptForm = new GridCreationOptionForm(gridCreationOption))
                {
                    DialogResult result = gridCreationOptForm.ShowDialog();
                    if (result == DialogResult.Cancel)
                    {
                        return(Autodesk.Revit.UI.Result.Cancelled);
                    }

                    ArrayList   labels = GetAllLabelsOfGrids(document);
                    ForgeTypeId unit   = GetLengthUnitType(document);
                    switch (gridCreationOption.CreateGridsMode)
                    {
                    case CreateMode.Select:     // Create grids with selected lines/arcs
                        CreateWithSelectedCurvesData data = new CreateWithSelectedCurvesData(commandData.Application, selectedCurves, labels);
                        using (CreateWithSelectedCurvesForm createWithSelected = new CreateWithSelectedCurvesForm(data))
                        {
                            result = createWithSelected.ShowDialog();
                            if (result == DialogResult.OK)
                            {
                                // Create grids
                                Transaction transaction = new Transaction(document, "CreateGridsWithSelectedCurves");
                                transaction.Start();
                                data.CreateGrids();
                                transaction.Commit();
                            }
                        }
                        break;

                        //case CreateMode.Orthogonal: // Create orthogonal grids
                        //    CreateOrthogonalGridsData orthogonalData = new CreateOrthogonalGridsData(commandData.Application, unit, labels);
                        //    using (CreateOrthogonalGridsForm orthogonalGridForm = new CreateOrthogonalGridsForm(orthogonalData))
                        //    {
                        //        result = orthogonalGridForm.ShowDialog();
                        //        if (result == DialogResult.OK)
                        //        {
                        //            // Create grids
                        //            Transaction transaction = new Transaction(document, "CreateOrthogonalGrids");
                        //            transaction.Start();
                        //            orthogonalData.CreateGrids();
                        //            transaction.Commit();
                        //        }
                        //    }
                        //    break;

                        //case CreateMode.RadialAndArc: // Create radial and arc grids
                        //    CreateRadialAndArcGridsData radArcData = new CreateRadialAndArcGridsData(commandData.Application, unit, labels);
                        //    using (CreateRadialAndArcGridsForm radArcForm = new CreateRadialAndArcGridsForm(radArcData))
                        //    {
                        //        result = radArcForm.ShowDialog();
                        //        if (result == DialogResult.OK)
                        //        {
                        //            // Create grids
                        //            Transaction transaction = new Transaction(document, "CreateRadialAndArcGrids");
                        //            transaction.Start();
                        //            radArcData.CreateGrids();
                        //            transaction.Commit();
                        //        }
                        //    }
                        //    break;
                    }

                    if (result == DialogResult.OK)
                    {
                        return(Autodesk.Revit.UI.Result.Succeeded);
                    }
                    else
                    {
                        return(Autodesk.Revit.UI.Result.Cancelled);
                    }
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return(Autodesk.Revit.UI.Result.Failed);
            }
        }