diff --git a/EXE_GdbObjects.cpp b/EXE_GdbObjects.cpp index 63a8872..2af43a7 100644 --- a/EXE_GdbObjects.cpp +++ b/EXE_GdbObjects.cpp @@ -219,6 +219,25 @@ ExeGetPrevName( int nId, const string& sName) return pGeomDB->GetPrevName( nId, sName) ; } +//----------------------------------------------------------------------------- +bool +ExeGetInfoInGroup( int nGroupId, const string& sKey, INTVECTOR& vIds) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + if ( ! pGeomDB->ExistsObj( nGroupId)) + return false ; + // recupero gli oggetti con l'info desiderata + vIds.clear() ; + int nId = pGeomDB->GetFirstInGroup( nGroupId) ; + while ( nId != GDB_ID_NULL) { + if ( pGeomDB->ExistsInfo( nId, sKey)) + vIds.push_back( nId) ; + nId = pGeomDB->GetNext( nId) ; + } + return true ; +} + //----------------------------------------------------------------------------- bool ExeGetBBox( int nId, int nFlag, BBox3d& b3Box) diff --git a/LUA_GdbObjects.cpp b/LUA_GdbObjects.cpp index 1c132d7..e845d03 100644 --- a/LUA_GdbObjects.cpp +++ b/LUA_GdbObjects.cpp @@ -313,6 +313,27 @@ LuaGetPrevName( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaGetInfoInGroup( lua_State* L) +{ + // 2 parametri : GroupId, sKey + int nGroupId = GDB_ID_NULL ; + LuaGetParam( L, 1, nGroupId) ; + string sKey ; + LuaGetParam( L, 2, sKey) ; + LuaClearStack( L) ; + // recupero tutti gli oggetti con l'info richiesta + INTVECTOR vIds ; + bool bOk = ExeGetInfoInGroup( nGroupId, sKey, vIds) ; + // restituisco il risultato + if ( bOk && ! vIds.empty()) + LuaSetParam( L, vIds) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaGetFirstGroupInGroup( lua_State* L) @@ -637,6 +658,7 @@ LuaInstallGdbObjects( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtGetNextName", LuaGetNextName) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetLastNameInGroup", LuaGetLastNameInGroup) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetPrevName", LuaGetPrevName) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetInfoInGroup", LuaGetInfoInGroup) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetFirstGroupInGroup", LuaGetFirstGroupInGroup) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetNextGroup", LuaGetNextGroup) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetLastGroupInGroup", LuaGetLastGroupInGroup) ;