private static void OnSetLastExecutedCommand()
        {
            PushButton repeatButton = FindSurfaceRevitPluginUI.GetPushButton(FindSurfaceRevitPluginUI.PushButtonRepeatClassName);

            if (s_last_executed_command != null && repeatButton.Enabled)
            {
                return;
            }
            FindSurfaceRevitPluginUI.GetPushButton(FindSurfaceRevitPluginUI.PushButtonRepeatClassName).Enabled = true;
        }
        /// <summary>
        /// Shows a warning message.
        /// This method is designed to be called when users explicitly deleted the point cloud
        /// that corresponds to the one that is used by FindSurface.
        /// (e.g., pressing the [delete] button after clicking the point cloud)
        /// </summary>
        private static void PromptOutlierDeletedWarning()
        {
            if (s_temporary_outlier_deletion == false)
            {
                TaskDialog.Show("Outlier deleted!",
                                "User deleted the outlier point cloud." + Environment.NewLine +
                                "To use the features in Find shapes tab:" + Environment.NewLine +
                                "- Click [Reset] button to restore the initial state." + Environment.NewLine +
                                "- Click [Open] button to import another point cloud file.");

                FindSurfaceRevitPluginUI.GetRibbonPanel(FindSurfaceRevitPluginUI.RibbonPanelFindSurfaceName).Enabled = false;
            }
            s_temporary_outlier_deletion = false;
        }
Example #3
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string messge,
            ElementSet elements)
        {
            Document doc = commandData.Application.ActiveUIDocument.Document;

            if (FindSurfaceRevitPlugin.OnResetCommand(doc))
            {
                FindSurfaceRevitPluginUI.GetRibbonPanel(FindSurfaceRevitPluginUI.RibbonPanelFindSurfaceName).Enabled     = true;
                FindSurfaceRevitPluginUI.GetRibbonPanel(FindSurfaceRevitPluginUI.RibbonPanelFindSurface2ptsName).Enabled = true;
                FindSurfaceRevitPluginUI.GetRibbonPanel(FindSurfaceRevitPluginUI.RibbonPanelFindSurface3ptsName).Enabled = true;
                FindSurfaceRevitPluginUI.GetPushButton(FindSurfaceRevitPluginUI.PushButtonViewListClassName).Enabled     = true;
            }

            return(Result.Succeeded);
        }
Example #4
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            Document doc = commandData.Application.ActiveUIDocument.Document;

            ImportXYZData import_data = new ImportXYZData(doc);

            try
            {
                using (ImportXYZForm import_form = new ImportXYZForm(import_data))
                {
                    if (import_form.ShowDialog(s_hwndRevit) == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return(Result.Cancelled);
                    }

                    FindSurfaceRevitPluginUI.GetRibbonPanel(FindSurfaceRevitPluginUI.RibbonPanelFindSurfaceName).Enabled     = true;
                    FindSurfaceRevitPluginUI.GetRibbonPanel(FindSurfaceRevitPluginUI.RibbonPanelFindSurface2ptsName).Enabled = true;
                    FindSurfaceRevitPluginUI.GetRibbonPanel(FindSurfaceRevitPluginUI.RibbonPanelFindSurface3ptsName).Enabled = true;
                    FindSurfaceRevitPluginUI.GetPushButton(FindSurfaceRevitPluginUI.PushButtonViewListClassName).Enabled     = true;
                }
            }
            catch (Exception ex)
            {
                message = ex.ToString();
                return(Result.Failed);
            }

            string import_file_full_name = import_data.ImportFileFullName;
            string import_file_name      = import_data.ImportFileName;

            float[] import_data_xyz_array          = import_data.ImportDataXYZ;
            int[]   import_data_color_array        = import_data.ImportDataColor;
            int     import_data_subdivision_factor = import_data.SubdivisionFactor;

            float[] import_data_bounding_box_center = import_data.ImportDataBoundingBoxCenter;
            float[] import_data_bounding_box_extent = import_data.ImportDataBoundingBoxExtent;

            //TODO: HERE to insert the working code of XYZUnitConversionForm...
            XYZUnitConversionData conversion_data = new XYZUnitConversionData();

            try
            {
                using (XYZUnitConversionForm conversion_form = new XYZUnitConversionForm(import_data_bounding_box_extent, import_data_bounding_box_center, conversion_data))
                {
                    if (conversion_form.ShowDialog(s_hwndRevit) == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return(Result.Cancelled);
                    }
                }
            }
            catch (Exception ex)
            {
                message = ex.ToString();
                return(Result.Failed);
            }

            float[] offset = conversion_data.OriginOffset;
            float   scale  = conversion_data.Scale;

            for (int k = 0; k < import_data_xyz_array.Length; k += 3)
            {
                import_data_xyz_array[k]     -= offset[0];
                import_data_xyz_array[k + 1] -= offset[1];
                import_data_xyz_array[k + 2] -= offset[2];
                import_data_xyz_array[k]     *= scale;
                import_data_xyz_array[k + 1] *= scale;
                import_data_xyz_array[k + 2] *= scale;
            }
            FindSurfaceRevitPlugin.OnOpenCommand(doc, import_file_name, import_data_xyz_array, import_data_color_array, import_data_subdivision_factor, conversion_data.MeasuringUnit);

            return(Result.Succeeded);
        }