From 758245f4fc79339c6235439902c9990a11acdadb Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 30 Apr 2015 20:42:52 +0000 Subject: [PATCH] EgtInterface 1.6d6 : - aggiunta EgtSaveObjToFile a API e Lua. --- API.h | 1 + API_GeomDB.cpp | 37 ++++++++++++++++++++++++++++++++++++- EgtInterface.rc | Bin 11718 -> 11718 bytes LUA_GeomDB.cpp | 20 ++++++++++++++++++++ 4 files changed, 57 insertions(+), 1 deletion(-) 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 56b0432dcf716c4a109905561af1f06f785c6279..d1daf54eb9b6ac2fe45230b8c8f16a2d0dd96e1b 100644 GIT binary patch delta 111 zcmX>WeJpyzFE&QA%^&$rGEF|hS;uHL`Jtfh<^rw;7OzIAO+TQQ4Xt~E@c}o08Rra&Hw-a delta 111 zcmX>WeJpyzFE&Qg%^&$rGEF|hS;uHP`Jtfh<^rw;7OzIAO+TQQ4Xt~E@c}o08AGs#sB~S 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 ; }