e1c303a5c6
- corretta gestione altezza taglio finale per tagli senza impostazione ultimo step.
243 lines
11 KiB
Lua
243 lines
11 KiB
Lua
-- 2023/05/18 09:30:00
|
|
-- Programma per Lucidatura in OmagCut
|
|
-- Legenda codici errore (POLI.ERR) :
|
|
-- 0 = tutto bene
|
|
-- 10 = manca il grezzo
|
|
-- 20 = manca il kit
|
|
-- 30 = manca il contorno dell'area
|
|
-- 40 = kit vuoto o errore nella sua lettura
|
|
-- 50 = errore nel calcolo della lavorazione
|
|
|
|
-- Intestazioni
|
|
require( 'EgtBase')
|
|
_ENV = EgtProtectGlobal()
|
|
EgtEnableDebug( false)
|
|
|
|
-- Versione
|
|
local POLISHING_VER = 'ver 2.5e1'
|
|
|
|
-- Recupero il grezzo
|
|
local nRawId = EgtGetFirstRawPart()
|
|
if not nRawId then
|
|
POLI.ERR = 10
|
|
return
|
|
end
|
|
|
|
-- Recupero la path del file dei kits
|
|
local sKitPath = EgtGetCurrMachineDir() .. '\\Machinings\\Kits.data'
|
|
-- Determinazioni da Ini di macchina
|
|
local sMachIni = EgtGetCurrMachineDir() .. '\\' .. EgtGetCurrMachineName() .. '.ini'
|
|
-- Se fresa e foretto devono lavorare con C=90deg (tavola 1 C90, tavola 2 C-90),
|
|
local nPolishingC90 = tonumber( EgtGetStringFromIni( 'Nest', 'PolishingC90', '0', sMachIni))
|
|
-- Reset stato di errore
|
|
POLI.ERR = 0
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- Funzione locale per lettura di una lavorazione del kit
|
|
local function ReadMachKit( sSect, nMachInd)
|
|
local sKeyInd = string.format( '%02d', nMachInd or 0)
|
|
local sTuuid = EgtGetStringFromIni( sSect, sKeyInd .. '.Tool', '', sKitPath)
|
|
local sTname = EgtGetStringFromIni( sSect, sKeyInd .. '.ToolName', '', sKitPath)
|
|
if #sTuuid == 0 or #sTname == 0 then return nil end
|
|
local bActive = ( tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.Active', '', sKitPath) or 0) ~= 0)
|
|
local nCnt = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.Contour', '', sKitPath) or 0)
|
|
local dOffCnt = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.OffContour', '', sKitPath) or 0)
|
|
local nZzX = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.ZigZagX', '', sKitPath) or 0)
|
|
local dOffZzX = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.OffZigZagX', '', sKitPath) or 0)
|
|
local dStepX = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.StepX', '', sKitPath) or 0)
|
|
local dRadiusX = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.RadiusX', '', sKitPath) or 0)
|
|
local dDistanceX = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.DistanceX', '', sKitPath) or 0)
|
|
local nZzY = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.ZigZagY', '', sKitPath) or 0)
|
|
local dOffZzY = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.OffZigZagY', '', sKitPath) or 0)
|
|
local dStepY = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.StepY', '', sKitPath) or 0)
|
|
local dRadiusY = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.RadiusY', '', sKitPath) or 0)
|
|
local dDistanceY = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.DistanceY', '', sKitPath) or 0)
|
|
|
|
local nSpiral = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.Spiral', '', sKitPath) or 0)
|
|
local dOffSpiral = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.OffSpiral', '', sKitPath) or 0)
|
|
local dStepSpiral = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.StepSpiral', '', sKitPath) or 0)
|
|
local dRadiusSpiral = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.RadiusSpiral', '', sKitPath) or 0)
|
|
local dDistanceSpiral = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.DistanceSpiral', '', sKitPath) or 0)
|
|
|
|
local dLiLen = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.LiLen', '', sKitPath) or 0)
|
|
local dLiHei = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.LiHeight', '', sKitPath) or 0)
|
|
local dLiLoad = tonumber( EgtGetStringFromIni( sSect, sKeyInd .. '.LiLoad', '', sKitPath) or 0)
|
|
return { Tuuid=sTuuid, Tname=sTname, Act=bActive, Cnt=nCnt, OffCnt=-dOffCnt, ZigZagX=nZzX, OffZigZagX=-dOffZzX, StepX=dStepX, ZigZagY=nZzY, OffZigZagY=-dOffZzY,StepY=dStepY,
|
|
Spiral=nSpiral, OffSpiral=-dOffSpiral, StepSpiral=dStepSpiral, RadiusSpiral=dRadiusSpiral, DistanceSpiral=dDistanceSpiral, LiLen=dLiLen, LiHeight=dLiHei, LiLoad=dLiLoad}
|
|
end
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- Funzione locale per lettura del kit
|
|
local function ReadKit( sKitName)
|
|
local kCurr = {}
|
|
local sSect = 'Kit.' .. sKitName
|
|
for nMachInd = 1, 50 do
|
|
local mkCurr = ReadMachKit( sSect, nMachInd)
|
|
if mkCurr then
|
|
table.insert( kCurr, mkCurr)
|
|
else
|
|
break
|
|
end
|
|
end
|
|
return kCurr
|
|
end
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- Funzione per aggiungere le lucidature
|
|
function POLI.Add()
|
|
|
|
-- Recupero il kit
|
|
local sKitName = POLI.KITNAME
|
|
if not sKitName or sKitName == '' then
|
|
POLI.ERR = 20
|
|
return
|
|
end
|
|
|
|
-- Recupero il contorno dell'area da lucidare
|
|
local nCntId = POLI.CNTID
|
|
if not EgtExistsObj( nCntId) then
|
|
POLI.ERR = 30
|
|
return
|
|
end
|
|
|
|
-- Leggo i dati del kit
|
|
local kCurr = ReadKit( sKitName)
|
|
if #kCurr == 0 then
|
|
POLI.ERR = 40
|
|
return
|
|
end
|
|
|
|
-- Applico le lavorazioni
|
|
local bOk = true
|
|
for i = 1, #kCurr do
|
|
-- se attivo
|
|
if kCurr[i].Act then
|
|
-- contornatura
|
|
if kCurr[i].Cnt > 0 then
|
|
EgtCreateMachining( 'Cont_'..kCurr[i].Tname, MCH_MY.MILLING, kCurr[i].Tname)
|
|
EgtSetMachiningParam( MCH_MP.USERNOTES , 'Polishing')
|
|
EgtSetMachiningParam( MCH_MP.STARTPOS, 10)
|
|
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
|
EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.GLIDE)
|
|
EgtSetMachiningParam( MCH_MP.LITANG, kCurr[i].LiLen)
|
|
EgtSetMachiningParam( MCH_MP.LIELEV, kCurr[i].LiHeight)
|
|
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.AS_LI)
|
|
EgtSetMachiningParam( MCH_MP.OFFSR, kCurr[i].OffCnt)
|
|
-- se richiesto un solo giro
|
|
if kCurr[i].Cnt == 1 then
|
|
EgtSetMachiningParam( MCH_MP.DEPTH, kCurr[i].LiLoad)
|
|
-- altrimenti più giri con step di discesa trascurabile
|
|
else
|
|
local dStep = 0.002
|
|
local dAddDepth = kCurr[i].Cnt * dStep
|
|
local sUserNotes = 'Polishing;MaxElev=' .. EgtNumToString( dAddDepth, 3) .. ';'
|
|
EgtSetMachiningParam( MCH_MP.DEPTH, kCurr[i].LiLoad + dAddDepth)
|
|
EgtSetMachiningParam( MCH_MP.STEP, dStep)
|
|
EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes)
|
|
EgtSetMachiningParam( MCH_MP.STEPTYPE, MCH_MILL_ST.SPIRAL)
|
|
end
|
|
local AngC = "C=" .. EgtNumToString(90*nPolishingC90,0)
|
|
EgtSetMachiningParam( MCH_MP.INITANGS, AngC)
|
|
EgtSetMachiningGeometry( {nCntId})
|
|
if not EgtApplyMachining() then
|
|
bOk = false
|
|
end
|
|
end
|
|
-- svuotature in X
|
|
for j = 1, kCurr[i].ZigZagX do
|
|
EgtCreateMachining( 'ZigZagX_'..kCurr[i].Tname, MCH_MY.POCKETING, kCurr[i].Tname)
|
|
EgtSetMachiningParam( MCH_MP.USERNOTES , 'Polishing')
|
|
EgtSetMachiningParam( MCH_MP.STARTPOS, 10)
|
|
EgtSetMachiningParam( MCH_MP.DEPTH, kCurr[i].LiLoad)
|
|
EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.ZIGZAG)
|
|
EgtSetMachiningParam( MCH_MP.SIDESTEP, kCurr[i].StepX)
|
|
EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_POCK_LI.GLIDE)
|
|
EgtSetMachiningParam( MCH_MP.LITANG, kCurr[i].LiLen)
|
|
EgtSetMachiningParam( MCH_MP.LIELEV, kCurr[i].LiHeight)
|
|
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_POCK_LO.GLIDE)
|
|
EgtSetMachiningParam( MCH_MP.LOTANG, kCurr[i].LiLen)
|
|
EgtSetMachiningParam( MCH_MP.LOELEV, kCurr[i].LiHeight)
|
|
EgtSetMachiningParam( MCH_MP.OFFSR, kCurr[i].OffZigZagX)
|
|
EgtSetMachiningParam( MCH_MP.INVERT, (( j % 2) == 0))
|
|
local AngC = "C=" .. EgtNumToString(90*nPolishingC90,0)
|
|
EgtSetMachiningParam( MCH_MP.INITANGS, AngC)
|
|
EgtSetMachiningGeometry( {nCntId})
|
|
if not EgtApplyMachining() then
|
|
bOk = false
|
|
end
|
|
end
|
|
-- svuotature in Y
|
|
for j = 1, kCurr[i].ZigZagY do
|
|
EgtCreateMachining( 'ZigZagY_'..kCurr[i].Tname, MCH_MY.POCKETING, kCurr[i].Tname)
|
|
EgtSetMachiningParam( MCH_MP.USERNOTES , 'Polishing')
|
|
EgtSetMachiningParam( MCH_MP.STARTPOS, 10)
|
|
EgtSetMachiningParam( MCH_MP.DEPTH, kCurr[i].LiLoad)
|
|
EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.ZIGZAG)
|
|
EgtSetMachiningParam( MCH_MP.SIDEANGLE, 90)
|
|
EgtSetMachiningParam( MCH_MP.SIDESTEP, kCurr[i].StepY)
|
|
EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_POCK_LI.GLIDE)
|
|
EgtSetMachiningParam( MCH_MP.LITANG, kCurr[i].LiLen)
|
|
EgtSetMachiningParam( MCH_MP.LIELEV, kCurr[i].LiHeight)
|
|
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_POCK_LO.GLIDE)
|
|
EgtSetMachiningParam( MCH_MP.LOTANG, kCurr[i].LiLen)
|
|
EgtSetMachiningParam( MCH_MP.LOELEV, kCurr[i].LiHeight)
|
|
EgtSetMachiningParam( MCH_MP.OFFSR, kCurr[i].OffZigZagY)
|
|
EgtSetMachiningParam( MCH_MP.INVERT, (( j % 2) == 0))
|
|
local AngC = "C=" .. EgtNumToString(90*nPolishingC90,0)
|
|
EgtSetMachiningParam( MCH_MP.INITANGS, AngC)
|
|
EgtSetMachiningGeometry( {nCntId})
|
|
if not EgtApplyMachining() then
|
|
bOk = false
|
|
end
|
|
end
|
|
-- svuotature a spirale (con epicicli)
|
|
for j = 1, kCurr[i].Spiral do
|
|
EgtCreateMachining( 'Spiral_'..kCurr[i].Tname, MCH_MY.POCKETING, kCurr[i].Tname)
|
|
EgtSetMachiningParam( MCH_MP.USERNOTES , 'Polishing')
|
|
EgtSetMachiningParam( MCH_MP.STARTPOS, 10)
|
|
EgtSetMachiningParam( MCH_MP.DEPTH, kCurr[i].LiLoad)
|
|
EgtSetMachiningParam( MCH_MP.SUBTYPE, EgtIf( ( j % 2) == 0, MCH_POCK_SUB.SPIRALOUT, MCH_POCK_SUB.SPIRALIN))
|
|
EgtSetMachiningParam( MCH_MP.SIDEANGLE, 0)
|
|
EgtSetMachiningParam( MCH_MP.SIDESTEP, kCurr[i].StepSpiral)
|
|
EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_POCK_LI.GLIDE)
|
|
EgtSetMachiningParam( MCH_MP.LITANG, kCurr[i].LiLen)
|
|
EgtSetMachiningParam( MCH_MP.LIELEV, kCurr[i].LiHeight)
|
|
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_POCK_LO.GLIDE)
|
|
EgtSetMachiningParam( MCH_MP.LOTANG, kCurr[i].LiLen)
|
|
EgtSetMachiningParam( MCH_MP.LOELEV, kCurr[i].LiHeight)
|
|
EgtSetMachiningParam( MCH_MP.OFFSR, kCurr[i].OffSpiral)
|
|
EgtSetMachiningParam( MCH_MP.INVERT, (( j % 2) == 0))
|
|
EgtSetMachiningParam( MCH_MP.EPICYCLESRAD, kCurr[i].RadiusSpiral)
|
|
EgtSetMachiningParam( MCH_MP.EPICYCLESDIST, kCurr[i].DistanceSpiral)
|
|
local AngC = "C=" .. EgtNumToString(90*nPolishingC90,0)
|
|
EgtSetMachiningParam( MCH_MP.INITANGS, AngC)
|
|
EgtSetMachiningGeometry( {nCntId})
|
|
if not EgtApplyMachining() then
|
|
bOk = false
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
POLI.ERR = EgtIf( bOk, 0, 50)
|
|
|
|
end
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- Funzione per cancellare le lucidature
|
|
function POLI.Remove()
|
|
-- Elimino tutte le lavorazioni di tipo lucidatura
|
|
local nOperId = EgtGetFirstOperation()
|
|
while nOperId do
|
|
local nNextOperId = EgtGetNextOperation( nOperId)
|
|
if EgtGetOperationType( nOperId) ~= MCH_OY.DISP then
|
|
EgtSetCurrMachining( nOperId)
|
|
local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES)
|
|
if sUserNotes and sUserNotes:find( 'Polishing', 1, true) then
|
|
EgtErase( nOperId)
|
|
end
|
|
end
|
|
nOperId = nNextOperId
|
|
end
|
|
end
|