-- -- EEEEEEEEEE GGGGGG wwww wwww -- EEEEEEEEEE GGGGGGGGGG wwww wwww -- EEEE GGGG GGGG wwww wwww wwww -- EEEE GGGG wwww wwww wwww -- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww -- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww -- EEEE GGGG GGGG wwww wwwwwwww wwww -- EEEE GGGG GGGG wwww wwww wwww wwww -- EEEEEEEEEE GGGGGGGGGG wwwwwwww wwwwwwww -- EEEEEEEEEE GGGGGG wwwwwww wwwwwww -- -- fc_lines.lua by EgalWare s.r.l. 2019.05.07 -- Autore: Filippo Monchi -- fc_lines dati i valori 'Thickness' e 'face' e con nome attributo -- 2019.05.07 V1.000 FM Write Component -- 2019.09.24 V1.001 FM Manage side distance parameters (top, bottom, lock, hinge) from ddf -- 2019.09.25 V1.002 FM Fix some error on calculate lines and rectangle position when diameter tool used -- 2019.10.18 V2.000 FM Manage use Materials -- 2019.10.18 V2.000 FM Manage to draw not premptive lines between premptive lines only if premptive lines are 2 and their start and stop -- distances are defined and without or zero step value -- 2022.07.27 V2.001 FM Modification to use compiled code -- 2023.05.15 V2.002 FM fix errors (x/0) when exists only 1 horizontal line and/or only 1 vertical line and both distances ( from reference and opposite sides) are difined -- Tavola per definizione modulo (serve ma non usata) local fc_lines = {} -- Intestazioni require( 'EgtBase') EgtEnableDebug( false) EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') -- Valori limite local DimMin = 4. -- valore minimo lato local function GetMachToolErrorMessage( nErrorId, sGeomName, dIdMach, dOriDiamTool, nIdLogErr, sMchngName) local EgtDoorsMsg = require( 'EgtDoorsMsg') local sMessage = '' if dOriDiamTool then if nErrorId == -1 then -- lavorazione non presente in tabella sMessage = string.format(EgtDoorsMsg[466], nIdLogErr, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -2 then -- errore nel settare la lavorazione, lavorazione non presente in libreria sMessage = string.format(EgtDoorsMsg[467], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione sMessage = string.format(EgtDoorsMsg[468], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione sMessage = string.format(EgtDoorsMsg[469], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -5 then -- diametro utensile non trovato sMessage = string.format(EgtDoorsMsg[470], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -6 then -- nome geometria non presente in tabella sMessage = string.format(EgtDoorsMsg[471], nIdLogErr, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -7 then -- altezza massima utensile non trovata sMessage = string.format(EgtDoorsMsg[472], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -8 then -- tabella non presente nelle note sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) end elseif nErrorId == -1 then -- lavorazione non presente in tabella sMessage = string.format(EgtDoorsMsg[504], nIdLogErr, dIdMach, sGeomName) elseif nErrorId == -2 then -- errore nel settare la lavorazione sMessage = string.format(EgtDoorsMsg[505], nIdLogErr, sMchngName, dIdMach, sGeomName) elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione sMessage = string.format(EgtDoorsMsg[506], nIdLogErr, sMchngName, dIdMach, sGeomName) elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione sMessage = string.format(EgtDoorsMsg[507], nIdLogErr, sMchngName, dIdMach, sGeomName) elseif nErrorId == -5 then -- diametro utensile non trovato sMessage = string.format(EgtDoorsMsg[508], nIdLogErr, sMchngName, dIdMach, sGeomName) elseif nErrorId == -6 then -- nome geometria non presente in tabella sMessage = string.format(EgtDoorsMsg[503], nIdLogErr, sGeomName) elseif nErrorId == -7 then -- altezza massima utensile non trovata sMessage = string.format(EgtDoorsMsg[473], nIdLogErr, sMchngName, dIdMach, sGeomName) elseif nErrorId == -8 then -- tabella non presente nelle note sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) end return sMessage end local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar) local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) local nNumLine if idTable then table.insert( idTable, nLine) -- se devo inserire una variazione nell'entità if sMVar then nNumLine = #idTable end end if bPrev then if bDrawFirst then local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC) EgtSetColor(nCircle1, cColor1) end if bDrawLast then local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC) EgtSetColor(nCircle2, cColor2) end end return nLine, nNumLine, sMVar end local function DrawAddCircleDrawCircle( pCenter, dRadius, dAngIni, dAngCen, nGroup, idTable, bPrev, nGroupCirc, nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar) local nCircle = EgtArc( nGroup, pCenter, dRadius, dAngIni, dAngCen, 0, GDB_RT.LOC) local nNumCircle if idTable then table.insert( idTable, nCircle) -- se devo inserire una variazione nell'entità if sMVar then nNumCircle = #idTable end end if bPrev then if bDrawFirst then local nCircle1 = EgtCircle( nGroupCirc, EgtSP( nCircle), nRad , GDB_RT.LOC) EgtSetColor( nCircle1, cColor1) end if bDrawLast then local nCircle2 = EgtCircle( nGroupCirc, EgtEP( nCircle), nRad , GDB_RT.LOC) EgtSetColor( nCircle2, cColor2) end end return nCircle, nNumCircle, sMVar end -- Funzione di sistemazione parametri function fc_lines.AdjustParams( tMhPar) -- Assegno parametri da dati utensili in macchina local MB = require( 'MachiningBase') local EgtDoorsMsg = require( 'EgtDoorsMsg') local nTempT1 local nTempT2 local dNumMessage local dNumLog = 0 local sMessToOut = '' local dMaxMat1 local dMaxMat2 local sMchngName1 local sMchngName2 local sLGV local nLGVi = 1 local sLGH local nLGHi = 1 -- setto le variabili dimensioni porta tMhPar.W = DGD.dW tMhPar.L = DGD.dH tMhPar.type = 1 -- 1: lines, 2: rectangle -- variabile supporto calcolo passi linee verticali tMhPar.esfv = 0 -- eventuale raggio fresa -- variabile supporto calcolo passi linee orizzontali tMhPar.esfh = 0 -- eventuale raggio fresa -- nomi geometrie e diametri utensili delle associate lavorazioni if tMhPar.LGV then sLGV = tMhPar.LGV if DGD.MachEn > 0 and tMhPar.d1 then nTempT1, dMaxMat1, sMchngName1 = MB.GetToolDataFromAttrib( sLGV, nLGVi) end end if tMhPar.LGH then sLGH = tMhPar.LGH if DGD.MachEn > 0 and tMhPar.d2 then nTempT2, dMaxMat2, sMchngName2 = MB.GetToolDataFromAttrib( sLGH, nLGHi) end end -- se devo disegnare le geometrie di lavorazione if DGD.MachEn > 0 then -- gestisco il risultato della lettura utensili if DGD.bProoduce and tMhPar.d1 and nTempT1 <= 0 then dNumLog = -2799 sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLGV, nLGVi, tMhPar.d1, dNumLog, sMchngName1) elseif nTempT1 then tMhPar.d1 = nTempT1 end if DGD.bProoduce and tMhPar.d2 and nTempT2 <= 0 then dNumLog = -2798 sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLGH, nLGHi, tMhPar.d2, dNumLog, sMchngName2) elseif nTempT2 then tMhPar.d2 = nTempT2 end end -- se i diametri non sono stati definiti (dal controllo lavorazione) if not tMhPar.d1 then tMhPar.d1 = 0 end if not tMhPar.d2 then tMhPar.d2 = 0 end -- assegnamento valore a variabili di appoggio if not tMhPar.ctv then -- se non devo considerare l'utensile tMhPar.esfv = 0 else -- considero l'utensile tMhPar.esfv = tMhPar.d1/2 end if not tMhPar.cth then -- se non devo considerare l'utensile tMhPar.esfh = 0 else -- considero l'utensile tMhPar.esfh = tMhPar.d2/2 end --------------------------------------- -- setto parametri da ddf --------------------------------------- -- profondità if DGD.DEPTH then if tMhPar.Dvl then tMhPar.Dvl = EgtIf( DGD.DEPTH >= DGD.dT, 0, DGD.DEPTH) end if tMhPar.Dhl then tMhPar.Dhl = EgtIf( DGD.DEPTH >= DGD.dT, 0, DGD.DEPTH) end end -- se c'è distanza da top if DGD.DFT and DGD.DFT > 0 then tMhPar.reh = false -- setto per partire da top else -- non c'è la distanza da top -- se la distanza da bottom è valida if DGD.DFB and DGD.DFB > 0 then tMhPar.reh = true -- setto per partire da bottom -- else -- altrimenti la distanza da bottom non è valida -- tMhPar.reh = false -- setto per partire da top end end if not tMhPar.reh then -- se devo partire da top if DGD.DFT and DGD.DFT > 0 then -- se ho distanza top tMhPar.dsh = DGD.DFT + tMhPar.esfh -- aggiungo il raggio else if not tMhPar.dsh then -- se non è definito lo setto a 0 tMhPar.dsh = 0 -- setto distanza dal bordo della linea elseif tMhPar.dsh <= GEO.EPS_SMALL then tMhPar.dsh = 0 -- setto distanza dal bordo della linea else -- altrimenti gli sommo eventuale raggio utensile tMhPar.dsh = abs(tMhPar.dsh) + tMhPar.esfh end end if DGD.DFB and DGD.DFB > 0 then -- se ho distanza bottom tMhPar.doh = DGD.DFB + tMhPar.esfh -- aggiungo il raggio else if not tMhPar.doh then -- se non è definito lo setto a 0 tMhPar.doh = 0 -- setto distanza dal bordo della linea elseif tMhPar.doh <= GEO.EPS_SMALL then tMhPar.doh = 0 -- setto distanza dal bordo della linea else -- altrimenti gli sommo eventuale raggio utensile tMhPar.doh = abs(tMhPar.doh) + tMhPar.esfh end end else -- altrimenti partire da bottom if DGD.DFB and DGD.DFB > 0 then -- se ho distanza bottom tMhPar.dsh = DGD.DFB + tMhPar.esfh -- aggiungo il raggio else if not tMhPar.dsh then -- se non è definito lo setto a 0 tMhPar.dsh = 0 -- setto distanza dal bordo della linea elseif tMhPar.dsh <= GEO.EPS_SMALL then tMhPar.dsh = 0 -- setto distanza dal bordo della linea else -- altrimenti gli sommo eventuale raggio utensile tMhPar.dsh = abs(tMhPar.dsh) + tMhPar.esfh end end if DGD.DFT and DGD.DFT > 0 then -- se ho distanza top tMhPar.doh = DGD.DFT + tMhPar.esfh -- aggiungo il raggio else if not tMhPar.doh then -- se non è definito lo setto a 0 tMhPar.doh = 0 -- setto distanza dal bordo della linea elseif tMhPar.doh <= GEO.EPS_SMALL then tMhPar.doh = 0 -- setto distanza dal bordo della linea else -- altrimenti gli sommo eventuale raggio utensile tMhPar.doh = abs(tMhPar.doh) + tMhPar.esfh end end end -- se c'è distanza da lock if DGD.DFL and DGD.DFL > 0 then tMhPar.rev = false -- setto per partire da lock else -- non c'è la distanza da lock -- se la distanza da hinge è valida if DGD.DFH and DGD.DFH > 0 then tMhPar.rev = true -- setto per partire da hinge -- else -- altrimenti la distanza da hinge non è valida -- tMhPar.rev = false -- setto per partire da lock end end if not tMhPar.rev then -- se devo partire da lock if DGD.DFL and DGD.DFL > 0 then -- se ho distanza lock tMhPar.dsv = DGD.DFL + tMhPar.esfv -- aggiungo il raggio else if not tMhPar.dsv then -- se non è definito lo setto a 0 tMhPar.dsv = 0 -- setto distanza dal bordo della linea elseif tMhPar.dsv <= GEO.EPS_SMALL then tMhPar.dsv = 0 -- setto distanza dal bordo della linea else -- altrimenti gli sommo eventuale raggio utensile tMhPar.dsv = abs(tMhPar.dsv) + tMhPar.esfv end end if DGD.DFH and DGD.DFH > 0 then -- se ho distanza hinge tMhPar.dov = DGD.DFH + tMhPar.esfv -- aggiungo il raggio else if not tMhPar.dov then -- se non è definito lo setto a 0 tMhPar.dov = 0 -- setto distanza dal bordo della linea elseif tMhPar.dov <= GEO.EPS_SMALL then tMhPar.dov = 0 -- setto distanza dal bordo della linea else -- altrimenti gli sommo eventuale raggio utensile tMhPar.dov = abs(tMhPar.dov) + tMhPar.esfv end end else -- altrimenti partire da hinge if DGD.DFH and DGD.DFH > 0 then -- se ho distanza hinge tMhPar.dsv = DGD.DFH + tMhPar.esfv -- aggiungo il raggio else if not tMhPar.dsv then -- se non è definito lo setto a 0 tMhPar.dsv = 0 -- setto distanza dal bordo della linea elseif tMhPar.dsv <= GEO.EPS_SMALL then tMhPar.dsv = 0 -- setto distanza dal bordo della linea else -- altrimenti gli sommo eventuale raggio utensile tMhPar.dsv = abs(tMhPar.dsv) + tMhPar.esfv end end if DGD.DFL and DGD.DFL > 0 then -- se ho distanza lock tMhPar.dov = DGD.DFL + tMhPar.esfv -- aggiungo il raggio else if not tMhPar.dov then -- se non è definito lo setto a 0 tMhPar.dov = 0 -- setto distanza dal bordo della linea elseif tMhPar.dov <= GEO.EPS_SMALL then tMhPar.dov = 0 -- setto distanza dal bordo della linea else -- altrimenti gli sommo eventuale raggio utensile tMhPar.dov = abs(tMhPar.dov) + tMhPar.esfv end end end -- se ci sono linee verticali if tMhPar.LGV and tMhPar.nvl and tMhPar.nvl > 0 then if not tMhPar.clv then -- se non è definita la lunghezza di arresto tMhPar.clv = -tMhPar.d1*0.75 -- calcolo l'uscita pari a 3/4 del diametro else -- la distanza è definita -- setto l'arretramento con il valore assoluto tMhPar.clv = abs(tMhPar.clv) end if not tMhPar.civ then -- se non è definita la lunghezza di arresto alle intersezioni tMhPar.civ = EgtIf( tMhPar.d1 > tMhPar.d2, ((tMhPar.d1-tMhPar.d2)/2), 0) -- setto al differenza tra raggio utensili se ha diametro maggiore else tMhPar.civ = abs(tMhPar.civ) end -- setto una variabile di appoggio con il valore nullo del passo tMhPar.estv = tMhPar.stv if not tMhPar.stv then -- se passo non specificato per linee verticali, lo calcolo -- se non devo considerare l'utensile if not tMhPar.ctv then local nNumAreaTot if (tMhPar.dsv > 0) and (tMhPar.dov > 0) then -- se entrambe gli estremi definiti -- se ho una sola linea prendo il lato di riferimento if tMhPar.nvl <= 1 then tMhPar.dov = 0 nNumAreaTot = tMhPar.nvl else nNumAreaTot = tMhPar.nvl - 1 end elseif (tMhPar.dsv > 0) or (tMhPar.dov > 0) then -- se solo un estremo definito nNumAreaTot = tMhPar.nvl else -- nessun estremo definito nNumAreaTot = tMhPar.nvl + 1 end tMhPar.stv = ( tMhPar.W - tMhPar.dsv - tMhPar.dov) / nNumAreaTot -- tMhPar.stv = ( tMhPar.W - tMhPar.dsv - EgtIf( tMhPar.dsv > GEO.EPS_SMALL, tMhPar.esfv, 0)) / ( tMhPar.nvl + EgtIf( tMhPar.dsv > GEO.EPS_SMALL, 0, 1)) else -- considero l'utensile local nNumAreaTot local nNumLineToCount local nCaseDist = 0 if (tMhPar.dsv > 0) and (tMhPar.dov > 0) then -- se entrambe gli estremi definiti -- se ho una sola linea prendo il lato di riferimento if tMhPar.nvl <= 1 then tMhPar.dov = 0 nNumAreaTot = tMhPar.nvl nCaseDist = 1 else nNumAreaTot = tMhPar.nvl - 1 nCaseDist = 2 end nNumLineToCount = nNumAreaTot - 1 elseif (tMhPar.dsv > 0) or (tMhPar.dov > 0) then -- se solo un estremo definito nNumAreaTot = tMhPar.nvl nNumLineToCount = nNumAreaTot - 1 nCaseDist = 1 else -- nessun estremo definito nNumAreaTot = tMhPar.nvl + 1 nNumLineToCount = nNumAreaTot - 1 end -- calcolo la distanza netta che intercorre tra un taglio e l'altro tranne gli estremi tMhPar.stv = ((( tMhPar.W - ( tMhPar.dsv + EgtIf( tMhPar.dsv > GEO.EPS_SMALL, tMhPar.esfv, 0)) - ( tMhPar.dov + EgtIf( tMhPar.dov > GEO.EPS_SMALL, tMhPar.esfv, 0))) - ( nNumLineToCount * tMhPar.esfv * 2) ) / nNumAreaTot) -- se non ho nessun estremo lo ricalcolo if nCaseDist == 0 then tMhPar.dsv = tMhPar.stv + tMhPar.esfv end -- calcolo il passo: dalla distanza netta aggiungo il diametro utensile tMhPar.stv = tMhPar.stv + ( tMhPar.esfv * 2) -- tMhPar.stv = (( tMhPar.W - tMhPar.dsv - EgtIf( tMhPar.dsv > GEO.EPS_SMALL, tMhPar.esfv, 0)) - ( ( tMhPar.nvl - EgtIf( tMhPar.dsv > GEO.EPS_SMALL, 1, 0)) * tMhPar.esfv * 2)) / ( tMhPar.nvl + EgtIf( tMhPar.dsv > GEO.EPS_SMALL, 0, 1)) end else -- se passo specificato -- se devo considerare l'utensile if tMhPar.ctv then tMhPar.stv = tMhPar.stv + (tMhPar.esfv*2) end -- se non ho una distanza fissa dal lato di riferimento lo setto con il valore del passo - raggio utensile if tMhPar.dsv <= GEO.EPS_SMALL then tMhPar.dsv = abs(tMhPar.stv) - tMhPar.esfv end end end -- se ci sono linee orizzontali if tMhPar.LGH and tMhPar.nhl and tMhPar.nhl > 0 then if not tMhPar.clh then -- se non è definita la lunghezza di arresto tMhPar.clh = -tMhPar.d2*0.75 -- calcolo l'uscita pari a 3/4 del diametro else -- la distanza è definita -- setto l'arretramento con il valore assoluto tMhPar.clh = abs(tMhPar.clh) end if not tMhPar.cih then -- se non è definita la lunghezza di arresto alle intersezioni tMhPar.cih = EgtIf( tMhPar.d2 > tMhPar.d1, ((tMhPar.d2-tMhPar.d1)/2), 0) -- setto al differenza tra raggio utensili se ha diametro maggiore else tMhPar.cih = abs(tMhPar.cih) end -- setto una variabile di appoggio con il valore nullo del passo tMhPar.esth = tMhPar.sth if not tMhPar.sth then -- se passo non specificato per linee orizzontali, lo calcolo -- se non devo considerare l'utensile if not tMhPar.cth then local nNumAreaTot if (tMhPar.dsh > 0) and (tMhPar.doh > 0) then -- se entrambe gli estremi definiti -- se ho una sola linea prendo il lato di riferimento if tMhPar.nhl <= 1 then tMhPar.doh = 0 nNumAreaTot = tMhPar.nhl else nNumAreaTot = tMhPar.nhl - 1 end elseif (tMhPar.dsh > 0) or (tMhPar.doh > 0) then -- se solo un estremo definito nNumAreaTot = tMhPar.nhl else -- nessun estremo definito nNumAreaTot = tMhPar.nhl + 1 end tMhPar.sth = ( tMhPar.L - tMhPar.dsh - tMhPar.doh) / nNumAreaTot else -- considero l'utensile local nNumAreaTot local nNumLineToCount local nCaseDist = 0 if (tMhPar.dsh > 0) and (tMhPar.doh > 0) then -- se entrambe gli estremi definiti -- se ho una sola linea prendo il lato di riferimento if tMhPar.nhl <= 1 then tMhPar.doh = 0 nNumAreaTot = tMhPar.nhl nCaseDist = 1 else nNumAreaTot = tMhPar.nhl - 1 nCaseDist = 2 end nNumLineToCount = nNumAreaTot - 1 elseif (tMhPar.dsh > 0) or (tMhPar.doh > 0) then -- se solo un estremo definito nNumAreaTot = tMhPar.nhl nNumLineToCount = nNumAreaTot - 1 nCaseDist = 1 else -- nessun estremo definito nNumAreaTot = tMhPar.nhl + 1 nNumLineToCount = nNumAreaTot - 1 end -- calcolo la distanza netta che intercorre tra un taglio e l'altro tranne gli estremi tMhPar.sth = ((( tMhPar.L - ( tMhPar.dsh + EgtIf( tMhPar.dsh > GEO.EPS_SMALL, tMhPar.esfh, 0)) - ( tMhPar.doh + EgtIf( tMhPar.doh > GEO.EPS_SMALL, tMhPar.esfh, 0))) - ( nNumLineToCount * tMhPar.esfh * 2) ) / nNumAreaTot) -- se non ho nessun estremo lo ricalcolo if nCaseDist == 0 then tMhPar.dsh = tMhPar.sth + tMhPar.esfh end -- calcolo il passo: dalla distanza netta aggiungo il diametro utensile tMhPar.sth = tMhPar.sth + ( tMhPar.esfh * 2) end else -- se passo specificato -- se devo considerare l'utensile if tMhPar.cth then tMhPar.sth = tMhPar.sth + (tMhPar.esfh*2) end -- se non ho una distanza fissa dal lato di riferimento lo setto con il valore del passo - raggio utensile if tMhPar.dsh <= GEO.EPS_SMALL then tMhPar.dsh = abs(tMhPar.sth) - tMhPar.esfh end end end -- se devo disegnare le geometrie di lavorazione if DGD.MachEn > 0 then -- se la profondità delle linee verticali è maggiore della capacità utensile limito la profondità ed emetto un warning if tMhPar.Dvl and dMaxMat1 and tMhPar.Dvl > dMaxMat1 then dNumLog = -2797 dNumMessage = 549 sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.Dvl), EgtToUiUnits(dMaxMat1)) tMhPar.Dvl = dMaxMat1 - 0.02 -- tolgo 0.02 per permettere la lavorazione end -- se la profondità delle linee orizzontali è maggiore della capacità utensile limito la profondità ed emetto un warning if tMhPar.Dhl and dMaxMat2 and tMhPar.Dhl > dMaxMat2 then dNumLog = -2796 dNumMessage = 549 sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.Dhl), EgtToUiUnits(dMaxMat2)) tMhPar.Dhl = dMaxMat2 - 0.02 -- tolgo 0.02 per permettere la lavorazione end end if dNumLog ~= 0 then return tMhPar, dNumLog, sMessToOut end return tMhPar, 0, '' end -- Funzione di disegno function fc_lines.Draw( tFDecorPar, bPreview, bRunByCompo, nDrawMach) -- Assegno le variabili per linee local nvl = tFDecorPar.nvl local dev = tFDecorPar.dev local Dvl = tFDecorPar.Dvl local rev = tFDecorPar.rev local dsv = tFDecorPar.dsv local dov = tFDecorPar.dov local stv = tFDecorPar.stv local estv = tFDecorPar.estv local clv = tFDecorPar.clv local civ = tFDecorPar.civ local esfv = tFDecorPar.esfv local nhl = tFDecorPar.nhl local deh = tFDecorPar.deh local Dhl = tFDecorPar.Dhl local reh = tFDecorPar.reh local dsh = tFDecorPar.dsh local doh = tFDecorPar.doh local sth = tFDecorPar.sth local esth = tFDecorPar.esth local clh = tFDecorPar.clh local cih = tFDecorPar.cih local esfh = tFDecorPar.esfh local d1 = tFDecorPar.d1 local d2 = tFDecorPar.d2 -- Assegno variabili comuni local pre = tFDecorPar.pre local dtype = tFDecorPar.type local L = tFDecorPar.L local W = tFDecorPar.W -- Assegno i nomi geometrie local LGV = tFDecorPar.LGV local LGH = tFDecorPar.LGH local DM = 'DUMMY' -- variabili per messaggi e settaggi vari local sCompoName = tFDecorPar.Nome local nCompoNpar = tFDecorPar.Npar local sCompoPath = tFDecorPar.Path -- eventuale messaggio errore rilevato nell'adjust local nCodAdj = tFDecorPar.nCod local sCodAdj = tFDecorPar.sCod -- variabili per messaggi di errore local sNamePar3 = 'Dvl' local sNamePar4 = 'Dhl' local sNamePar7 = 'clv' local sNamePar8 = 'clh' -- RunByComponentInterface local RC = true -- Messaggi codice errori local EM = ' ' local EC = 0 local ErrorBase = 2700 -- variabili che abilitano la creazione della geometria local bMakeFaceGeom1 = true local bMakeFaceGeom2 = true if not bRunByCompo then -- controllo se lanciato da componente RC = false end -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione nDrawMach = 0 end local nForceMakeFace = nDrawMach if not Dvl or Dvl < GEO.EPS_SMALL or not nvl or nvl == 0 then -- se spessore 0 o no linee bMakeFaceGeom1 = false end if not Dhl or Dhl < GEO.EPS_SMALL or not nhl or nhl == 0 then -- se spessore 0 o no linee bMakeFaceGeom2 = false end if nForceMakeFace == 0 then -- se solo geometria disabilito il raggio fresa esfv = 0 esfh = 0 end local EgtDoorsMsg = require( 'EgtDoorsMsg') -- Verifica delle dimensioni, le condizioni vengono verificate in base a quale geometria deve essere creata if bMakeFaceGeom1 and clv and clv*2 >= L then EC = 1 EM = string.format( EgtDoorsMsg[626], sNamePar7, EgtToUiUnits(clv), EgtToUiUnits((L/2)-0.1), sCompoPath) -- il parametro 'clv' deve essere < L/2 clv = 0 elseif bMakeFaceGeom2 and clh and clh*2 >= W then EC = 2 EM = string.format( EgtDoorsMsg[626], sNamePar8, EgtToUiUnits(clh), EgtToUiUnits((W/2)-0.1), sCompoPath) -- il parametro 'clh' deve essere < W/2 clh = 0 end if not bPreview and EC ~= 0 then return (ErrorBase+EC), EM end -- Se Preview cancello tutto if bPreview then EgtNewFile() EgtSetDefaultMaterial( BLACK()) end -- Pezzo e Layer local Pz if bPreview then Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- nuovo pezzo else if not RC then Pz = EgtGetCurrPart() -- pezzo corrente end if not Pz then Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- nuovo pezzo end end -- Layer local Dm local Lg local GId local hint local nRev local pIni, pEnd local dStartValX, dStopValX local dStartValY, dStopValY local dValXv1Ini, dValXv1End, dValYv1Ini, dValYv1End -- prima linea verticale local dValXv2Ini, dValXv2End, dValYv2Ini, dValYv2End -- seconda linea verticale local dValXh1Ini, dValXh1End, dValYh1Ini, dValYh1End -- prima linea orizzontale local dValXh2Ini, dValXh2End, dValYh2Ini, dValYh2End -- seconda linea orizzontale local dStart Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale EgtSetName(Lg,sCompoName) if nDrawMach > 0 then -- se abilitata geometria lavorazione Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentante il diametro utensile EgtSetName(Dm,DM) end if nForceMakeFace ~= 1 then -- se abilitata geometria esterna -- se linee verticali if bMakeFaceGeom1 then -- se posso fare linee verticali -- definisco i punti iniziali e finali if not rev then -- se riferite a lock if dsv > 0 then -- se ho posizione dStartValX = dsv dStopValX = dsv else -- non ho posizione dStartValX = stv+esfv dStopValX = stv+esfv end nRev = 1 else -- riferite a hinge if dsv > 0 then -- se ho posizione dStartValX = W-dsv dStopValX = W-dsv else -- non ho posizione dStartValX = W-stv-esfv dStopValX = W-stv-esfv end nRev = -1 end if not pre or pre <= 1 then -- se non ci sono prelazioni o prelazione sulle linee verticali dStartValY = L - clv -- posizione in alto dStopValY = clv else -- ci sono prelazioni su linee orizzontali -- se ci sono linee orizzontali -- in base al loro riferimento definisco la posizione di partenza in Y if bMakeFaceGeom2 then -- se ho solo due linee e sono specificate le distanze e senza un passo definito if nhl == 2 and dsh and doh and dsh > 0 and doh > 0 and ( not esth or esth < 0) then if not reh then -- se riferite a top dStartValY = L - dsh - civ -- posizione in alto dStopValY = doh + civ else -- partono da sotto dStartValY = L - doh - civ -- posizione in alto dStopValY = dsh + civ end else if not reh then -- se riferite a top dStartValY = L - dsh - ( ( sth + (esfh*2)) * EgtIf( dsh > GEO.EPS_SMALL, nhl-1, nhl)) - civ -- posizione in alto dStopValY = clv else -- partono da sotto dStartValY = L - clv -- posizione in alto dStopValY = dsh + ( ( sth + (esfh*2)) * EgtIf( dsh > GEO.EPS_SMALL, nhl-1, nhl)) + civ end end else -- altrimenti come per il primo caso dStartValY = L - clv -- posizione in alto dStopValY = clv end end if dStopValY >= dStartValY then -- se punti definiscono linea nulla o incongruente EC = 20 EM = string.format( EgtDoorsMsg[647], ( dStartValY - dStopValY), sCompoPath) -- mancano i parametri delle dimensioni return (ErrorBase+EC), EM end -- prendo la partenza iniziale dStart = dStartValX -- disegno geometria for k = 1, nvl do pIni = Point3d( dStartValX, dStartValY, 0) pEnd = Point3d( dStopValX, dStopValY, 0) hint = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, (d1/2), true, true, RED(), RED()) if hint then EgtModifyCurveThickness( hint, -Dvl) -- di default è sul lato keyway EgtSetName( hint, LGV) end -- se ho il check di cancellazione linea esterna if dev then if nRev > 0 then -- se riferita a bottom -- se ultima linea inserita è esterna cancello ultima linea e aggiorno il numero linee if dStartValX >= W then nvl = k - 1 EgtErase(hint) break end else -- riferita a top -- se ultima linea inserita è esterna cancello ultima linea e aggiorno il numero linee if dStartValX < 0 then -- se ultima linea arriva oltre nvl = k - 1 EgtErase(hint) break end end end -- aggiorno il passo dStartValX = dStartValX + ( ( stv + (2*esfv)) * nRev) dStopValX = dStopValX + ( ( stv + (2*esfv)) * nRev) end if not dev then -- se non devo cancellare linee esterne verifico se sbordano if nRev > 0 then -- se riferita a lock if ( dStart + (( stv + (2*esfv)) * (nvl-1) * nRev)) >= W then -- se ultima linea arriva oltre EC = 21 EM = string.format( EgtDoorsMsg[652], sCompoPath) -- geometria sborda in larghezza return (ErrorBase+EC), EM end else -- riferita a hinge if ( dStart + (( stv + (2*esfv)) * (nvl-1) * nRev)) < 0 then -- se ultima linea arriva oltre EC = 22 EM = string.format( EgtDoorsMsg[652], sCompoPath) -- geometria sborda in larghezza return (ErrorBase+EC), EM end end end end -- se linee orizzontali if bMakeFaceGeom2 then -- se posso fare linee orizzontali -- definisco i punti iniziali e finali if not reh then -- se riferite a top if dsh > 0 then -- se ho posizione dStartValY = L-dsh dStopValY = L-dsh else -- non ho posizione dStartValY = L-sth-esfh dStopValY = L-sth-esfh end nRev = -1 else -- riferite a bottom if dsh > 0 then -- se ho posizione dStartValY = dsh dStopValY = dsh else -- non ho posizione dStartValY = sth+esfh dStopValY = sth+esfh end nRev = 1 end if not pre or pre == 0 or pre == 2 then -- se non ci sono prelazioni o prelazione sulle linee orizzontali dStartValX = clh -- posizione a sinistra dStopValX = W - clh else -- ci sono prelazioni su linee verticali -- se ci sono linee verticali -- in base al loro riferimento definisco la posizione di partenza in X if bMakeFaceGeom1 then -- se ho solo due linee e sono specificate le distanze e senza un passo definito if nvl == 2 and dsv and dov and dsv > 0 and dov > 0 and ( not estv or estv < 0) then if not rev then -- se partono da lock dStartValX = dsv + cih -- posizione a sinistra dStopValX = W - dov - cih else -- partono da hinge dStartValX = dov + cih -- posizione a sinistra dStopValX = W - dsv - cih end else if not rev then -- se partono da lock dStartValX = dsv + ( ( stv + (esfv*2)) * EgtIf( dsv > GEO.EPS_SMALL, nvl-1, nvl)) + cih -- posizione a sinistra dStopValX = W - clh -- posizione a destra else -- partono da hinge dStartValX = clh -- posizione a sinistra dStopValX = W - dsv - ( ( stv + (esfv*2)) * EgtIf( dsv > GEO.EPS_SMALL, nvl-1, nvl)) - cih -- posizione a destra end end else -- altrimenti come per il primo caso dStartValX = clh -- posizione a sinistra dStopValX = W - clh end end if dStartValX >= dStopValX then -- se punti definiscono linea nulla o incongruente EC = 23 EM = string.format( EgtDoorsMsg[648], ( dStopValX - dStartValX), sCompoPath) return (ErrorBase+EC), EM end -- prendo la partenza iniziale dStart = dStartValY -- disegno geometria for k = 1, nhl do pIni = Point3d( dStartValX, dStartValY, 0) pEnd = Point3d( dStopValX, dStopValY, 0) hint = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, (d2/2), true, true, RED(), RED()) if hint then EgtModifyCurveThickness( hint, -Dhl) -- di default è sul lato keyway EgtSetName( hint, LGH) end -- se ho il check di cancellazione linea esterna if deh then if nRev > 0 then -- se riferita a bottom -- se ultima linea inserita è esterna cancello ultima linea e aggiorno il numero linee if dStartValY >= L then nhl = k - 1 EgtErase(hint) break end else -- riferita a top -- se ultima linea inserita è esterna cancello ultima linea e aggiorno il numero linee if dStartValY < 0 then -- se ultima linea arriva oltre nhl = k - 1 EgtErase(hint) break end end end -- aggiorno il passo dStartValY = dStartValY + ( ( sth + (2*esfh)) * nRev) dStopValY = dStopValY + ( ( sth + (2*esfh)) * nRev) end if not deh then -- se non devo cancellare linee esterne verifico se sbordano if nRev > 0 then -- se riferita a bottom if ( dStart + (( sth + (2*esfh)) * (nhl-1) * nRev)) >= L then -- se ultima linea arriva oltre EC = 24 EM = string.format( EgtDoorsMsg[653], sCompoPath) -- geometria sborda in larghezza return (ErrorBase+EC), EM end else -- riferita a top if ( dStart + (( sth + (2*esfh)) * (nhl-1) * nRev)) < 0 then -- se ultima linea arriva oltre EC = 25 EM = string.format( EgtDoorsMsg[653], sCompoPath) -- geometria sborda in larghezza return (ErrorBase+EC), EM end end end end end -- cambio colore alla geometria if bPreview then if EC == 0 then EgtSetColor( Lg or GDB_ID.NULL, AQUA()) else EgtSetColor( Lg or GDB_ID.NULL, ORANGE()) end end -- Se non Preview -- (NOTA : se ci sono errori il componente non viene eseguito dal programma di gestione dei componenti) if not bPreview then if bRunByCompo then -- scrivo i parametri nelle info del pezzo WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) end -- scrivo note nel layer della cerniera EgtSetInfo(Lg,'Type' ,'fc_lines') EgtSetInfo(Lg,'L' ,L) EgtSetInfo(Lg,'W' ,W) EgtSetInfo(Lg,'nvl' ,nvl) EgtSetInfo(Lg,'Dvl' ,Dvl) EgtSetInfo(Lg,'rev' ,rev) EgtSetInfo(Lg,'dsv' ,dsv) EgtSetInfo(Lg,'dov' ,dov) EgtSetInfo(Lg,'stv' ,stv) EgtSetInfo(Lg,'clv' ,clv) EgtSetInfo(Lg,'civ' ,civ) EgtSetInfo(Lg,'esfv' ,esfv) EgtSetInfo(Lg,'nhl' ,nhl) EgtSetInfo(Lg,'Dhl' ,Dhl) EgtSetInfo(Lg,'reh' ,reh) EgtSetInfo(Lg,'dsh' ,dsh) EgtSetInfo(Lg,'doh' ,doh) EgtSetInfo(Lg,'sth' ,sth) EgtSetInfo(Lg,'clh' ,clh) EgtSetInfo(Lg,'cih' ,cih) EgtSetInfo(Lg,'esfh' ,esfh) EgtSetInfo(Lg,'pre' ,pre) EgtSetInfo(Lg,'dtype' ,dtype) EgtSetInfo(Lg,'LGV' ,LGV) EgtSetInfo(Lg,'LGH' ,LGH) EgtSetInfo(Lg,'Path' ,sCompoPath) -- cancello le parti ausiliarie se disegnate if Dm then EgtErase(Dm) end end if EC == 0 and nCodAdj and nCodAdj < 0 then EC = nCodAdj EM = sCodAdj end return EC, EM, Lg end return fc_lines