public ImportXYZForm(ImportXYZData importData)
        {
            m_importData = importData;

            InitializeComponent();
            this.FormClosing += new FormClosingEventHandler(s_positioning.OnFormClosing);
            this.Shown       += new System.EventHandler(s_positioning.OnShown);
            LoadParameters();
        }
        public static DialogResult ShowXYZFileOpenDialog(ImportXYZData import_data, out string file_name, out string file_full_name)
        {
            file_name      = string.Empty;
            file_full_name = string.Empty;
            using (OpenFileDialog open_file_dialog = new OpenFileDialog())
            {
                open_file_dialog.Title            = import_data.Title;
                open_file_dialog.InitialDirectory = import_data.ImportFolder;
                open_file_dialog.Filter           = import_data.Filter;
                open_file_dialog.RestoreDirectory = true;

                DialogResult result = open_file_dialog.ShowDialog();
                if (result != DialogResult.Cancel)
                {
                    file_name      = open_file_dialog.SafeFileName;
                    file_full_name = open_file_dialog.FileName;
                }
                return(result);
            }
        }
コード例 #3
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);
        }