From fb66d208893a8cac017fc03cb60072bdf7f67be9 Mon Sep 17 00:00:00 2001 From: Nicogene Date: Fri, 5 Apr 2024 12:52:13 +0200 Subject: [PATCH] First working version --- src/creo2urdf/src/main.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/creo2urdf/src/main.cpp b/src/creo2urdf/src/main.cpp index 2ed11f4..7cf3514 100644 --- a/src/creo2urdf/src/main.cpp +++ b/src/creo2urdf/src/main.cpp @@ -10,6 +10,7 @@ #include #include #include +#include /*! @brief Do batch mode stuff @@ -26,13 +27,18 @@ ProError evaluateBatchMode(const std::string& asm_path, const std::string& yaml_ return PRO_TK_GENERAL_ERROR; } - auto asm_model_ptr = session->RetrieveModel(pfcModelDescriptor::CreateFromFileName(asm_path.c_str())); + pfcModel_ptr asm_model_ptr{ nullptr }; - if (!asm_model_ptr) { - ProTKPrintf("Creo2Urdf: impossible to retrieve the model located in %s", asm_path); - return PRO_TK_GENERAL_ERROR; + try { + asm_model_ptr = session->RetrieveModel(pfcModelDescriptor::CreateFromFileName(asm_path.c_str())); } - + xcatchbegin + xcatchcip(defaultEx) + { + ProTKPrintf("Exception caught: %s", pfcXPFC::cast(defaultEx)->GetMessage()); + return PRO_TK_E_NOT_FOUND; + } + xcatchend Creo2Urdf creo2urdfApp(yaml_path, csv_path, output_path, asm_model_ptr); creo2urdfApp.OnCommand(); @@ -58,6 +64,16 @@ extern "C" int user_initialize( std::string yaml_path = argv[2]; std::string csv_path = argv[3]; std::string output_path = argv[4]; + + // We need to remove the '+' character from the paths + asm_path.erase(std::find(asm_path.begin(), asm_path.end(), '+')); + yaml_path.erase(std::find(yaml_path.begin(), yaml_path.end(), '+')); + csv_path.erase(std::find(csv_path.begin(), csv_path.end(), '+')); + output_path.erase(std::find(output_path.begin(), output_path.end(), '+')); + + ProTKPrintf("Running in batch mode"); + auto debug_msg = "Assembly path: " + asm_path + " yaml path " + yaml_path + " csv_path " + csv_path + " output_path " + output_path; + ProTKPrintf("%s\n", debug_msg.c_str()); ProError err = evaluateBatchMode(asm_path, yaml_path, csv_path, output_path); ProEngineerEnd(); return (int)err; // or whatever you want