28d676555e
- modifiche per import BTL.
155 lines
4.6 KiB
C++
155 lines
4.6 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2014
|
|
//----------------------------------------------------------------------------
|
|
// File : LUA_Exchange.cpp Data : 29.09.14 Versione : 1.5i5
|
|
// Contenuto : Funzioni di import/export per LUA.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 29.09.14 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "LUA.h"
|
|
#include "/EgtDev/Include/EXeExecutor.h"
|
|
#include "/EgtDev/Include/EXeConst.h"
|
|
#include "/EgtDev/Include/EGkLuaAux.h"
|
|
#include "/EgtDev/Include/EgnStringUtils.h"
|
|
|
|
using namespace std ;
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaImportDxf( lua_State* L)
|
|
{
|
|
// 1 o 2 parametri : path del file da importare [, Fattore di scala]
|
|
string sFilePath ;
|
|
LuaCheckParam( L, 1, sFilePath)
|
|
double dScaleFactor = 1.0 ;
|
|
LuaGetParam( L, 2, dScaleFactor) ;
|
|
LuaClearStack( L) ;
|
|
// apro il file
|
|
bool bOk = ExeImportDxf( sFilePath, dScaleFactor) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaImportStl( lua_State* L)
|
|
{
|
|
// 1 o 2 parametri : path del file da importare [, Fattore di scala]
|
|
string sFilePath ;
|
|
LuaCheckParam( L, 1, sFilePath)
|
|
double dScaleFactor = 1.0 ;
|
|
LuaGetParam( L, 2, dScaleFactor) ;
|
|
LuaClearStack( L) ;
|
|
// apro il file
|
|
bool bOk = ExeImportStl( sFilePath, dScaleFactor) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaImportCnc( lua_State* L)
|
|
{
|
|
// 1 o 2 parametri : FilePath [, Flag]
|
|
string sFilePath ;
|
|
LuaCheckParam( L, 1, sFilePath)
|
|
int nFlag = EIC_FLAG_NONE ;
|
|
LuaGetParam( L, 2, nFlag) ;
|
|
LuaClearStack( L) ;
|
|
// apro il file
|
|
bool bOk = ExeImportCnc( sFilePath, nFlag) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaImportCsf( lua_State* L)
|
|
{
|
|
// 1 parametro : path del file da importare
|
|
string sFilePath ;
|
|
LuaCheckParam( L, 1, sFilePath)
|
|
LuaClearStack( L) ;
|
|
// apro il file
|
|
bool bOk = ExeImportCsf( sFilePath) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaImportBtl( lua_State* L)
|
|
{
|
|
// 1 o 2 : FilePath [, Flag]
|
|
string sFilePath ;
|
|
LuaCheckParam( L, 1, sFilePath)
|
|
int nFlag = EIB_FLAG_NONE ;
|
|
LuaGetParam( L, 2, nFlag) ;
|
|
LuaClearStack( L) ;
|
|
// apro il file
|
|
bool bOk = ExeImportBtl( sFilePath, nFlag) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaExportDxf( lua_State* L)
|
|
{
|
|
// 2 parametri, GroupId e path del file da esportare
|
|
int nGroupId ;
|
|
LuaCheckParam( L, 1, nGroupId)
|
|
string sFilePath ;
|
|
LuaCheckParam( L, 2, sFilePath)
|
|
LuaClearStack( L) ;
|
|
// apro il file
|
|
bool bOk = ExeExportDxf( nGroupId, sFilePath) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaExportStl( lua_State* L)
|
|
{
|
|
// 2 parametri, GroupId e path del file da esportare
|
|
int nGroupId ;
|
|
LuaCheckParam( L, 1, nGroupId)
|
|
string sFilePath ;
|
|
LuaCheckParam( L, 2, sFilePath)
|
|
LuaClearStack( L) ;
|
|
// apro il file
|
|
bool bOk = ExeExportStl( nGroupId, sFilePath) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
bool
|
|
LuaInstallExchange( LuaMgr& luaMgr)
|
|
{
|
|
bool bOk = ( &luaMgr != nullptr) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtImportDxf", LuaImportDxf) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtImportStl", LuaImportStl) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtImportCnc", LuaImportCnc) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtImportCsf", LuaImportCsf) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtImportBtl", LuaImportBtl) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtExportDxf", LuaExportDxf) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtExportStl", LuaExportStl) ;
|
|
return bOk ;
|
|
}
|