EgtExecutor 2.2i4 :

- aggiunta funzione ExeAdvancedImport (per import IGES, STEP, ACIS, PARASOLID, JT e VRML)
- piccole migliorie.
This commit is contained in:
Dario Sassi
2020-09-22 07:50:03 +00:00
parent 02470abc0c
commit 3f724959a8
6 changed files with 133 additions and 4 deletions
+4
View File
@@ -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) ;
+109
View File
@@ -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<IImportStl> 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)
+14
View File
@@ -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)
+1 -1
View File
@@ -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 ;
}
BIN
View File
Binary file not shown.
+5 -3
View File
@@ -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 ;