Files
Carlo Baronchelli 741791a0e4 Copia locale Iniziale
2022-05-19 16:04:07 +02:00

696 lines
25 KiB
Lua

-- 2021/11/14 11:00:00
-- Creazione di fresa cilindrica per legno
-- 2019/03/26 DS Tolleranza creazione superficie portata a 0.01.
-- 2020/05/15 DS Correzione creazione layer per utensile senza portautensile.
-- 2021/05/22 DS Cancellazione eventuale layer aux di portautensile
-- 2021/11/14 DS Aggiunta gestione eventuale secondo ingombro portautensile.
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
require( "EgtDimension")
-- Dati utensile : dichiarazione e valori standard
local TOOL = {}
TOOL.TOOLHOLDER = ''
TOOL.SPEED = nil
TOOL.LEN = 80
TOOL.TOTLEN = 80
TOOL.DIAM = 20
TOOL.TOTDIAM = 20
TOOL.CORNRAD = 0
TOOL.SIDEANG = 0
TOOL.HEIGHT = 30
TOOL.MAXMAT = 40
TOOL.ERR = 0
_G.TOOL = TOOL
-- Creazione utensile cilindrico
function CreateTool()
TOOL.ERR = 999
-- Parametri utensile
local sFilePath = TOOL.TOOLHOLDER
local dMillHeight = TOOL.LEN
local dTotMillHeight = TOOL.TOTLEN
local dMillDiameter = TOOL.DIAM
local dTotMillDiameter = TOOL.TOTDIAM
local dRadFillet = TOOL.CORNRAD
local dProfileHeight = TOOL.HEIGHT
local dSideAng = TOOL.SIDEANG
local dCutterHeight = TOOL.MAXMAT
local dSpeed = TOOL.SPEED
-- correzione diametro utensile prossimo allo 0
if dMillDiameter <= GEO.EPS_SMALL then
dMillDiameter = 0
end
-- progetto vuoto
EgtNewFile()
local dToolHolderHeight = 0
local dToolHolderDiameter = 0
local dToolHolderStemDiam = 0
if not dRadFillet then dRadFillet = 0 end
-- Se richiesto inserisco porta utensile
if sFilePath and sFilePath ~= "" then
-- eseguo inserimento
if not EgtInsertFile(sFilePath) then
TOOL.ERR = 1
return
end
-- recupero dimensioni portautensile
local Pz = EgtGetFirstInGroup( GDB_ID.ROOT)
dToolHolderHeight = EgtGetInfo( Pz, "H", 'd') or 0
dToolHolderDiameter = EgtGetInfo( Pz, "D", 'd') or 0
dToolHolderStemDiam = EgtGetInfo( Pz, "D_STEM", 'd') or 0
-- eventuale gestione secondo ingombro
local dThH2 = EgtGetInfo( Pz, "H2", 'd')
local dThD2 = EgtGetInfo( Pz, "D2", 'd')
if dThH2 and dThD2 and dTotMillDiameter <= dThD2 then
EgtSetInfo( Pz, "H", dThH2)
EgtSetInfo( Pz, "D", dThD2)
EgtSetInfo( Pz, "H2", dToolHolderHeight)
EgtSetInfo( Pz, "D2", dToolHolderDiameter)
dToolHolderHeight = dThH2
dToolHolderDiameter = dThD2
end
-- rimuovo eventuale nome e layer ausiliario
EgtSetName( Pz, '')
local ThAuxId = EgtGetFirstNameInGroup( Pz, 'TH_AUX')
if ThAuxId then
EgtErase( ThAuxId)
end
-- eventuale visualizzazione senso di rotazione
local Ly = EgtGetFirstInGroup( Pz or GDB_ID.NULL)
local RotId = EgtGetFirstNameInGroup( Ly or GDB_ID.NULL, 'Rot')
if RotId then
if dSpeed and abs( dSpeed) > 1 then
-- se rotazione opposta, devo invertire
if dSpeed < 0 then
EgtMirror( RotId, ORIG(), X_AX(), GDB_RT.GLOB)
end
else
EgtSetStatus( RotId, GDB_ST.OFF)
end
end
-- Altrimenti creo pezzo e layer opportuni
else
-- Creo pezzo e layer
local Pz = EgtGroup( GDB_ID.ROOT)
local Ly = EgtGroup( Pz)
-- altezza portautensile rimane nulla
end
local dLenRef = dMillHeight
local nProfH = 0
if dProfileHeight and dProfileHeight ~= 0 then
if dSideAng and dSideAng ~= 0 then
if dProfileHeight > 0 then
dLenRef = dLenRef + dProfileHeight
nProfH = 1
else
nProfH = -1
end
-- se lunghezza totale ( senza raccordo) è maggiore della lunghezza utensile aggiorno la lunghezza tagliente
if dTotMillHeight > dLenRef and dRadFillet <= 0 then
dCutterHeight = dCutterHeight - ( dTotMillHeight - dLenRef)
end
end
end
-- variabile quotatura tagliente
local dQuoteCutter = dCutterHeight
-- Controllo lunghezza utensile
local dCutterRef = dCutterHeight
if nProfH ~= 0 then
if abs(dProfileHeight) > dCutterHeight then
dCutterRef = abs(dProfileHeight)
end
end
if dLenRef - dToolHolderHeight - dCutterRef < 0 then
TOOL.ERR = 12
return
end
-- Layer
local Part = EgtGetFirstGroupInGroup( GDB_ID.ROOT)
local MillLayer = EgtGetFirstInGroup( Part)
EgtSetName( MillLayer, 'SOLID')
local QuoteLayer = EgtGroup(Part)
EgtSetName( QuoteLayer, 'AUX')
EgtSetColor( QuoteLayer, BLACK())
if EgtGetBackground then
local colTop, colBot = EgtGetBackground()
if colTop and colBot then
local nInt = colTop:getRed() + colTop:getGreen() + colTop:getBlue() + colBot:getRed() + colBot:getGreen() + colBot:getBlue()
if nInt < 769 then
EgtSetColor( QuoteLayer, WHITE())
end
end
end
-- Disegno utensile
local dXP0, dYP0, dXP1, dYP1, dXP2, dYP2, dXP3, dYP3, dXP4, dYP4, dXP5, dYP5, dXP6, dYP6
local dAddRad, dAddRefRad, dAddCutRad
local ptP0, ptP1, ptP2, ptP3, ptP4, ptP5, ptP6, ptLen, ptLenC, ptLenT
local dMyTotMillDiameter
local dMyOrigDiam = dMillDiameter
local bNoTipLine = false
local dLenExtra = dTotMillHeight - dLenRef
if dSideAng and dSideAng ~= 0 then -- ae è conico
-- se non ho altezza profilo do errore
if nProfH == 0 then
TOOL.ERR = 13 -- 6131
return
end
-- se angolo conicità errato do errore
if dSideAng >= 90 then
TOOL.ERR = 14 -- 6132
return
elseif dSideAng <= -90 then
TOOL.ERR = 15 -- 6133
return
end
-- dato che la lunghezza utensile può essere espressa nella parte alta, controllo con la lunghezza totale
if dLenRef > dTotMillHeight then
TOOL.ERR = 22 -- 6134
return
end
dAddRad = dProfileHeight * tan(abs(dSideAng)) -- può essere positivo o negativo
dAddRefRad = dCutterRef * tan(abs(dSideAng)) -- è positivo
dAddCutRad = dCutterHeight * tan(abs(dSideAng)) -- è positivo
local dMinDiam = 2 * ( dRadFillet / tan( (90 + dSideAng)/2))
if dSideAng > 0 then -- utensile a punta
if dAddRad < 0 then -- lunghezza definita sulla punta
if dMillDiameter == 0 then -- se diametro 0 gli assegno il diametro minimo
dMillDiameter = dMinDiam
bNoTipLine = true
elseif dMillDiameter < dMinDiam then -- se raccordo troppo grande do errore
TOOL.ERR = 16 -- 6135
return
end
-- se altezza profilo minore o uguale della parte occupata dal raccordo do errore
if dRadFillet > 0 and abs( dProfileHeight) <= ( ( dMinDiam / 2) * cos( dSideAng)) then
TOOL.ERR = 17 -- 6136
return
elseif dRadFillet > 0 and abs( dCutterHeight) <= ( ( dMinDiam / 2) * cos( dSideAng)) then
TOOL.ERR = 17 -- 6136
return
end
-- se il diametro calcolato in alto supera il diametro max do errore
dMyTotMillDiameter = ( dMillDiameter - ( 2 * dAddRad)) -- per le quotature
if dMyTotMillDiameter > dTotMillDiameter then
TOOL.ERR = 18 -- 6137
return
end
-- se non ho raccordo e la differenza tra lungtot e lunghezza profilo generano parte inclinata che collassa do errore
if dMinDiam <= 0 and ( dLenExtra * tan(abs(dSideAng)))*2 > dMillDiameter then
TOOL.ERR = 19 -- 6138
return
end
else -- altrimenti lunghezza definita nella parte alta del profilo
if ( dMillDiameter - (2*dAddRad)) < 0 then -- se in punta il diametro collassa
TOOL.ERR = 19 -- 6138
return
elseif ( dMillDiameter - (2*dAddRad)) == dMinDiam then -- se la tip line va a 0
bNoTipLine = true
-- se raccordo troppo grande do errore
elseif ( dMillDiameter - (2*dAddRad)) < dMinDiam then
TOOL.ERR = 16 -- 6135
return
end
-- se altezza profilo minore o uguale della parte occupata dal raccordo do errore
if dRadFillet > 0 and abs( dProfileHeight) <= ( ( dMinDiam / 2) * cos( dSideAng)) then
TOOL.ERR = 17 -- 6136
return
elseif dRadFillet > 0 and abs( dCutterHeight) <= ( ( dMinDiam / 2) * cos( dSideAng)) then
TOOL.ERR = 17 -- 6136
return
end
dMyTotMillDiameter = dMillDiameter -- per le quotature
-- se non ho raccordo e la differenza tra lungtot e lunghezza profilo generano parte inclinata che collassa do errore
if dMinDiam <= 0 and (( dLenExtra + dProfileHeight) * tan(abs(dSideAng)))*2 > dMillDiameter then
TOOL.ERR = 19 -- 6138
return
end
end
else -- altrimenti a coda di rontine
if dAddRad < 0 then -- lunghezza definita sulla punta
if ( dMillDiameter - ( 2 * dRadFillet)) < 0 then -- se raccordo troppo grande do errore
TOOL.ERR = 16 -- 6135
return
elseif ( dMillDiameter - ( 2 * dRadFillet)) < 0.001 then -- se raccordo arriva a 0
bNoTipLine = true
end
-- se altezza profilo minore o uguale della parte occupata dal raccordo do errore
if dRadFillet > 0 and abs(dProfileHeight) <= ( ( dMinDiam / 2) * cos(abs(dSideAng))) then
TOOL.ERR = 17 -- 6136
return
-- se altezza tagliente minore o uguale della parte occupata dal raccordo do errore
elseif dRadFillet > 0 and dCutterHeight <= ( ( dMinDiam / 2) * cos(abs(dSideAng))) then
TOOL.ERR = 17 -- 6136
return
-- se il diametro in alto si annulla do errore
elseif ( dMillDiameter + ( 2 * ( dAddRad - dRadFillet)) + dMinDiam) <= 0 then
TOOL.ERR = 20 -- 6139
return
end
dMyTotMillDiameter = dMillDiameter - dMinDiam + ( 2 * ( ( ( dTotMillHeight - dLenRef) * tan(abs(dSideAng))) + dRadFillet)) -- per le quotature
-- se non ho raccordo e la differenza tra lungtot e lunghezza profilo generano parte inclinata che supera maxdiam do errore
if dMinDiam <= 0 and ((( dLenExtra * tan(abs(dSideAng)))*2) + dMillDiameter) > dTotMillDiameter then
TOOL.ERR = 18 -- 6137
return
end
else -- altrimenti lunghezza definita nella parte alta del profilo
-- se il diametro effettivo supera il diametro massimo do errore
dMyTotMillDiameter = ( dMillDiameter - dMinDiam + ( 2 * ( ( ( dTotMillHeight - dLenRef) * tan(abs(dSideAng))) + dAddRad + dRadFillet))) -- per le quotature
if dMyTotMillDiameter > dTotMillDiameter then
TOOL.ERR = 18 -- 6137
return
elseif ( dMillDiameter - dMinDiam + ( 2 * dAddRad)) < 0 then -- se raccordo troppo grande do errore
TOOL.ERR = 16 -- 6135
return
elseif ( dMillDiameter - dMinDiam + ( 2 * dAddRad)) < 0.001 then -- se il raccordo arriva a 0
bNoTipLine = true
end
-- se altezza profilo minore o uguale della parte occupata dal raccordo do errore
if dRadFillet > 0 and abs(dProfileHeight) <= ( ( dMinDiam / 2) * cos(abs(dSideAng))) then
TOOL.ERR = 17 -- 6136
return
end
-- se altezza tagliente minore o uguale della parte occupata dal raccordo do errore
if dRadFillet > 0 and abs(dCutterHeight) <= ( ( dMinDiam / 2) * cos(abs(dSideAng))) then
TOOL.ERR = 17 -- 6136
return
end
-- se non ho raccordo e la differenza tra lungtot e lunghezza profilo generano parte inclinata che collassa do errore
if dMinDiam <= 0 and (((( dLenExtra + dProfileHeight) * tan(abs(dSideAng)))*2) + dMillDiameter) > dTotMillDiameter then
TOOL.ERR = 18 -- 6137
return
end
end
end
-- calcolo punti per gambo utensile
dYP0 = - dToolHolderHeight
dYP1 = dYP0
if dSideAng > 0 then -- utensile a punta
dXP1 = ( dMillDiameter / 2) - dAddRad
else
dXP1 = ( dMillDiameter / 2) - dRadFillet + ( dMinDiam / 2) + dAddRad
end
if dAddRad > 0 then -- se profilo definito in alto
dXP1 = ( dMillDiameter / 2)
end
-- calcolo punti per gambo utensile
if dToolHolderStemDiam > 0 and ( dToolHolderStemDiam / 2) < dXP1 then
dXP0 = dToolHolderStemDiam / 2
elseif dToolHolderDiameter > 0 and (( dToolHolderDiameter - 5)/2) < dXP1 then
dXP0 = ( dToolHolderDiameter - 5) / 2
else
dXP0 = dXP1
end
dXP2 = dXP1
dXP1 = dXP0
dYP2 = - dLenRef + dCutterRef
-- se tagliente minore dell'altezza profilo
if dCutterHeight < dCutterRef then
if dSideAng > 0 then -- utensile a punta
dXP3 = dXP2 - ( dAddRefRad - dAddCutRad)
else -- altrimenti a coda di rondine
dXP3 = dXP2 + ( dAddRefRad - dAddCutRad)
end
dYP3 = - dLenRef + dCutterHeight
end
if dSideAng > 0 then -- utensile a punta
dXP4 = dXP2 - abs( dAddRad)
else -- altrimenti a coda di rondine
dXP4 = dXP2 + abs( dAddRad)
end
-- completo i punti comuni per entrambe i casi
dYP4 = - dLenRef
if dRadFillet > 0 then
dXP5 = 0
dYP5 = - dLenRef
else
dXP5 = dXP4 - ( dLenExtra * tan(dSideAng))
dYP5 = - dTotMillHeight
dXP6 = 0
dYP6 = - dTotMillHeight
end
-- costruisco le linee
local NoCutter
local NoCutterLine
local NoCutterLine2
local NoCutterLine3
local NoCutterSurf
local tNoCutter = {}
ptP0 = Point3d( dXP0, dYP0, 0)
ptP1 = Point3d( dXP1, dYP1, 0)
if ( dYP1 - dYP2) > 0.01 then
ptP1 = Point3d( dXP1, dYP2, 0)
NoCutterLine = EgtLine(MillLayer, ptP0, ptP1, GDB_RT.GRID)
if NoCutterLine then
table.insert( tNoCutter, NoCutterLine)
end
ptP2 = Point3d( dXP2, dYP2, 0)
else
ptP2 = Point3d( dXP2, dYP1, 0)
end
if abs( dXP1 - dXP2) > 0.01 then
NoCutterLine2 = EgtLine(MillLayer, ptP1, ptP2, GDB_RT.GRID)
if NoCutterLine2 then
table.insert( tNoCutter, NoCutterLine2)
end
end
if dYP3 and ( dYP2 - dYP3) > 0.01 then
ptP3 = Point3d( dXP3, dYP3, 0)
ptLenC = ptP3
NoCutterLine3 = EgtLine(MillLayer, ptP2, ptP3, GDB_RT.GRID)
if NoCutterLine3 then
table.insert( tNoCutter, NoCutterLine3)
end
else
ptLenC = ptP2
end
-- disegno la superfice non tagliente
if #tNoCutter > 0 then
NoCutter = EgtCurveCompo( MillLayer, tNoCutter, true)
NoCutterSurf = EgtSurfTmByRevolve( MillLayer, NoCutter, Point3d(0,0,0), Vector3d(0,-1,0), false, 0.01, GDB_RT.GRID)
EgtSetColor( NoCutterSurf, LGRAY())
EgtErase( NoCutter)
end
-- geometria parte tagliente
local CutterLine
local CutterLine0
local CutterLine1
local CutterLine2
local CutterLine3
local CutterArc
local CutterSurf
local tCutter = {}
-- se altezza profilo minore del tagliente
if abs(dProfileHeight) < dCutterRef then
dXP3 = dXP2
dYP3 = - dLenRef + abs(dProfileHeight)
ptP3 = Point3d( dXP3, dYP3, 0)
CutterLine0 = EgtLine( MillLayer, ptP2, ptP3, GDB_RT.GRID)
if CutterLine0 then
table.insert( tCutter, CutterLine0)
end
elseif abs(dProfileHeight) == dCutterHeight then -- se uguale al tagliente
ptP3 = ptP2
end
-- costruisco le linee
ptP4 = Point3d( dXP4, dYP4, 0)
ptP5 = Point3d( dXP5, dYP5, 0)
if dCutterHeight < 0 then
CutterLine1 = EgtLine( MillLayer, ptP3, ptP5, GDB_RT.GRID)
ptP4 = ptP5
else
CutterLine1 = EgtLine( MillLayer, ptP3, ptP4, GDB_RT.GRID)
end
if CutterLine1 then
table.insert( tCutter, CutterLine1)
end
-- se utensile a punta e non ho raccordo e non devo disegnare la tip line, non faccio la linea
if dSideAng > 0 and dRadFillet <= 0 and bNoTipLine then
ptP4 = ptP5
-- se non ho raccordo e devo disegnare tip line
elseif dRadFillet <= 0 and not bNoTipLine then
if dCutterHeight >= 0 then
CutterLine2 = EgtLine( MillLayer, ptP4, ptP5, GDB_RT.GRID)
end
ptP6 = Point3d( dXP6, dYP6, 0)
CutterLine3 = EgtLine( MillLayer, ptP5, ptP6, GDB_RT.GRID)
else
CutterLine2 = EgtLine( MillLayer, ptP4, ptP5, GDB_RT.GRID)
end
if dRadFillet > 0 then
CutterArc = EgtCurveFillet( MillLayer, CutterLine1, ptP3, CutterLine2, ptP5, dRadFillet, true, GDB_RT.GRID)
if CutterArc then
table.insert( tCutter, CutterArc)
end
if bNoTipLine then
EgtErase( CutterLine2)
CutterLine2 = nil
end
end
if CutterLine2 then
table.insert( tCutter, CutterLine2)
end
if CutterLine3 then
table.insert( tCutter, CutterLine3)
end
-- in caso di lunghezza definita sulla punta
if dAddRad < 0 then
if dSideAng < 0 then -- se utensile a coda di rondine
ptLen = Point3d( (dMillDiameter/2), dYP4, 0)
else -- utensile a punta
if dMyOrigDiam == 0 then
ptLen = Point3d( 0, dYP4, 0)
else
ptLen = ptP4
end
end
else -- lunghezza profilo nella parte alta
if abs(dProfileHeight) < dCutterRef then
ptLen = Point3d( dXP2, dYP3, 0)
else
ptLen = Point3d( dXP2, dYP2, 0)
end
end
ptLenT = ptP4
-- disegno la superfice tagliente
if #tCutter > 0 then
CutterLine = EgtCurveCompo( MillLayer,tCutter, true)
CutterSurf = EgtSurfTmByRevolve( MillLayer, CutterLine, Point3d(0,0,0), Vector3d(0,-1,0), false, 0.01, GDB_RT.GRID)
EgtSetColor( CutterSurf, Color3d( 224, 0, 0))
EgtErase( CutterLine)
end
else -- altrimenti cilindrico
if dRadFillet == ( dMillDiameter/2) then
bNoTipLine = true
-- se raccordo troppo grande do errore
elseif dRadFillet > ( dMillDiameter/2) then
TOOL.ERR = 16 -- 6135
return
elseif dRadFillet > dCutterHeight then
TOOL.ERR = 21 -- 6140
return
end
dMyTotMillDiameter = dMillDiameter -- per le quotature
-- calcolo punti per gambo utensile
if dToolHolderStemDiam > 0 and dToolHolderStemDiam < dMillDiameter then
dXP0 = dToolHolderStemDiam / 2
elseif dToolHolderDiameter > 0 and ( dToolHolderDiameter - 5) < dMillDiameter then
dXP0 = ( dToolHolderDiameter - 5) / 2
else
dXP0 = dMillDiameter/2
end
dYP0 = - dToolHolderHeight
dXP1 = dXP0
dYP1 = dYP0
dXP2 = dMillDiameter/2
dYP2 = - dLenRef + dCutterHeight
dXP3 = dXP2
dYP3 = - dLenRef
dXP4 = 0
dYP4 = dYP3
-- costruisco le linee
local NoCutter
local NoCutterLine
local NoCutterLine2
local NoCutterSurf
local tNoCutter = {}
ptP0 = Point3d( dXP0, dYP0, 0)
ptP1 = Point3d( dXP1, dYP1, 0)
if ( dYP1 - dYP2) > 0.01 then
ptP1 = Point3d( dXP1, dYP2, 0)
NoCutterLine = EgtLine(MillLayer, ptP0, ptP1, GDB_RT.GRID)
if NoCutterLine then
table.insert( tNoCutter, NoCutterLine)
end
ptP2 = Point3d( dXP2, dYP2, 0)
else
ptP2 = Point3d( dXP2, dYP1, 0)
end
if abs( dXP1 - dXP2) > 0.01 then
NoCutterLine2 = EgtLine(MillLayer, ptP1, ptP2, GDB_RT.GRID)
if NoCutterLine2 then
table.insert( tNoCutter, NoCutterLine2)
end
end
-- disegno la superfice non tagliente
if #tNoCutter > 0 then
NoCutter = EgtCurveCompo( MillLayer, tNoCutter, true)
NoCutterSurf = EgtSurfTmByRevolve( MillLayer, NoCutter, Point3d(0,0,0), Vector3d(0,-1,0), false, 0.01, GDB_RT.GRID)
EgtSetColor( NoCutterSurf, LGRAY())
EgtErase( NoCutter)
end
-- geometria parte tagliente
local CutterLine
local CutterLine1
local CutterLine2
local CutterArc
local CutterSurf
local tCutter = {}
-- costruisco le linee
ptP3 = Point3d( dXP3, dYP3, 0)
ptLen = ptP3
ptP4 = Point3d( dXP4, dYP4, 0)
ptLenC = ptP2
ptLenT = ptP3
CutterLine1 = EgtLine( MillLayer, ptP2, ptP3, GDB_RT.GRID)
if CutterLine1 then
table.insert( tCutter, CutterLine1)
end
CutterLine2 = EgtLine( MillLayer, ptP3, ptP4, GDB_RT.GRID)
if dRadFillet > 0 then
CutterArc = EgtCurveFillet( MillLayer, CutterLine1, ptP2, CutterLine2, ptP4, dRadFillet, true, GDB_RT.GRID)
if CutterArc then
table.insert( tCutter, CutterArc)
end
if bNoTipLine then
EgtErase( CutterLine2)
CutterLine2 = nil
end
end
if CutterLine2 then
table.insert( tCutter, CutterLine2)
end
-- disegno la superfice tagliente
if #tCutter > 0 then
CutterLine = EgtCurveCompo( MillLayer,tCutter, true)
CutterSurf = EgtSurfTmByRevolve( MillLayer, CutterLine, Point3d(0,0,0), Vector3d(0,-1,0), false, 0.01, GDB_RT.GRID)
EgtSetColor( CutterSurf, Color3d( 224, 0, 0))
EgtErase( CutterLine)
end
end
-- Calcolo dimensione quote
local dMaxLinDim
if dLenRef > dMyTotMillDiameter then
dMaxLinDim = dMillHeight
else
dMaxLinDim = dMyTotMillDiameter
end
local dLenghtArrow = 0.05 * dMaxLinDim
local dDistQuote = 20
if dAddRad and dAddRad > 0 then -- se utensile definito nella parte alta
dDistQuote = dDistQuote + abs(dProfileHeight)
end
if dTotMillHeight > dLenRef and dRadFillet <= 0 then -- se ho in aggiunta la lunghezza totale utensile
dDistQuote = dDistQuote + ( dTotMillHeight - dLenRef)
end
local dDistQuoteY = max( dToolHolderDiameter, dMyTotMillDiameter) / 2 + 10
local dTextSize = min( 13, max( 0.1 * dMyTotMillDiameter, 0.1 * dLenRef))
local dTextDist = 5
-- quotatura lunghezza utensile
local sLenTxt = EgtNumToString( EgtToUiUnits( dMillHeight),3)
CreateLinearDimensionOnY( QuoteLayer, Point3d(0,0,0), ptLen, sLenTxt, dTextSize, dDistQuoteY, dLenghtArrow, dTextDist, true, 'LEN', GDB_RT.GRID)
-- quotatura altezza tagliente
local ptP2M = ptLenC
ptP2M:mirror(ORIG(),X_AX())
local ptP3M = ptLenT
ptP3M:mirror(ORIG(),X_AX())
-- calcolo extralunghezza
if dAddRad and dAddRad ~= 0 and -- se utensile inclinato
dTotMillHeight > dLenRef and -- se ho in aggiunta la lunghezza totale utensile
dRadFillet <= 0 then -- se non c'è raccordo utensile
local ptP5M = Point3d( ptP3M:getX(), -dTotMillHeight, 0)
local sMaxLenTxt = EgtNumToString(EgtToUiUnits( dCutterHeight + dTotMillHeight - dLenRef),3)
CreateLinearDimensionOnY( QuoteLayer, ptP2M, ptP5M, sMaxLenTxt, dTextSize, dDistQuoteY, dLenghtArrow, dTextDist, false, 'MAXEXTRA', GDB_RT.GRID)
else
local sMaxMatTxt = EgtNumToString(EgtToUiUnits( dCutterHeight),3)
CreateLinearDimensionOnY( QuoteLayer, ptP2M, ptP3M, sMaxMatTxt, dTextSize, dDistQuoteY, dLenghtArrow, dTextDist, false, 'MAXMAT', GDB_RT.GRID)
end
-- quotatura diametro
local ptP4M = Point3d( ptLen)
ptP4M:mirror( ORIG(), X_AX())
local sDiamTxt = EgtNumToString( EgtToUiUnits( dMyOrigDiam), 3)
CreateLinearDimensionOnX( QuoteLayer, ptLen, ptP4M, sDiamTxt, dTextSize, dDistQuote, dLenghtArrow, dTextDist, false, 'DIAM', GDB_RT.GRID)
-- quotatuta diametro e lunghezza ingombro solo per utensile a coda di rondine
if dAddRad and dAddRad ~= 0 and dSideAng < 0 and -- se utensile a coda di rondine
dRadFillet <= 0 then -- se non c'è raccordo utensile
-- se diametri differenti inserisco la quota
if abs( dMyTotMillDiameter - dMillDiameter) > 0.001 then
local ptP6M = Point3d( dMyTotMillDiameter / 2, -dTotMillHeight, 0)
local ptP7M = Point3d( -dMyTotMillDiameter / 2, -dTotMillHeight, 0)
local dDistQuote2 = abs(( ptLen:getY() - dDistQuote) - ptP7M:getY()) + dTextSize * 2.1
local sDiamTotTxt = EgtNumToString(EgtToUiUnits( dMyTotMillDiameter),3)
CreateLinearDimensionOnX( QuoteLayer, ptP6M, ptP7M, sDiamTotTxt, dTextSize, dDistQuote2, dLenghtArrow, dTextDist, false, 'MAXDIAM', GDB_RT.GRID, ORANGE())
end
-- se lunghezze differenti inserisco la seconda quota
if abs( dTotMillHeight - dMillHeight) > 0.001 then
local b3Solid = EgtGetBBoxGlob( Part, GDB_BB.STANDARD)
local pMax = b3Solid:getMax()
local ptP8M = Point3d( dMyTotMillDiameter / 2, -dTotMillHeight, 0)
local sLenTotTxt = EgtNumToString( EgtToUiUnits( dTotMillHeight),3)
local dDistQuoteY2 = pMax:getX() - ptP8M:getX() + dTextSize / 2
CreateLinearDimensionOnY( QuoteLayer, Point3d(0,0,0), ptP8M, sLenTotTxt, dTextSize, dDistQuoteY2, dLenghtArrow, dTextDist, true, 'LENTOT', GDB_RT.GRID, ORANGE())
end
end
TOOL.ERR = 0
end
_G.CreateTool = CreateTool