diff --git a/API.h b/API.h index b6cdb2d..798359d 100644 --- a/API.h +++ b/API.h @@ -36,6 +36,7 @@ bool EgtGetCurrFilePath( std::string& sFilePath) ; bool EgtOpenFile( const std::string& sFilePath) ; bool EgtInsertFile( const std::string& sFilePath) ; bool EgtSaveFile( const std::string& sFilePath, int nFlag) ; +bool EgtSaveObjToFile( int nId, const std::string& sFilePath, int nFlag) ; //--------------------------- GeomDBCreate ----------------------------------- int EgtCreateText( int nParentId, const Point3d& ptP, double dAngRotDeg, diff --git a/API_GeomDB.cpp b/API_GeomDB.cpp index 21df71c..57e1f8a 100644 --- a/API_GeomDB.cpp +++ b/API_GeomDB.cpp @@ -400,7 +400,7 @@ EgtSaveFile( const string& sFilePath, int nFlag) int nCurrMachGroup = EgtGetCurrMachGroup() ; EgtResetCurrMachGroup() ; // salvo il file - bool bOk = pGseCtx->m_pGeomDB->Save( sFilePath, nFlag) ; + bool bOk = pGseCtx->m_pGeomDB->Save( GDB_ID_ROOT, sFilePath, nFlag) ; // eventuale ripristino precedente CAM if ( nCurrMachGroup != GDB_ID_NULL) EgtSetCurrMachGroup( nCurrMachGroup) ; @@ -420,3 +420,38 @@ EgtSaveFile( const string& sFilePath, int nFlag) // restituisco il risultato return bOk ; } + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSaveObjToFile( int nId, const wchar_t* wsFilePath, int nFlag) +{ + return ( EgtSaveObjToFile( nId, wstrztoA( wsFilePath), nFlag) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +bool +EgtSaveObjToFile( int nId, const string& sFilePath, int nFlag) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // se ero in CAM, esco + int nCurrMachGroup = EgtGetCurrMachGroup() ; + EgtResetCurrMachGroup() ; + // copio l'oggetto nel file + bool bOk = pGeomDB->Save( nId, sFilePath, nFlag) ; + // ripristino eventuale precedente CAM + if ( nCurrMachGroup != GDB_ID_NULL) + EgtSetCurrMachGroup( nCurrMachGroup) ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLuaPath = sFilePath ; + ReplaceString( sLuaPath, "\\", "\\\\") ; + string sLua = "EgtSaveObjToFile('" + sLuaPath + "'," + + ToString( nId) + "," + + NgeTypeToString( nFlag) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} diff --git a/EgtInterface.rc b/EgtInterface.rc index 56b0432..d1daf54 100644 Binary files a/EgtInterface.rc and b/EgtInterface.rc differ diff --git a/LUA_GeomDB.cpp b/LUA_GeomDB.cpp index d9a9428..6a4b9c0 100644 --- a/LUA_GeomDB.cpp +++ b/LUA_GeomDB.cpp @@ -152,6 +152,25 @@ LuaSaveFile( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaSaveObjToFile( lua_State* L) +{ + // 2 o 3 parametri : nId, path del file [, flag] + int nId ; + LuaCheckParam( L, 1, nId) + string sFilePath ; + LuaCheckParam( L, 2, sFilePath) + int nFlag = GDB_SV_CMPTXT ; + LuaGetParam( L, 3, nFlag) ; + LuaClearStack( L) ; + // copio il gruppo nel file + bool bOk = EgtSaveObjToFile( nId, sFilePath, nFlag) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- bool LuaInstallGeomDB( void) @@ -165,5 +184,6 @@ LuaInstallGeomDB( void) bOk = bOk && LuaRegisterFunction( "EgtOpenFile", LuaOpenFile) ; bOk = bOk && LuaRegisterFunction( "EgtInsertFile", LuaInsertFile) ; bOk = bOk && LuaRegisterFunction( "EgtSaveFile", LuaSaveFile) ; + bOk = bOk && LuaRegisterFunction( "EgtSaveObjToFile", LuaSaveObjToFile) ; return bOk ; }