From 3f724959a8da89f9fa78bc2c91bd19a11fe40b96 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 22 Sep 2020 07:50:03 +0000 Subject: [PATCH] EgtExecutor 2.2i4 : - aggiunta funzione ExeAdvancedImport (per import IGES, STEP, ACIS, PARASOLID, JT e VRML) - piccole migliorie. --- EXE.h | 4 ++ EXE_Exchange.cpp | 109 +++++++++++++++++++++++++++++++++++++++++ EXE_General.cpp | 14 ++++++ EXE_NstPartNesting.cpp | 2 +- EgtExecutor.rc | Bin 16176 -> 16176 bytes LUA_General.cpp | 8 +-- 6 files changed, 133 insertions(+), 4 deletions(-) diff --git a/EXE.h b/EXE.h index 1a0b80c..56f0671 100644 --- a/EXE.h +++ b/EXE.h @@ -22,6 +22,10 @@ HWND ExeGetMainWindowHandle( void) ; //---------------------------------------------------------------------------- const std::string& ExeGetIniFile( void) ; +//---------------------------------------------------------------------------- +const std::string& ExeGetKey( void) ; +const std::string& ExeGetNestKey( void) ; + //---------------------------------------------------------------------------- ILogger* GetLogger( void) ; ILogger* GetCmdLogger( void) ; diff --git a/EXE_Exchange.cpp b/EXE_Exchange.cpp index e59bc7d..1c218a4 100644 --- a/EXE_Exchange.cpp +++ b/EXE_Exchange.cpp @@ -29,8 +29,11 @@ #include "/EgtDev/Include/EExExportDxf.h" #include "/EgtDev/Include/EExImportPnt.h" #include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EGnFileUtils.h" #include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtPointerOwner.h" +#include "/EgtDev/Include/EgtKeyCodes.h" +#include "/EgtDev/Include/SELkKeyProc.h" using namespace std ; @@ -70,6 +73,18 @@ ExeGetFileType( const string& sFilePath) return FT_PNT ; else if ( sFileExt == "SVG") return FT_SVG ; + else if ( sFileExt == "IGS" || sFileExt == "IGES") + return FT_IGES ; + else if ( sFileExt == "STP" || sFileExt == "STEP") + return FT_STEP ; + else if ( sFileExt == "SAT") + return FT_ACIS ; + else if ( sFileExt == "X_T" || sFileExt == "X_B") + return FT_PARASOLID ; + else if ( sFileExt == "JT") + return FT_JT ; + else if ( sFileExt == "WRL" || sFileExt == "WRZ") + return FT_VRML ; else if ( sFileExt == "TSC") return FT_TSC ; else if ( sFileExt == "LUA") @@ -258,6 +273,100 @@ ExeImportStl( const string& sFilePath, double dScaleFactor) return bOk ; } +//----------------------------------------------------------------------------- +bool +ExeAdvancedImport( const string& sFilePath) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, false) + bool bOk = true ; + // verifico che il formato sia supportato + int nFileType = ExeGetFileType( sFilePath) ; + if ( nFileType != FT_IGES && + nFileType != FT_STEP && + nFileType != FT_ACIS && + nFileType != FT_PARASOLID && + nFileType != FT_JT && + nFileType != FT_VRML) { + string sOut = "Error unknown format " + sFilePath ; + LOG_ERROR( GetLogger(), sOut.c_str()) + return false ; + } + // verifico la chiave e le opzioni per l'import avanzato + unsigned int nOpt1, nOpt2 ; + int nOptExpDays ; + int nRet = GetKeyOptions( ExeGetKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, + nOpt1, nOpt2, nOptExpDays) ; + if ( nRet != KEY_OK) { + std::string sErr = "Error on Key (EXA/" + ToString( nRet) + ")" ; + LOG_ERROR( GetLogger(), sErr.c_str()) ; + return false ; + } + if ( ( nOpt1 & ( KEYOPT_EEX_INPADV)) == 0 || + nOptExpDays < GetCurrDay()) { + std::string sErr = "Warning on Key (EXA/OPT)" ; + LOG_ERROR( GetLogger(), sErr.c_str()) ; + return false ; + } + // file intermedio stl + string sTempDir ; ExeGetTempDir( sTempDir) ; + string sFileOut = sTempDir + "\\AdvImp.stl" ; + EraseFile( sFileOut) ; + // eseguo il programma esterno di conversione + string sExec ; + #if defined( _WIN64) + sExec = "EgtConverterR64.exe" ; + #elif defined( _WIN32) + sExec = "EgtConverterR32.exe" ; + #endif + string sCmdLine = "\"" + sExec + "\" \"" + sFilePath + "\" \"" + sFileOut + "\"" ; + STARTUPINFO si ; + PROCESS_INFORMATION pi ; + ZeroMemory( &si, sizeof( si)) ; + si.cb = sizeof( si) ; + si.dwFlags = STARTF_USESHOWWINDOW ; + si.wShowWindow = SW_HIDE ; + ZeroMemory( &pi, sizeof( pi)) ; + if ( CreateProcess( NULL, stringtoW( sCmdLine), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) == FALSE) + return false ; + int nTime = 0 ; + while ( bOk) { + ++ nTime ; + nTime = ( nTime % 200) ; + if ( ExeProcessEvents( int( nTime / 200.0 * 100), 100) == 1) + bOk = false ; + if ( WaitForSingleObject( pi.hProcess, 100) != WAIT_TIMEOUT) + break ; + } + DWORD nExitCode = 99 ; + GetExitCodeProcess( pi.hProcess, &nExitCode) ; + bOk = bOk && ( nExitCode == 0) ; + CloseHandle( pi.hProcess) ; + CloseHandle( pi.hThread) ; + // importo il file STL + // aggiungo un gruppo pezzo e un gruppo layer + int nPartId = ( bOk ? pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) : GDB_ID_NULL) ; + int nLayerId = ( bOk ? pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) : GDB_ID_NULL) ; + // preparo l'importatore + PtrOwner pImpStl( MyCreateImportStl()) ; + bOk = bOk && ! IsNull( pImpStl) ; + // eseguo l'importazione + bOk = bOk && pImpStl->Import( sFileOut, pGseCtx->m_pGeomDB, nLayerId, 1) ; + ExeProcessEvents( 100, 0) ; + // aggiorno stato file corrente + if ( bOk && pGseCtx->m_sFilePath.empty()) + pGseCtx->m_sFilePath = sFilePath ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtAdvancedImport('" + StringToLuaString( sFilePath) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} + //----------------------------------------------------------------------------- bool ExeExportDxf( int nId, const string& sFilePath) diff --git a/EXE_General.cpp b/EXE_General.cpp index 6be6a6f..b346d80 100644 --- a/EXE_General.cpp +++ b/EXE_General.cpp @@ -202,6 +202,13 @@ ExeSetKey( const string& sKey) return true ; } +//----------------------------------------------------------------------------- +const string& +ExeGetKey( void) +{ + return s_sKey ; +} + //----------------------------------------------------------------------------- bool ExeSetNestKey( const string& sNestKey) @@ -210,6 +217,13 @@ ExeSetNestKey( const string& sNestKey) return true ; } +//----------------------------------------------------------------------------- +const string& +ExeGetNestKey( void) +{ + return s_sNestKey ; +} + //----------------------------------------------------------------------------- bool ExeSetLockType( int nType) diff --git a/EXE_NstPartNesting.cpp b/EXE_NstPartNesting.cpp index b1ac4bd..ee405a2 100644 --- a/EXE_NstPartNesting.cpp +++ b/EXE_NstPartNesting.cpp @@ -2193,7 +2193,7 @@ ExeAutomaticPackParts( INTVECTOR& vIds, bool bMinimizeOnXvsY, bool bReducedCut, if ( nStat == 3) break ; nTime += 1 ; - if ( ExeProcessEvents( nTime / nMaxTime * 100, 995) == 1) { + if ( ExeProcessEvents( int( 1.0 * nTime / nMaxTime * 100), 995) == 1) { bOk = ExeAutoNestCancelComputation() ; break ; } diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 75b22ed6f42ce09e2244534e618ea43fa9f4c09d..f69159da224836ccfd80d23d9d06a4ddf16b9f39 100644 GIT binary patch delta 79 zcmdl`x1nysFE&P#&A-`PnSqoe*K!sx?>N)s4T4pSCX*exk~jAW*?>e(i-FY$N+HxV MD8kglDP58Q0DHq5YXATM delta 79 zcmdl`x1nysFE&Qw&A-`PnSqoe*K!sx?>N)s4T4pS#*-bnk~jAW*?>e(i-FY$N+HxV MD8kglDP58Q0D5;DV*mgE diff --git a/LUA_General.cpp b/LUA_General.cpp index bc85101..8c640ec 100644 --- a/LUA_General.cpp +++ b/LUA_General.cpp @@ -840,10 +840,12 @@ LuaWinExec( lua_State* L) // mando in esecuzione la linea di comando STARTUPINFO si ; PROCESS_INFORMATION pi ; - ZeroMemory( &si, sizeof(si)) ; - si.cb = sizeof(si) ; - ZeroMemory( &pi, sizeof(pi)) ; + ZeroMemory( &si, sizeof( si)) ; + si.cb = sizeof( si) ; + ZeroMemory( &pi, sizeof( pi)) ; bool bOk = ( CreateProcess( NULL, stringtoW( sCmdLine), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) != FALSE) ; + CloseHandle( pi.hProcess) ; + CloseHandle( pi.hThread) ; // restituisco il risultato LuaSetParam( L, bOk) ; return 1 ;