コード例 #1
0
        /* machine_type = LATHE or MILLING */
        public static void LoadProjectToEureka(string stock_fpath, string tdb_fpath, string project_fpath)
        {
            string fcontent = "";
            string new_template_path;

            try
            {
                Variables.eureka_app = FCToEUREKA.StartEUREKA();
                Directory.CreateDirectory(Variables.output_dirpath);
                new_template_path     = Path.Combine(Variables.output_dirpath, Path.GetFileName(Variables.eureka_template_fpath));
                Variables.eureka_proj = (Eureka.Project)Variables.eureka_app.OpenProject(Variables.eureka_template_fpath, true, true);
                if (Variables.eureka_proj.GetControllerCount() == 0)
                {
                    MessageBox.Show(
                        "Failed to load data into EUREKA project. Selected project should have at least 1 controller.",
                        Variables.prog_name,
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                Variables.eureka_proj.Units = (Variables.doc.Metric ? 0 : 1);
                Variables.eureka_proj.SelectProgramFile(Variables.setups_info[0].nc_fpath, 0, "");
                Eureka.Controller controller = (Eureka.Controller)Variables.eureka_proj.GetControllerByIndex(0);
                /* Setup information */
                GetNCCodeInfo(controller);

                string workpieceID = Variables.eureka_proj.GetWorkPieceID(0);

                Variables.eureka_proj.RemoveShape(workpieceID + ".*");
                LoadStockInfo(stock_fpath, workpieceID);

                Eureka.ToolLibrary tool_lib = (Eureka.ToolLibrary)((Eureka.Machine)controller.Machine).ToolLibrary;
                tool_lib.FilePath = tdb_fpath;
                tool_lib.ReadFromFile(tdb_fpath, null);

                Variables.eureka_app.Refresh();
                Variables.eureka_app.ActiveProject().SaveAs(project_fpath);

                /* Stock identification */


                /* Clamps information */
                fcontent += GetClampsInfo();

                /* Tool information */
                fcontent += tdb_fpath;

                /* Save result */
                fcontent += "BEGIN_SAVE_STOCK" + Lib.EOL +
                            "  |1|NCMAC|" + "saved_" + Path.GetFileName(Variables.output_dirpath) + "|" + Lib.EOL +
                            "END";
            }
            catch (Exception Ex)
            { }
        }
コード例 #2
0
        private void b_export_Click(object sender, EventArgs e)
        {
            if (Variables.output_dirpath == "")
            {
                MessageBox.Show(
                    "Output directory path must be set. Please fix it and try again.",
                    Variables.prog_name,
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (Variables.eureka_template_fpath.Trim() != "")
            {
                if (!File.Exists(Variables.eureka_template_fpath))
                {
                    MessageBox.Show(
                        "If EUREKA machine file path is set, file must exist. File " + Variables.eureka_template_fpath + " doesn't exist. Please select existing file and try again.",
                        Variables.prog_name,
                        MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }
            }
            foreach (SolidInfo solid_info in Variables.clamps)
            {
                solid_info.is_export = false;
            }
            if (Variables.clamps != null)
            {
                foreach (string item in clb_solids_to_export.CheckedItems)
                {
                    foreach (SolidInfo solid_info in Variables.clamps)
                    {
                        if (solid_info.solid.Name.Equals(item, StringComparison.OrdinalIgnoreCase))
                        {
                            solid_info.is_export = true;
                        }
                    }
                }
            }
            this.Close();
            if (Variables.offset_pt != null)
            {
                Variables.offset_pt.Delete(false);
            }

            FCToEUREKA.Convert();
        }
コード例 #3
0
        private static void InitializeVariables()
        {
            FeatureCAM.FMSetup setup      = null;
            Eureka.Application eureka_app = null;
            string             eureka_template_name;

            Variables.eureka_path = FCToEUREKA.GetEUREKAPath();
            if (Variables.eureka_template_files_dir == "")
            {
                eureka_app = FCToEUREKA.StartEUREKA();
                if (eureka_app != null)
                {
                    Variables.eureka_template_files_dir = eureka_app.TemplateDirectory;
                    eureka_app.Quit();
                    eureka_app = null;
                }
            }

            if (fc != null)
            {
                Variables.doc = (FeatureCAM.FMDocument)fc.ActiveDocument;
            }
            if (Variables.doc == null)
            {
                Variables.prev_doc_name  = "";
                Variables.output_dirpath = "";
            }
            else
            {
                Variables.stock       = Variables.doc.Stock;
                Variables.setup_names = new List <string>();
                for (int i = 1; i <= Variables.doc.Setups.Count; i++)
                {
                    setup = (FeatureCAM.FMSetup)Variables.doc.Setups.Item(i);
                    if (setup != null)
                    {
                        Variables.setup_names.Add(setup.Name);
                        /* Have to subtract 1 b/c setups are 1-based and combobox values are 0-based */
                        if (Variables.doc.ActiveSetup.Name == setup.Name)
                        {
                            Variables.selected_setup_id = i - 1;
                        }
                    }
                }
                if (Variables.stock.IndexType != FeatureCAM.tagFMIndexType.eIT_None)
                {
                    Variables.output_dirpath = Path.Combine(Variables.doc.path, Variables.doc.PartName);
                }
                else
                {
                    Variables.output_dirpath = Path.Combine(Variables.doc.path, Variables.doc.PartName) + "_" + Variables.setup_names[Variables.selected_setup_id];
                }

                Variables.orig_single_stock = Variables.stock.SingleProgramWithProgramStop;
                if (Variables.prev_doc_name != Variables.doc.Name)
                {
                    Variables.clamps = new List <SolidInfo>();
                    foreach (FeatureCAM.FMSolid solid in Variables.doc.Solids)
                    {
                        Variables.clamps.Add(new SolidInfo(solid, false));
                    }
                }
                Variables.doc.ActiveSetup.GetMachineSimLocation(out Variables.offset_x, out Variables.offset_y, out Variables.offset_z);
            }
        }