/* 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) { } }
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); } }