public void InitializeTextStrings()
 {
     LanguageSupport.Translate(lb_include_in_subdir_name, ref LanguageSupport.lb_include_in_subdir_name);
     LanguageSupport.Translate(cb_include_file_name, ref LanguageSupport.cb_include_file_name_text);
     LanguageSupport.Translate(cb_include_project_title, ref LanguageSupport.cb_include_project_title_text);
     LanguageSupport.Translate(cb_include_postprocessor, ref LanguageSupport.cb_include_postprocessor_text);
     LanguageSupport.Translate(cb_include_machine_name, ref LanguageSupport.cb_include_machine_name_text);
     LanguageSupport.Translate(cb_include_setup_name, ref LanguageSupport.cb_include_setup_name_text);
     LanguageSupport.Translate(this, ref LanguageSupport.f_subdir_options_text);
     LanguageSupport.Translate(cb_select_order, ref LanguageSupport.cb_select_order_text);
     LanguageSupport.Translate(b_Up, ref LanguageSupport.b_Up_text);
     LanguageSupport.Translate(b_Down, ref LanguageSupport.b_Down_text);
     LanguageSupport.Translate(b_OK, ref LanguageSupport.b_OK_text);
     LanguageSupport.Translate(b_Apply, ref LanguageSupport.b_Apply_text);
     LanguageSupport.Translate(b_Cancel, ref LanguageSupport.b_Cancel_text);
 }
コード例 #2
0
        private static void ClampsToSolids()
        {
            string err_msg = "";
            string fpath;

            try
            {
                if (Variables.clamps == null)
                {
                    Variables.clamp_fpaths = null;
                    return;
                }
                if (Variables.clamps.Count == 0)
                {
                    Variables.clamp_fpaths = null;
                    return;
                }
                foreach (SolidInfo clamp in Variables.clamps)
                {
                    if (clamp.is_export)
                    {
                        fpath = Path.Combine(Variables.output_dirpath, clamp.solid.Name + "_clamp.stl");
                        clamp.solid.ExportToSTL(fpath, out err_msg);
                        if (err_msg == "" || err_msg == null)
                        {
                            Variables.output_msg += fpath + "\n";
                        }
                        else
                        {
                            MessageBox.Show(LanguageSupport.Translate(Properties.Resources.msg_clamp_export_exception) + "\n'" + err_msg + "'", LanguageSupport.Translate(Properties.Resources.msg_exception_title));
                        }
                        if (Variables.clamp_fpaths == null)
                        {
                            Variables.clamp_fpaths = new List <string>();
                        }
                        Variables.clamp_fpaths.Add(fpath);
                    }
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(LanguageSupport.Translate(Properties.Resources.msg_general_exception) + Ex.Message, LanguageSupport.Translate(Properties.Resources.msg_exception_title));
            }
        }
コード例 #3
0
 public void InitializeTextStrings()
 {
     LanguageSupport.Translate(label8, ref LanguageSupport.label8_text);
     LanguageSupport.Translate(rb_save_to_file_dir, ref LanguageSupport.rb_save_to_file_dir_text);
     LanguageSupport.Translate(rb_save_to_other_dir, ref LanguageSupport.rb_save_to_other_dir_text);
     LanguageSupport.Translate(b_select_output_dir, ref LanguageSupport.b_select_output_dir_text);
     LanguageSupport.Translate(cb_create_subdir, ref LanguageSupport.cb_create_subdir_text);
     LanguageSupport.Translate(b_subdir_options, ref LanguageSupport.b_subdir_options);
     LanguageSupport.Translate(button1, ref LanguageSupport.button1_text);
     LanguageSupport.Translate(label5, ref LanguageSupport.label5_text);
     LanguageSupport.Translate(b_select_ncsimul_machine, ref LanguageSupport.b_select_ncsimul_machine_text);
     LanguageSupport.Translate(label3, ref LanguageSupport.label3_text);
     LanguageSupport.Translate(label4, ref LanguageSupport.label4_text);
     LanguageSupport.Translate(rb_tool_number, ref LanguageSupport.rb_tool_number_text);
     LanguageSupport.Translate(rb_tool_id, ref LanguageSupport.rb_tool_id_text);
     LanguageSupport.Translate(label2, ref LanguageSupport.label2_text);
     LanguageSupport.Translate(label6, ref LanguageSupport.label6_text);
     LanguageSupport.Translate(rb_indiv_offsets, ref LanguageSupport.rb_indiv_offsets_text);
     LanguageSupport.Translate(rb_DATUM, ref LanguageSupport.rb_DATUM_text);
     LanguageSupport.Translate(lb_setup_warning, ref LanguageSupport.lb_setup_warning_text);
     LanguageSupport.Translate(gb_turret_info, ref LanguageSupport.gb_turret_info_text);
     LanguageSupport.Translate(l_umss, ref LanguageSupport.l_umss_text);
     LanguageSupport.Translate(l_usss, ref LanguageSupport.l_usss_text);
     LanguageSupport.Translate(l_lmss, ref LanguageSupport.l_lmss_text);
     LanguageSupport.Translate(l_lsss, ref LanguageSupport.l_lsss_text);
     LanguageSupport.Translate(rb_umss_milling_head, ref LanguageSupport.rb_umss_milling_head_text);
     LanguageSupport.rb_usss_milling_head_text = LanguageSupport.rb_umss_milling_head_text;
     LanguageSupport.rb_lmss_milling_head_text = LanguageSupport.rb_umss_milling_head_text;
     LanguageSupport.rb_lsss_milling_head_text = LanguageSupport.rb_umss_milling_head_text;
     LanguageSupport.Translate(rb_umss_turret, ref LanguageSupport.rb_umss_turret_text);
     LanguageSupport.rb_usss_turret_text = LanguageSupport.rb_umss_turret_text;
     LanguageSupport.rb_lmss_turret_text = LanguageSupport.rb_umss_turret_text;
     LanguageSupport.rb_lsss_turret_text = LanguageSupport.rb_umss_turret_text;
     LanguageSupport.Translate(b_SaveSettings, ref LanguageSupport.b_SaveSettings_text);
     LanguageSupport.Translate(b_export, ref LanguageSupport.b_export_text);
     LanguageSupport.Translate(b_cancel, ref LanguageSupport.b_cancel_text);
     LanguageSupport.Translate(b_help, ref LanguageSupport.b_help_text);
     LanguageSupport.Translate(cb_tool_rad_as_offset, ref LanguageSupport.cb_tool_rad_as_offset_text);
     LanguageSupport.Translate(cb_tool_length_as_offset, ref LanguageSupport.cb_tool_length_as_offset_text);
     LanguageSupport.Translate(b_PreviewOffset, ref LanguageSupport.b_PreviewOffset_text);
 }
        private void b_Up_Click(object sender, EventArgs e)
        {
            if (clb_name_format.SelectedItem == null)
            {
                MessageBox.Show(LanguageSupport.Translate(Properties.Resources.msg_no_Order_list_selection), LanguageSupport.Translate(Properties.Resources.str_prog_name));
                return;
            }

            int    i;
            Format temp1;

            i = clb_name_format.SelectedIndex;
            if (i > 0)
            {
                temp1 = Settings.subdir_format1[i - 1];
                Settings.subdir_format1[i - 1] = (Format)clb_name_format.SelectedItem;
                Settings.subdir_format1[i]     = temp1;
                clb_name_format.SelectedIndex--;
            }
            UpdateFormatList();
        }
コード例 #5
0
        public Format(tagFormat Id)
        {
            switch (Id)
            {
            case tagFormat.tF_CNCFileName:
                this.display_name     = LanguageSupport.Translate(Properties.Resources.str_post_name);
                this.eng_name         = Properties.Resources.str_post_name;
                this.ini_file_keyword = Settings.str_ini_format_cnc_file_name;
                this.id = Id;
                break;

            case tagFormat.tF_FileName:
                this.display_name     = LanguageSupport.Translate(Properties.Resources.str_file_name);
                this.eng_name         = Properties.Resources.str_file_name;
                this.ini_file_keyword = Settings.str_ini_format_file_name;
                this.id = Id;
                break;

            case tagFormat.tF_MachineName:
                this.display_name     = LanguageSupport.Translate(Properties.Resources.str_machine_name);
                this.eng_name         = Properties.Resources.str_machine_name;
                this.ini_file_keyword = Settings.str_ini_format_machine_name;
                this.id = Id;
                break;

            case tagFormat.tF_SetupName:
                this.display_name     = LanguageSupport.Translate(Properties.Resources.str_setup_name);
                this.eng_name         = Properties.Resources.str_setup_name;
                this.ini_file_keyword = Settings.str_ini_format_setup_name;
                this.id = Id;
                break;

            case tagFormat.tF_Title:
                this.display_name     = LanguageSupport.Translate(Properties.Resources.str_title);
                this.eng_name         = Properties.Resources.str_title;
                this.ini_file_keyword = Settings.str_ini_format_title;
                this.id = Id;
                break;
            }
        }
        private void b_Down_Click(object sender, EventArgs e)
        {
            if (clb_name_format.SelectedItem == null)
            {
                MessageBox.Show(LanguageSupport.Translate(Properties.Resources.msg_no_Order_list_selection), LanguageSupport.Translate(Properties.Resources.str_prog_name));
                return;
            }

            List <string> list_items = new List <string>();
            Format        temp1;

            int i = clb_name_format.SelectedIndex;

            if (i < Settings.subdir_format1.Count - 1)
            {
                temp1 = Settings.subdir_format1[i + 1];
                Settings.subdir_format1[i + 1] = (Format)clb_name_format.SelectedItem;
                Settings.subdir_format1[i]     = temp1;
                clb_name_format.SelectedIndex++;
            }
            UpdateFormatList();
        }
コード例 #7
0
        private static void StockToSolid()
        {
            string err_msg = "";

            try
            {
                Variables.stock_fpath = Path.Combine(Variables.output_dirpath, "stock.stl");

                Variables.stock.ExportToSTL(Variables.stock_fpath, out err_msg);
                if (err_msg == "" || err_msg == null)
                {
                    Variables.output_msg += Variables.stock_fpath + "\n";
                }
                else
                {
                    MessageBox.Show(LanguageSupport.Translate(Properties.Resources.msg_stock_export_exception) + "\n'" + err_msg + "'", LanguageSupport.Translate(Properties.Resources.msg_exception_title));
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(LanguageSupport.Translate(Properties.Resources.msg_general_exception) + Ex.Message, LanguageSupport.Translate(Properties.Resources.msg_exception_title));
            }
        }
コード例 #8
0
        static public void FeatureCAMToNCSIMUL()
        {
            FeatureCAM.FMDocument doc;

            LanguageSupport.InitializeTranslation(fc.CurrentLanguage);

            doc = (FeatureCAM.FMDocument)fc.ActiveDocument;

            InitializeVariables();
            if (Variables.ncsimul_path == "")
            {
                MessageBox.Show(LanguageSupport.Translate(Properties.Resources.msg_no_NCSIMUL), LanguageSupport.Translate(Properties.Resources.str_prog_name));
                return;
            }

            if (Variables.doc == null)
            {
                MessageBox.Show(LanguageSupport.Translate(Properties.Resources.msg_no_open_files), LanguageSupport.Translate(Properties.Resources.str_prog_name));
                return;
            }
            Settings.ReadSettingsFromAddinIniFile();

            // helper function to force a single instance of plugin form
            if (main_form != null)
            {
                main_form.BringToFront();
            }
            else
            {
                main_form = new UI();
                main_form.Show();
                main_form.TopLevel = true;
                main_form.TopMost  = true;
                System.Windows.Forms.Application.Run(main_form);
            }
        }
コード例 #9
0
 private void button1_Click(object sender, EventArgs e)
 {
     MessageBox.Show(ConstructOutputDirPath(), LanguageSupport.Translate(Properties.Resources.str_prog_name));
 }
コード例 #10
0
        private void b_export_Click(object sender, EventArgs e)
        {
            Variables.output_dirpath = ConstructOutputDirPath();
            if (Variables.output_dirpath == "")
            {
                MessageBox.Show(LanguageSupport.Translate(Properties.Resources.msg_no_output_folder_set), LanguageSupport.Translate(Properties.Resources.str_prog_name));
                return;
            }
            if (Settings.ncsimul_md_fpath.Trim() == "")
            {
                MessageBox.Show(LanguageSupport.Translate(Properties.Resources.msg_no_machine_set), LanguageSupport.Translate(Properties.Resources.str_prog_name));
                return;
            }
            if (Settings.ncsimul_md_fpath.Trim() != "")
            {
                if (!File.Exists(Settings.ncsimul_md_fpath))
                {
                    MessageBox.Show(String.Format(LanguageSupport.Translate(Properties.Resources.msg_machine_file_doesnot_exist), Settings.ncsimul_md_fpath),
                                    LanguageSupport.Translate(Properties.Resources.str_prog_name));
                    return;
                }
            }
            if (Variables.clamps != null)
            {
                foreach (SolidInfo solid_info in Variables.clamps)
                {
                    solid_info.is_export = false;
                }

                foreach (string item in lb_clamps.CheckedItems)
                {
                    foreach (SolidInfo solid_info in Variables.clamps)
                    {
                        if (solid_info.solid.Name.Equals(item, StringComparison.OrdinalIgnoreCase))
                        {
                            solid_info.is_export = true;
                        }
                    }
                }
            }
            this.Close();
            FCToNCSIMUL.main_form = null;

            if (Variables.offset_pt != null)
            {
                Variables.offset_pt.Delete(false);
            }
            if (p_lmss.Visible)
            {
                Variables.lmss.available       = true;
                Variables.lmss.is_milling_head = rb_lmss_milling_head.Checked;
            }
            if (p_lsss.Visible)
            {
                Variables.lsss.available       = true;
                Variables.lsss.is_milling_head = rb_lsss_milling_head.Checked;
            }
            if (p_umss.Visible)
            {
                Variables.umss.available       = true;
                Variables.umss.is_milling_head = rb_umss_milling_head.Checked;
            }
            if (p_usss.Visible)
            {
                Variables.usss.available       = true;
                Variables.usss.is_milling_head = rb_usss_milling_head.Checked;
            }

            FCToNCSIMUL.Convert();
        }
コード例 #11
0
        private static string ToolsToXMLFile()
        {
            List <string> setup_tools       = null;
            List <string> partline_features = null;
            string        tool_info         = "";
            int           setup_num;
            string        setup_tool_list;

            FeatureCAM.FMToolMap2 toolmap;

            setup_num         = 0;
            setup_tool_list   = "";
            partline_features = GetAllFeaturesUsingPartLineComp();
            foreach (FeatureCAM.FMSetup setup in Variables.doc.Setups)
            {
                if (setup_tools == null)
                {
                    setup_tools = new List <string>();
                }
                foreach (FeatureCAM.FMFeature feat in setup.Features)
                {
                    if (feat.Enabled)
                    {
                        foreach (FeatureCAM.FMOperation op in feat.Operations)
                        {
                            if (op.Tool != null)
                            {
                                setup_tool_list += op.Tool.Name + ";";
                            }
                        }
                    }
                }
                setup_tools.Add(setup_tool_list);
                setup_num++;
            }

            Variables.unsupported_tool_names = "";
            Variables.doc.InvalidateAll();
            /* If we need to create separate tls file for each setup, write tools for each setup to a separate file */
            if (!Variables.is_single_program)
            {
                for (int si = 1; si <= Variables.doc.Setups.Count; si++)
                {
                    tool_info = "";
                    for (int i = 1; i <= Variables.doc.ToolMaps.Count; i++)
                    {
                        toolmap = Variables.doc.ToolMaps.Item(i);
                        if (setup_tools[si - 1].IndexOf(toolmap.Tool.Name + ";") >= 0 &&
                            toolmap.Operations.Count > 0)
                        {
                            tool_info +=
                                Tool.ToString(toolmap, partline_features) + Environment.NewLine;
                        }
                    }
                }
            }
            else
            {
                for (int i = 1; i <= Variables.doc.ToolMaps.Count; i++)
                {
                    toolmap = Variables.doc.ToolMaps.Item(i);
                    if (toolmap.Operations.Count > 0)
                    {
                        tool_info +=
                            Tool.ToString(toolmap, partline_features) + Environment.NewLine;
                    }
                }
            }

            if (Variables.unsupported_tool_names != "")
            {
                MessageBox.Show(String.Format(LanguageSupport.Translate(Properties.Resources.msg_unsupported_tools), Variables.unsupported_tool_names),
                                LanguageSupport.Translate(Properties.Resources.str_prog_name));
            }

            return(tool_info);
        }
コード例 #12
0
        private static bool SaveNCCode()
        {
            int    nc_files_num, doc_files_num, macro_files_num;
            object doc_file_names, macro_file_names, nc_file_names;
            string err_msg;
            bool   is_op_error;
            int    nc_file_id;

            is_op_error = false;
            foreach (FeatureCAM.FMOperation op in Variables.doc.Operations)
            {
                if (op.Errors.Trim() != "")
                {
                    is_op_error = true;
                }
            }

            if (is_op_error)
            {
                MessageBox.Show(LanguageSupport.Translate(Properties.Resources.msg_cannot_export_data), LanguageSupport.Translate(Properties.Resources.str_prog_name));
                return(false);
            }

            /* Set correct output units */
            fc.PostOptionsMill.SetIsInchOutputUnits(!Variables.doc.Metric);
            fc.PostOptionsTurn.SetIsInchOutputUnits(!Variables.doc.Metric);
            fc.PostOptionsWire.SetIsInchOutputUnits(!Variables.doc.Metric);

            /* If part is non-indexed, we can only generate NCSIMUL report for the active setup */
            if (Variables.stock.IndexType == tagFMIndexType.eIT_None)
            {
                Variables.doc.SaveNC("nc_program.iso", Variables.output_dirpath, false,
                                     FeatureCAM.tagFMSaveNCFileType.eNCFT_NCCode, false, out err_msg,
                                     out nc_files_num, out nc_file_names, out doc_files_num, out doc_file_names,
                                     out macro_files_num, out macro_file_names);
            }
            else if (Variables.stock.SingleProgram) /* We'll have NC code for one file */
            {
                Variables.doc.SaveNC("nc_program.iso", Variables.output_dirpath, false,
                                     FeatureCAM.tagFMSaveNCFileType.eNCFT_NCCode, false, out err_msg,
                                     out nc_files_num, out nc_file_names, out doc_files_num, out doc_file_names,
                                     out macro_files_num, out macro_file_names);
            }
            else
            {
                foreach (FMSetup setup in Variables.doc.Setups)
                {
                    if (setup.Enabled)
                    {
                        setup.Activate();
                        Variables.doc.SimToolpath(false);
                    }
                }
                Variables.doc.SaveNC("nc_program.iso", Variables.output_dirpath, false,
                                     FeatureCAM.tagFMSaveNCFileType.eNCFT_NCCode, false, out err_msg,
                                     out nc_files_num, out nc_file_names, out doc_files_num, out doc_file_names,
                                     out macro_files_num, out macro_file_names);
            }

            if (!Variables.is_single_program && Variables.stock.IndexType != tagFMIndexType.eIT_None)
            {
                if ((int)nc_files_num == Variables.num_enabled_setups)
                {
                    nc_file_id = 1;
                    for (int i = 0; i < Variables.setups_info.Count; i++)
                    {
                        if (Variables.setups_info[i].enabled && Variables.setups_info[i].num_features > 0)
                        {
                            Variables.setups_info[i].nc_fpath = (string)(((Array)nc_file_names).GetValue(nc_file_id));
                            Variables.output_msg += Variables.setups_info[i].nc_fpath + "\n";
                            nc_file_id++;
                        }
                    }
                }
            }
            else
            {
                if ((int)nc_files_num == 1)
                {
                    for (int i = 0; i < Variables.setups_info.Count; i++)
                    {
                        Variables.setups_info[i].nc_fpath = (string)(((Array)nc_file_names).GetValue(1));
                    }
                    Variables.output_msg += Variables.setups_info[0].nc_fpath + "\n";
                }
            }
            return(true);
        }
コード例 #13
0
        public static void Convert()
        {
            SetupInfo setup_info;
            string    tool_info      = "";
            string    ncdelcam_fpath = "";

            try
            {
                Variables.doc = (FeatureCAM.FMDocument)fc.ActiveDocument;

                if (Variables.stock.IndexType == tagFMIndexType.eIT_None)
                {
                    Variables.doc.Setups.Item(Variables.selected_setup_id + 1).Activate();
                    Variables.stock.SingleProgramWithProgramStop = false;
                }
                /* Verify that file is open */
                if (Variables.doc == null)
                {
                    MessageBox.Show(LanguageSupport.Translate(Properties.Resources.msg_no_open_files), LanguageSupport.Translate(Properties.Resources.str_prog_name));
                    return;
                }

                Variables.is_single_program =
                    (
                        (Variables.stock.IndexType == FeatureCAM.tagFMIndexType.eIT_None &&
                         Variables.stock.SingleProgramWithProgramStop)
                        ||
                        (Variables.stock.IndexType != FeatureCAM.tagFMIndexType.eIT_None &&
                         !Variables.stock.ToolDominant &&
                         Variables.stock.SingleProgram)
                        ||
                        (Variables.stock.IndexType != FeatureCAM.tagFMIndexType.eIT_None &&
                         Variables.stock.ToolDominant)
                    );


                Directory.CreateDirectory(Variables.output_dirpath);

                /* Initialize setup information (set enabled/disabled) */
                setup_info = null;
                foreach (FeatureCAM.FMSetup setup in Variables.doc.Setups)
                {
                    if (!Variables.is_single_program)
                    {
                        setup_info = new SetupInfo(setup);
                        if (Variables.setups_info == null)
                        {
                            Variables.setups_info = new List <SetupInfo>();
                        }
                        Variables.setups_info.Add(setup_info);
                        if (setup_info.enabled && setup_info.num_features > 0)
                        {
                            Variables.num_enabled_setups++;
                        }
                    }
                    else
                    {
                        if (setup_info == null)
                        {
                            setup_info      = new SetupInfo(setup);
                            setup_info.name = Variables.doc.Name + "_combined_setup";
                            if (Variables.setups_info == null)
                            {
                                Variables.setups_info = new List <SetupInfo>();
                            }
                            Variables.setups_info.Add(setup_info);
                        }
                        else
                        {
                            if (Variables.setups_info.Count == 1)
                            {
                                Variables.setups_info[0].ucss.Add(new UCS(setup.ucs));
                            }
                            else
                            {
                                MessageBox.Show(LanguageSupport.Translate(Properties.Resources.msg_failed_to_generate_setup_info) + "\n" + Variables.output_msg, LanguageSupport.Translate(Properties.Resources.str_prog_name));
                            }
                        }
                    }
                }

                if (!SaveNCCode())
                {
                    MessageBox.Show(LanguageSupport.Translate(Properties.Resources.msg_failed_to_save_nc), LanguageSupport.Translate(Properties.Resources.str_prog_name));
                    return;
                }

                tool_info = ToolsToXMLFile();

                StockToSolid();
                ClampsToSolids();

                /* Export projects file */
                Project_Manager.ConstructProjectFile(
                    Path.Combine(Variables.output_dirpath, "export.nxf"),
                    "Milling", Settings.ncsimul_md_fpath,
                    tool_info,
                    "", Variables.setups_info.Count);

                ncdelcam_fpath = GetNCDelcamPath();
                if (ncdelcam_fpath != "")
                {
                    Process proc = new Process();
                    proc.StartInfo.FileName  = "cmd.exe";
                    proc.StartInfo.Arguments = "/c call \"" + ncdelcam_fpath + "\"" +
                                               " " +
                                               "\"" + Path.Combine(Variables.output_dirpath, "export.nxf") + "\"";
                    proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                    proc.Start();
                }

                MessageBox.Show(LanguageSupport.Translate(Properties.Resources.msg_output_written_to) + "\n" + Variables.output_msg, LanguageSupport.Translate(Properties.Resources.str_prog_name));
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message, LanguageSupport.Translate(Properties.Resources.msg_exception_title));
            }
            finally
            {
                Variables.stock.SingleProgramWithProgramStop = Variables.orig_single_stock;
                Variables.Cleanup();
            }
        }