Files
Dario Sassi cc55202ec5 DataDoors 2.7c1 :
- primo commit con versione corrente.
2025-03-18 17:02:20 +01:00

3368 lines
130 KiB
Lua

--
-- 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
--
-- MachiningBase.lua by EgalWare s.r.l. 2016.07.10
-- Machining Base library
-- 2017.06.30 V1.013 FM Add function for optimization paths with same machining
-- 2017.11.17 V1.014 FM Add manage parameter dExtraThruDepth from CurrCamInfo into functions AdjustThrouIsle and AdjustVertHole
-- 2018.08.22 V1.015 FM Add parameter dBevelOffs on MakeRoughPaths function
-- 2018.08.22 V1.016 FM add parameter nForceUseShuttle on AdjustHead function to set only the forced shuttle
-- 2019.01.11 V1.017 FM Manage note Mach2nd into function FindEntitiesCompMach
-- 2019.01.14 V1.018 FM Manage note Mach2nd into functions AdjustThrouIsle and AdjustVertHole
-- 2019.01.21 V1.019 FM Add output of variable nTypeGeom on function AdjustVertHole
-- 2019.01.24 V1.01a FM Fix error into FindEntitiesCompMach on compare with sKeepProbe
-- 2019.01.24 V1.01b FM Extend cases on AdjustHeadChisel function
-- 2019.04.08 V1.01c FM Add common functions ModifyLiLo (used into AddAndDelMachining) and AdjustBladeVertCurve
-- to manage blade lead-in and lead-out
-- 2019.04.30 V1.01d FM Add functions AdjustASplintWithBlade to manage anti-splint paths when groove by blade
-- 2019.04.08 V1.01d FM Add functions AdjustHeadOnASplint to manage anti-splint path on hinge side when groove by blade
-- 2019.04.08 V1.01d FM Add common functions DefineASplint (used into AdjustHeadOnASplint and AdjustASplintWithBlade)
-- 2019.07.17 V1.01e FM Manage better the delta angle when probemode is active on function AdjustHorizDrillX and AdjustHorizDrillY
-- 2019.08.27 V1.01f FM Release Notes info on exit of AddAndDelMachining function
-- 2019.08.27 V1.01f FM Add FindGeomWithNote function
-- 2019.10.01 V1.020 FM Delete function FindProperties (already present into EgtDoorBase as FindProperty)
-- 2019.10.01 V1.021 FM Add AdjPrfThrouCurveNew function
-- 2019.10.17 V1.023 FM Manage note for blade into AdjustThrouIsle
-- 2019.10.18 V2.000 FM Manage use Materials
-- 2019.10.21 V2.001 FM Add function ModifyLiLoToExt to modify lead-in and lead-out for strike steel machining
-- 2019.11.11 V2.002 FM Into function MakeRoughPaths manage also Top chamfer shape
-- 2019.12.02 V2.003 FM Modify function ModifyLiLoToExt to disable also oscillation parameters
-- 2020.12.22 V2.004 FM Manage Open Paths into TestThrouIsle and AdjustThrouIsle functions
-- 2021.04.02 V2.005 FM Manage Closed paths with no area into TestThrouIsle and AdjustThrouIsle functions
-- 2021.05.25 V2.006 FM Manage Closed paths with no area into TestVertHole and AdjustVertHole functions
-- 2021.11.24 V2.007 FM Add functions AdjustProbeMill to manage probe paths
-- 2022.02.21 V2.008 FM Manage machining note CUT_LENGTH=xxx to machine only distance defined by value (in mm)
-- 2023.05.24 V2.009 FM Add function AdjustVertAsOnHeads to modify anti split paths (of door heads) to be vertical on bevelled sides
-- 2023.07.26 V2.00a FM Fix error on calculate area on closed curved into AdjustThrouIsle function
-- 2023.09.16 V2.00b FM Manage to invert path also with Zpositive direction path into AdjustThrouCurve function
-- 2023.10.25 V2.00c FM Manage add extra leadout length into AddAndDelMachining
-- 2023.10.25 V2.00d FM Manage new input interface parameter nModeOrder into OrderEnt function
-- to have head machining ordered from X pos to X neg
-- 2023.10.25 V2.00d FM Manage new input interface parameter bNoModifyPath into AdjustBevel function
-- to manage 5 axis head and 3 axis head ( that machine bevel profile) on same machine
-- 2023.11.13 V2.00e FM into AddAndDelMachining function let to Outpuut the machining note also when 'not generation machining' flag is enable
-- 2024.01.19 V2.010 FM Fix error into InsZedByTool when use max function with a paarameter at nil value
-- 2024.05.31 V2.011 FM Add to function interface (and manage) the bNarrowDoor parameter into AddAndDelMachining function let to manage narrow doors
-- Add to function interface (and manage) the bSkipOnSecCol parameter into AdjustBevel function
-- Add to function interface (and manage) the bSkipOnSecCol parameter into AdjustThrouCurve function
-- 2024.06.21 V2.012 FM Manage to set clockwise direction on closed path into Adjusthead (by new parameter: bCheckDirection)
-- 2024.10.30 V2.013 FM into GetToolDataFromAttrib function, if force read thicknnes is enabled get the mill max thickness as blade thickness
-- in case mill is used instead blade
-- 2024.11.14 V2.014 FM Manage the flipping geometry into AdjustConeCleanPaths from solid layer than geometry
-- 2025.01.13 V2.015 FM Initialize DGD.GHT to be compatible with old Machining_xxx
-- 2025.01.17 V2.016 FM Set infos (Parent and LinkCode) to ghost paths (into MakeGhostCopy function)
-- and disable the machining that has info LinkCode with negative value ( into AddAndDelMachining function)
-- 2025.01.20 V2.017 FM Manage new info type 'InvDir' from groove compo into funtion ModifyLiLo
require( 'EgtBase')
require( 'EgtConst')
local EgtDoorsMsg = require( 'EgtDoorsMsg')
-- Tavola per definizione modulo
local MachiningBase = {}
print( 'MachiningBase started')
DoorOutLog( ' MachiningBase started', 1)
-- set the DGD with old value to be compatible with old Machining_x files
if not DGD.GHT then
DGD.GHT = '_HIDE'
end
-----------------------------------------------------------------
-- *** Disposition Functions ***
-----------------------------------------------------------------
--------------------------------------------------------------------------------
function MachiningBase.AdjustXFixture( dX)
-- per non trovarsi tra i due tavoli
if dX > 2360 and dX < 2570 then
dX = 2570
end
return dX
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustXReference( dX, HintList)
local DX_ENG = 200
dX = MachiningBase.AdjustXFixture( dX)
--for i = 1, #HintList, 2 do
-- if dX > HintList[i] - DX_ENG and dX < HintList[i+1] + DX_ENG then
-- dX = HintList[i] - DX_ENG
-- end
--end
return dX
end
-----------------------------------------------------------------
-- *** Make Ghost copy of entity ***
-----------------------------------------------------------------
function MachiningBase.MakeGhostCopy( EntId, bCheckDirection)
local sParnt = EgtGetParent( EntId)
local EntName = EgtGetName( EntId)
local nNewEntId = EgtCopyGlob( EntId, sParnt)
EgtSetName( nNewEntId, EntName..DGD.GHT)
EgtSetStatus( nNewEntId, GDB_ST.OFF)
-- Se ottimizzazione lavorazioni macchine in linea
if DGD.OML then
EgtSetInfo( nNewEntId, 'Parent', EntId)
end
-- assegno nota con valore il campo Link della Mtable
if DGD.LVL and abs(DGD.LVL) > 0 then
EgtSetInfo( nNewEntId, 'LinkCode', DGD.LVL)
end
-- se check per verifica direzione percorso
if bCheckDirection then
-- verifico se ho la nota per non fare il controllo di direzione percorso ( per esempio le svuotature in centro utensile)
local nNotCheck = EgtGetInfo( nNewEntId, 'NotCheckDir', 'i') or 0
-- se la nota vale 0 o non ho la nota faccio la verifica
if nNotCheck == 0 then
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( nNewEntId, GDB_ID.ROOT)
local vtMPlane, dDist, dArea
-- verifico se il percorso è chiuso
if EgtCurveIsClosed( nNewEntId) then
-- impongo senso di rotazione orario visto da sopra
vtMPlane, dDist, dArea = EgtCurveArea( nNewEntId)
if abs( dArea) < 1 then
-- Rimando il valore originario in caso avessi skippato la lavorazione
return nNewEntId
end
-- altrimenti non è chiuso
else
-- faccio una copia del percorso
local nNewEntId2 = EgtCopyGlob( nNewEntId, sParnt)
-- chiudo il percorso
if EgtCloseCurveCompo( nNewEntId2) then
-- impongo senso di rotazione orario visto da sopra
vtMPlane, dDist, dArea = EgtCurveArea( nNewEntId2)
EgtErase(nNewEntId2)
if dArea and abs( dArea) < 1 then
-- Rimando il valore originario in caso avessi skippato la lavorazione
return nNewEntId
end
else
EgtErase(nNewEntId2)
-- impongo senso di rotazione orario visto da sopra
vtMPlane, dDist, dArea = EgtCurveArea( nNewEntId)
if not dArea or abs( dArea) < 1 then
-- Rimando il valore originario in caso avessi skippato la lavorazione
return nNewEntId
end
end
end
local frEnt = EgtGetGlobFrame( nNewEntId)
if vtMPlane then
vtMPlane:toGlob(frEnt)
if dArea and dArea * ( vtMPlane * vtExtr) > 0 then
EgtInvertCurve( nNewEntId)
end
end
end
end
return nNewEntId
end
-----------------------------------------------------------------
-- *** Seeking Functions ***
-----------------------------------------------------------------
--------------------------------------------------------------------------------
function MachiningBase.FindEntitiesCompMach( nEntId, tEntList, sMachining, nJoinGeomInMach, nMaxDist, bSameLayer, bSameSecMach)
local List = {}
-- inserisco per prima l'entità passata
table.insert( List, nEntId)
-- acquisisco il padre dell'entità passata
local nParendId = EgtGetParent(nEntId)
-- punto iniziale entità passata
local pIni1 = EgtSP( nEntId, GDB_ID.ROOT)
-- nota correzione in Z per probe
local sKeepProbe = EgtGetInfo( nEntId, 'KeepBackSet') or '0'
local sNoteProbes = EgtGetInfo( nEntId, 'ProbeSide') or '0'
-- se direzione fresa da sotto esco subito
local vtExtr = EgtCurveExtrusion( nEntId, GDB_ID.ROOT) -- recupero versore estrusione
-- parametro link
local nCheckLink = EgtGetInfo( nEntId, 'LinkCode', 'i') or 0
local bEnablekinkCheck = DGD.OML
-- --------------------------------------------------------------------------------------
-- provvisoriamente lascio attiva la gestione del Join anche se ho il parametro LinkCode
-- nel caso si voglia disabilitare il join commentare la linea bEnablekinkCheck = false
-- --------------------------------------------------------------------------------------
bEnablekinkCheck = false
-- se non ha codice link, non abilitato, con distanza valida e non diretto verso il basso
if ( nCheckLink == 0 or not bEnablekinkCheck) and nJoinGeomInMach and nJoinGeomInMach > 0 and nMaxDist and nMaxDist > 0 and vtExtr:getZ() > - 0.1 then
for i = 1, #tEntList do
if tEntList[i] and tEntList[i] ~= nEntId then
-- se sono nello stesso layer
if not bSameLayer or EgtGetParent( tEntList[i]) == nParendId then
-- se non ha parametro link
nCheckLink = EgtGetInfo( tEntList[i], 'LinkCode', 'i') or 0
if ( nCheckLink == 0 or not bEnablekinkCheck) then
local sMachNote = EgtGetInfo( tEntList[i], 'Machining')
-- se hanno la stessa lavorazione
if sMachNote and sMachNote == sMachining then
-- se non è già stata lavorata
local nSecMach = EgtGetInfo( tEntList[i], 'Mach2nd', 'i') or 0
if bSameSecMach or nSecMach == 0 then
local vtExtr1 = EgtCurveExtrusion( tEntList[i], GDB_ID.ROOT) -- recupero versore estrusione
if AreSameVectorApprox( vtExtr1, vtExtr) then -- se direzioni uguali
local pIni2 = EgtSP( tEntList[i], GDB_ID.ROOT)
local sKeepProbe2 = EgtGetInfo( tEntList[i], 'KeepBackSet') or '0'
local sNoteProbes2 = EgtGetInfo( tEntList[i], 'ProbeSide') or '0'
-- se la distanza tra loro è inferiore della massima
if dist( pIni1, pIni2) <= nMaxDist then
-- se hanno note uguali
if sKeepProbe == sKeepProbe2 or sNoteProbes == sNoteProbes2 then
table.insert( List, tEntList[i])
-- pIni1 = pIni2 -- diventa il nuovo punto
end
end
end
end
end
end
end
end
end
end
return List
end
--------------------------------------------------------------------------------
function MachiningBase.FindEntitiesWithNameFromTab( ListPrev, sName)
local List = {}
if ListPrev then
for i = 1, #ListPrev do
local sEntName = EgtGetName( ListPrev[i])
if sEntName and sEntName == sName then
table.insert( List, ListPrev[i])
end
end
end
return List
end
--------------------------------------------------------------------------------
function MachiningBase.FindEntitiesWithName( Pz, sName, ListPrev)
local List = {}
local PzIsTab = type(Pz) == 'table'
if ListPrev then
for i = 1, #ListPrev do
table.insert( List, ListPrev[i])
end
end
local nMaxPz = 1
if PzIsTab then nMaxPz = #Pz end
for i = 1, nMaxPz do
local nIdPz
if PzIsTab then nIdPz = Pz[i] else nIdPz = Pz end
local Ly = EgtGetFirstGroupInGroup( nIdPz)
while Ly do
local Ent = EgtGetFirstNameInGroup( Ly, sName)
while Ent do
table.insert( List, Ent)
Ent = EgtGetNextName( Ent, sName)
end
Ly = EgtGetNextGroup( Ly)
end
end
return List
end
--------------------------------------------------------------------------------
function MachiningBase.FindGroupWithPartName( Pz, sNameFind, ListPrev)
local List = {}
local PzIsTab = type(Pz) == 'table'
if ListPrev then
for i = 1, #ListPrev do
table.insert( List, ListPrev[i])
end
end
local nMaxPz = 1
if PzIsTab then nMaxPz = #Pz end
for i = 1, nMaxPz do
local nIdPz
if PzIsTab then nIdPz = Pz[i] else nIdPz = Pz end
local Ent = EgtGetFirstInGroup( nIdPz)
while Ent do
local sNameEnt = EgtGetName(Ent)
if sNameEnt and string.find( sNameEnt, sNameFind) then
table.insert( List, Ent)
end
Ent = EgtGetNext( Ent)
end
end
return List
end
--------------------------------------------------------------------------------
function MachiningBase.FindEntitiesWithPartName( Pz, sNameFind, ListPrev, sInfoName, nInfoValue)
local List = {}
local ListTwo = {}
local PzIsTab = type(Pz) == 'table'
if ListPrev then
for i = 1, #ListPrev do
table.insert( List, ListPrev[i])
end
end
local nMaxPz = 1
if PzIsTab then nMaxPz = #Pz end
for i = 1, nMaxPz do
local nIdPz
if PzIsTab then nIdPz = Pz[i] else nIdPz = Pz end
local Ly = EgtGetFirstGroupInGroup( nIdPz)
while Ly do
local Ent = EgtGetFirstInGroup( Ly)
while Ent do
local sNameEnt = EgtGetName(Ent)
if sNameEnt and string.find( sNameEnt, sNameFind) then
-- se note da ricercare
if sInfoName and nInfoValue and #sInfoName > 0 and nInfoValue > 0 then
-- se nota corrisponde
if EgtGetInfo( Ent, sInfoName, 'i') == nInfoValue then
table.insert( ListTwo, Ent)
else
table.insert( List, Ent)
end
else
table.insert( List, Ent)
end
end
Ent = EgtGetNext( Ent)
end
Ly = EgtGetNextGroup( Ly)
end
end
return List, ListTwo
end
--------------------------------------------------------------------------------
function MachiningBase.FindEntities( Pz, bSingle)
local List = {}
local Ly = EgtGetFirstInGroup( Pz)
while Ly do
if bSingle then
return Ly -- esco appena ha trovato il primo trovato
else
table.insert( List, Ly) -- inserisco a tabella
end
Ly = EgtGetNext( Ly)
end
if bSingle then
return nil
else
return List
end
end
--------------------------------------------------------------------------------
function MachiningBase.FindGeomWithName( Pz, sName, bSingle, ListPrev)
local List = {}
if ListPrev and not bSingle then
for i = 1, #ListPrev do
table.insert( List, ListPrev[i])
end
end
local Ly = EgtGetFirstInGroup( Pz)
while Ly do
local Ent = EgtGetName( Ly)
if Ent == sName then
if bSingle then
return Ly -- esco appena ha trovato il primo elemento
else
table.insert( List, Ly) -- inserisco a tabella
end
end
Ly = EgtGetNext( Ly)
end
if bSingle then
return nil
else
return List
end
end
--------------------------------------------------------------------------------
function MachiningBase.FindGeomWithNote( Pz, sNote, sTypeNote, NoteToFind, ListPrev)
local List = {}
if ListPrev then
for i = 1, #ListPrev do
table.insert( List, ListPrev[i])
end
end
local Ly = EgtGetFirstInGroup( Pz) -- ottengo il primo layer
while Ly do
-- ottengo la prima entità del layer
local Lx = EgtGetFirstInGroup( Ly)
while Lx do
local Ent = EgtGetInfo( Lx, sNote, sTypeNote)
if sTypeNote == 'b' then -- se nota booleana
if Ent then -- se trovata nota boolena
table.insert( List, Lx) -- inserisco a tabella
end
else
if Ent == NoteToFind then
table.insert( List, Lx) -- inserisco a tabella
end
end
Lx = EgtGetNext( Lx)
end
Ly = EgtGetNext( Ly)
end
return List
end
--------------------------------------------------------------------------------
function MachiningBase.GetHingesBoxes( Pz, tabOriX)
local List = {}
local Ly = EgtGetFirstGroupInGroup( Pz)
while Ly do
local sName = EgtGetName( Ly)
if sName and string.find( sName, 'Hinge', 1, true) then
local b3Box = EgtGetBBoxGlob( Ly, GDB_BB.STANDARD)
if b3Box then
table.insert( List, b3Box:getMin():getX() - tabOriX)
table.insert( List, b3Box:getMax():getX() - tabOriX)
end
end
Ly = EgtGetNextGroup( Ly)
end
return List
end
--------------------------------------------------------------------------------
function MachiningBase.ReorderGroup( EntId, tOrderGrp, nDirToIns)
local nParendId = EgtGetParent(EntId)
local b3Grp = EgtGetBBoxGlob( nParendId, GDB_BB.STANDARD)
local dRefGrp = EgtIf( nDirToIns > 0, b3Grp:getMin():getX(), b3Grp:getMax():getX())
-- controllo dalla nota se non è già stata lavorata prima
local nSetSide = EgtGetInfo( EntId, 'Mach', 'i') or 0
-- se già lavorata annullo valore disabilitante
if nSetSide >= 10 then
EgtSetInfo( EntId, 'Mach', 0)
end
-- se trovato minimo lo assegno in testa
if #tOrderGrp == 0 then
table.insert( tOrderGrp, { nParendId, dRefGrp})
else
local bInsert = false
local bfoundGroup = false
for i = 1, #tOrderGrp do
-- se trovato minimo lo inserisco in tabella e ne riloco il gruppo nell'albero
local nIdParTab = tOrderGrp[i]
if nDirToIns > 0 then
if dRefGrp < nIdParTab[2] then
table.insert( tOrderGrp, i,{ nParendId, dRefGrp})
EgtRelocateGlob( nParendId, nIdParTab[1], GDB_IN.BEFORE)
bInsert = true
break
elseif nParendId == nIdParTab[1] then -- se gruppo già presente esco
bfoundGroup = true
break
end
else
if dRefGrp > nIdParTab[2] then
table.insert( tOrderGrp, i,{ nParendId, dRefGrp})
EgtRelocateGlob( nParendId, nIdParTab[1], GDB_IN.BEFORE)
bInsert = true
break
elseif nParendId == nIdParTab[1] then -- se gruppo già presente esco
bfoundGroup = true
break
end
end
end
-- se non inserito lo inserisco in coda senza rilocamento
if not bInsert and not bfoundGroup then
table.insert( tOrderGrp, { nParendId, dRefGrp})
end
end
end
--------------------------------------------------------------------------------
function MachiningBase.GetGroup( tLocMachOrd, ind, nNumGroup, sProperty)
local tSubGroup = {}
local nIdt = ind
if sProperty and #sProperty > 0 then -- acquisisco tutto il gruppo
for j = ind, #tLocMachOrd do
if tLocMachOrd[j].Group == nNumGroup then
table.insert( tSubGroup, tLocMachOrd[j])
nIdt = j
else -- se non è più lo stesso gruppo esco
break
end
end
else
table.insert( tSubGroup, tLocMachOrd[nIdt]) -- restituisco solo una linea della tabella
end
return tSubGroup, nIdt
end
--------------------------------------------------------------------------------
function MachiningBase.LoadEntitiesFromGroup( tGroup, Pz, sSuffix)
local EntList
for j = 1, #tGroup do
EntList = MachiningBase.FindEntitiesWithName( Pz, tGroup[j].Name..sSuffix, EntList)
end
return EntList
end
--------------------------------------------------------------------------------
function MachiningBase.InsZedByTool( TabZMach, tMachining, nInd)
local bFind = false
local nMaxVal = 0
for i = 1, nInd-1 do
if tMachining[nInd][2] == tMachining[i][2] then -- se utensile uguale assegno identico valore
table.insert( TabZMach, TabZMach[i]) -- inserisco lo stesso valore
bFind = true
break -- esco dal ciclo
else
nMaxVal = max( nMaxVal, (TabZMach[i] or 0))
end
end
if not bFind then -- se non ho trovato aggiungo nuovo valore alla Z utensile
table.insert( TabZMach, ( nMaxVal+10000))
end
end
--------------------------------------------------------------------------------
function MachiningBase.OrderEnt( tListEntSameMach, EndLastMach, nModeOrder)
-- Tavole per fresature da ordinare
local TabMill = {}
local TabMStEnP = {}
local TabResult = {}
local dStart = -2000
if nModeOrder and nModeOrder == 1 then
dStart = 10000
end
for m = 1, #tListEntSameMach do
local ptStart = EgtSP( tListEntSameMach[m], GDB_ID.ROOT )
if ptStart then
table.insert( TabMill, tListEntSameMach[m])
table.insert( TabMStEnP, ptStart)
end
end
-- calcolo ordinamento
EgtSpInit()
for m = 1, #TabMill do
EgtSpAddPoint( TabMStEnP[m]:getX(), TabMStEnP[m]:getY(), TabMStEnP[m]:getZ(), 0, 0,
TabMStEnP[m]:getX(), TabMStEnP[m]:getY(), TabMStEnP[m]:getZ(), 0, 0)
end
if EndLastMach then
EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,EndLastMach:getX(),EndLastMach:getY(),0,90,90)
else
EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,dStart,0,0,90,90)
end
local vMillOrd
if not nModeOrder or nModeOrder == 0 then
vMillOrd = EgtSpCalculate(SHP_TY.OPEN)
elseif nModeOrder == 1 then
vMillOrd = EgtSpCalculate(SHP_TY.ONEWAY_XP)
else
vMillOrd = EgtSpCalculate(SHP_TY.OPEN)
end
EgtSpTerminate()
-- applico ordinamento calcolato
if vMillOrd and #vMillOrd == #tListEntSameMach then
for m = 1, #vMillOrd do
table.insert( TabResult, TabMill[vMillOrd[m]])
end
tListEntSameMach = TabResult
end
return tListEntSameMach
end
--------------------------------------------------------------------------------
function MachiningBase.DefineASplint( EntId, nDispType, bFlipDoor, nMaxNum)
-- recupero note percorso
local bCutByBlade = EgtGetInfo( EntId, 'UseBlade', 'b')
local bCutByTwiceBlade = EgtGetInfo( EntId, 'UseTwiceBl', 'b')
-- se utilizzata lama
if bCutByBlade then
-- se uso doppia lama assegno la seconda lavorazione
if bCutByTwiceBlade then
-- lavorazione 2nd
EgtSetInfo( EntId, 'Mach', nMaxNum)
return nMaxNum
else -- altrimenti leggo altre note
local sSideApp = EgtGetInfo( EntId, 'SideApp', 's')
local nTypePath = EgtGetInfo( EntId, 'TypePath', 'i')
if sSideApp and nTypePath then
if sSideApp == 'hinge' or sSideApp == 'lock' then
if bFlipDoor then -- se porta ribaltata
if nTypePath == 1 then -- se percorso antisplint 1
EgtSetInfo( EntId, 'Mach', nMaxNum) -- eventualmente lo disabilito
return nMaxNum
else -- percorso antisplint 2
EgtRemoveInfo( EntId, 'Mach')
return 0
end
else -- non ribaltata
if nTypePath == 1 then -- se percorso antisplint 1
EgtRemoveInfo( EntId, 'Mach')
return 0
else -- percorso antisplint 2
EgtSetInfo( EntId, 'Mach', nMaxNum) -- eventualmente lo disabilito
return nMaxNum
end
end
else
if ( sSideApp == 'top' and nDispType > 0) or ( sSideApp == 'bottom' and nDispType < 0 ) then
if nTypePath == 1 then -- se percorso lato hinge
EgtRemoveInfo( EntId, 'Mach')
return 0
else -- se percorso lato lock
EgtSetInfo( EntId, 'Mach', nMaxNum) -- eventualmente lo disabilito
return nMaxNum
end
else
if nTypePath == 1 then -- se percorso lato hinge
EgtSetInfo( EntId, 'Mach', nMaxNum) -- eventualmente lo disabilito
return nMaxNum
else -- se percorso lato lock
EgtRemoveInfo( EntId, 'Mach')
return 0
end
end
end
end
end
else
-- lavorazione standard
EgtRemoveInfo( EntId, 'Mach')
end
return 0
end
-----------------------------------------------------------------
-- *** Machining Functions ***
-----------------------------------------------------------------
-----------------------------------------------------------------
function MachiningBase.ModifyLiLoToExt()
-- leggo il parametro di lunghezza perpendicolare di ingresso
local dLenIniPerp = EgtGetMachiningParam( MCH_MP.LIPERP)
local sTuuid = EgtGetMachiningParam( MCH_MP.TUUID)
local sTool = EgtTdbGetToolFromUUID( sTuuid)
EgtTdbSetCurrTool( sTool)
local dDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
if dLenIniPerp then
if dLenIniPerp > 0 then
dLenIniPerp = -dLenIniPerp
else -- altrimenti è a 0
dLenIniPerp = -(dDiam*0.55)
end
else -- altrimenti lo calcolo dall'utensile
dLenIniPerp = -(dDiam*0.55)
end
-- cambio il lead-in a lineare
EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.LINEAR)
-- setto a 0 l'allungamento iniziale
EgtSetMachiningParam( MCH_MP.STARTADDLEN, 0.762)
-- setto a 0 la lunghezza tangente ingresso
EgtSetMachiningParam( MCH_MP.LITANG, 0)
-- setto il valore di distanza perpendicolare uscita come quella dell'ingresso
EgtSetMachiningParam( MCH_MP.LIPERP, dLenIniPerp)
-- setto a 0 l'elevazione iniziale
EgtSetMachiningParam( MCH_MP.LIELEV, 0)
-- setto a 0 l'inserimento correttore attacco
EgtSetMachiningParam( MCH_MP.LICOMPLEN , 0)
-- cambio il lead-out a lineare
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LI.LINEAR)
-- 2019/12/20 setto a -0.6 il valore di distanza perpendicolare
-- 2020/05/18 setto a 0 il valore di distanza perpendicolare
EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0)
-- setto a 0 l'allungamento finale
-- EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0)
-- setto a 0 il valore tangente finale
EgtSetMachiningParam( MCH_MP.LOTANG, 0)
-- 2019/12/20 setto a 0 il valore di distanza perpendicolare
EgtSetMachiningParam( MCH_MP.LOPERP, 0)
-- setto il valore di distanza perpendicolare uscita come quella dell'ingresso
-- EgtSetMachiningParam( MCH_MP.LOPERP, dLenIniPerp)
-- setto a 0 l'elevazione
EgtSetMachiningParam( MCH_MP.LOELEV, 0)
-- setto a 0 l'inserimento correttore uscita
EgtSetMachiningParam( MCH_MP.LOCOMPLEN , 0)
-- disabilito eventuale oscillazione
EgtSetMachiningParam( MCH_MP.OSCENABLE, false)
-- setto a 0 la sovrapposizione 2019/12/20
EgtSetMachiningParam( MCH_MP.OVERL , 0)
end
-----------------------------------------------------------------
function MachiningBase.ModifyLiLo( sLeadCode, bRevCode, sPathType, sToolUse, dCalcLead, dPercFeedVal, sDirType)
-- leggo il parametro di lunghezza perpendicolare di ingresso
local dLenIniPerp = EgtGetMachiningParam( MCH_MP.LIPERP)
-- leggo il parametro feed per moltiplicarlo con il fattore di riduzione per l'ingresso nel pieno
local dFeedVal = EgtGetMachiningParam( MCH_MP.FEED)
-- cambio il lead-in a lineare
EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.LINEAR)
if bRevCode and ( sLeadCode == '_NLI' or sLeadCode == '_NLO') then
if sPathType and sPathType == 'NR' and sToolUse then
-- setto a 0 l'allungamento iniziale
EgtSetMachiningParam( MCH_MP.STARTADDLEN, 0)
-- cambio la feed di ingresso con la Feed ricalcolata con il parametro
EgtSetMachiningParam( MCH_MP.STARTFEED, (dFeedVal*dPercFeedVal))
else
if sDirType == 'INV' then
-- setto a 0 l'allungamento iniziale
EgtSetMachiningParam( MCH_MP.STARTADDLEN, 0)
-- cambio la feed di ingresso con la Feed ricalcolata con il parametro
EgtSetMachiningParam( MCH_MP.STARTFEED, (dFeedVal*dPercFeedVal))
else
-- setto al valore l'allungamento iniziale
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dCalcLead)
end
end
elseif ( not bRevCode and sLeadCode == '_NLO') then
if sPathType and sPathType == 'NR' and sToolUse then
-- setto a 0 l'allungamento iniziale
EgtSetMachiningParam( MCH_MP.STARTADDLEN, 0)
-- cambio la feed di ingresso con la Feed ricalcolata con il parametro
EgtSetMachiningParam( MCH_MP.STARTFEED, (dFeedVal*dPercFeedVal))
else
-- setto al valore l'allungamento iniziale
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dCalcLead)
end
elseif ( not bRevCode and sLeadCode == '_NLI') then
if sDirType == 'INV' then
-- setto al valore l'allungamento iniziale
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dCalcLead)
else
-- setto a 0 l'allungamento iniziale
EgtSetMachiningParam( MCH_MP.STARTADDLEN, 0)
-- cambio la feed di ingresso con la Feed ricalcolata con il parametro
EgtSetMachiningParam( MCH_MP.STARTFEED, (dFeedVal*dPercFeedVal))
end
else
-- setto a 0 l'allungamento iniziale
EgtSetMachiningParam( MCH_MP.STARTADDLEN, 0)
-- cambio la feed di ingresso con la Feed ricalcolata con il parametro
EgtSetMachiningParam( MCH_MP.STARTFEED, (dFeedVal*dPercFeedVal))
end
-- setto a 0 la lunghezza tangente ingresso
EgtSetMachiningParam( MCH_MP.LITANG, 0)
-- cambio il lead-out a lineare
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LI.LINEAR)
if ( bRevCode and sLeadCode == '_NLO') then -- Se percorso REV con niente uscita
if sPathType and sPathType == 'NR' then -- se percorso di andata
-- setto al valore l'allungamento finale
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dCalcLead)
else
-- setto a 0 l'allungamento finale
EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0)
end
elseif ( bRevCode and sLeadCode == '_NLI') then -- Se percorso REV con niente ingresso
if sPathType and sPathType == 'NR' then -- se percorso di andata
if sDirType == 'INV' then
-- setto al valore l'allungamento finale
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dCalcLead)
else
-- setto a 0 l'allungamento finale
EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0)
end
else
-- setto al valore l'allungamento finale
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dCalcLead)
end
elseif ( not bRevCode and sLeadCode == '_NLI') then
if sPathType and sPathType == 'NR' and sToolUse then
-- setto a 0 l'allungamento finale
EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0)
else
if sDirType == 'INV' then
-- setto a 0 l'allungamento finale
EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0)
else
-- setto al valore l'allungamento finale
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dCalcLead)
end
end
elseif ( not bRevCode and sLeadCode == '_NLO') then
if sPathType and sPathType == 'NR' and sToolUse then
-- setto al valore l'allungamento finale
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dCalcLead)
else
-- setto a 0 l'allungamento finale
EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0)
end
else
-- setto a 0 l'allungamento finale
EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0)
end
-- setto a 0 il valore tangente finale
EgtSetMachiningParam( MCH_MP.LOTANG, 0)
-- setto il valore di distanza perpendicolare uscita come quella dell'ingresso
EgtSetMachiningParam( MCH_MP.LOPERP, dLenIniPerp)
end
-----------------------------------------------------------------
function MachiningBase.AddAndDelMachining( sName, sMach, tEntId, dOverL, sOriName,
bNotGenMachining, sCodeKeepBackSet, dBladePerpLeadIn, dPercRedFeed, sCodeProbeSide,
sActiveStop, sSetMaxElev, dOverR, bSandFound, dAddLength,
dAddSandLength, bNarrowDoor)
local sEntId = ''
local tParentId = {}
local sNotesMach
local nCheckLink
for t = 1, #tEntId do
if tEntId[t] then
if not bNotGenMachining then
-- load the Link value if exists
if not nCheckLink or nCheckLink == 0 then
nCheckLink = EgtGetInfo( tEntId[t], 'LinkCode', 'i') or 0
end
-- acquisisco le note Parent delle entità
table.insert( tParentId, EgtGetInfo( tEntId[t], 'Parent', 'i'))
end
sEntId = sEntId .. tEntId[t] .. ','
end
end
if not sMach or ( sMach and #sMach == 0) then
DGD.ERM = DGD.ERM .. string.format( EgtDoorsMsg[483], sOriName, sEntId)
return 0 -- nome lavorazione vuoto
end
local nMach = EgtAddMachining( sName, sMach)
local sTool
if not nMach then
DGD.EMC = DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[484], sMach, sOriName, sEntId)
return -1 -- lavorazione mancante o errata
end
if dOverL then -- se c'è un valore, assegno sovramateriale in lunghezza
EgtSetMachiningParam( MCH_MP.OFFSL, dOverL)
end
if dOverR and dOverR > 0 then -- se c'è un valore, assegno offset sul raggio
EgtSetMachiningParam( MCH_MP.OFFSR, dOverR)
end
if sCodeKeepBackSet then -- se c'è un valore, assegno codice correzione in Z
sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES)
if not sNotesMach or #sNotesMach == 0 then -- se la nota è vuota aggiungo il codice
EgtSetMachiningParam( MCH_MP.USERNOTES, sCodeKeepBackSet..';')
else -- altrimenti se non è vuota verifico se c'è o no
-- verifico se c'é già parte iniziale del codice 'CORR_Z_PROBE' settato nel Machining_xvx nella funzione InsertMachiningByMachNum
local sFirst = string.sub( sCodeKeepBackSet, 1, 12)
local nPosFind, _ = sNotesMach:find( sFirst, 1, true)
if nPosFind then -- se ho già la prima parte
if not sNotesMach:find( sCodeKeepBackSet, 1, true) then -- se non ho la stessa nota la sostituisco
sNotesMach = string.gsub( sNotesMach, string.sub( sNotesMach, nPosFind, 14), sCodeKeepBackSet)
end
else -- se non ho la prima parte la aggiungo
sNotesMach = sNotesMach..sCodeKeepBackSet..';'
EgtSetMachiningParam( MCH_MP.USERNOTES, sNotesMach)
end
end
end
if sCodeProbeSide then
sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES)
if not sNotesMach or #sNotesMach == 0 then -- se la nota è vuota aggiungo il codice
EgtSetMachiningParam( MCH_MP.USERNOTES, sCodeProbeSide..';')
else -- altrimenti se non è vuota verifico se c'è o no
-- verifico se c'é già parte iniziale del codice 'CPBP' settato nel Machining_xvx nella funzione InsertMachiningByMachNum
local sFirst = string.sub( sCodeProbeSide, 1, 4)
local nPosFind, _ = sNotesMach:find( sFirst, 1, true)
if nPosFind then -- se ho già la prima parte
if not sNotesMach:find( sCodeProbeSide, 1, true) then -- se non ho la stessa nota la sostituisco
sNotesMach = string.gsub( sNotesMach, string.sub( sNotesMach, nPosFind, 4), sCodeProbeSide)
end
else -- se non ho la prima parte la aggiungo
sNotesMach = sNotesMach..sCodeProbeSide..';'
EgtSetMachiningParam( MCH_MP.USERNOTES, sNotesMach)
end
end
end
if sActiveStop then
sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES)
if not sNotesMach or #sNotesMach == 0 then -- se la nota è vuota aggiungo il codice
EgtSetMachiningParam( MCH_MP.USERNOTES, sActiveStop..';')
else -- altrimenti se non è vuota verifico se c'è o no
-- verifico se c'é già parte iniziale del codice 'ActiveStopMach' settato nel Machining_xvx nella funzione InsertMachiningByMachNum
local sFirst = string.sub( sActiveStop, 1, 14)
local nPosFind, _ = sNotesMach:find( sFirst, 1, true)
if nPosFind then -- se ho già la prima parte
if not sNotesMach:find( sActiveStop, 1, true) then -- se non ho la stessa nota la sostituisco
sNotesMach = string.gsub( sNotesMach, string.sub( sNotesMach, nPosFind, 16), sActiveStop)
end
else -- se non ho la prima parte la aggiungo
sNotesMach = sNotesMach..sActiveStop..';'
EgtSetMachiningParam( MCH_MP.USERNOTES, sNotesMach)
end
end
end
if sSetMaxElev then
sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES)
if not sNotesMach or #sNotesMach == 0 then -- se la nota è vuota aggiungo il codice
EgtSetMachiningParam( MCH_MP.USERNOTES, sSetMaxElev..';')
else -- altrimenti se non è vuota verifico se c'è o no
-- verifico se c'é già parte iniziale del codice 'MaxElev' settato nel Machining_xvx nella funzione InsertMachiningByMachNum
local sFirst = string.sub( sSetMaxElev, 1, 7)
local nPosFind, _ = sNotesMach:find( sFirst, 1, true)
if nPosFind then -- se ho già la prima parte
if not sNotesMach:find( sSetMaxElev, 1, true) then -- se non ho la stessa nota la sostituisco
sNotesMach = string.gsub( sNotesMach, string.sub( sNotesMach, nPosFind, 11), sSetMaxElev)
end
else -- se non ho la prima parte la aggiungo
sNotesMach = sNotesMach..sSetMaxElev..';'
EgtSetMachiningParam( MCH_MP.USERNOTES, sNotesMach)
end
end
end
if bSandFound and dAddLength and dAddLength > 0 then
sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES)
if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota cerco la lavorazione di profilatura
local sProfFind_LK, _ = sNotesMach:find( 'TRIM_LK', 1, true)
local sProfFind, _ = sNotesMach:find( 'TRIM_', 1, true)
local sProfAdded, _ = sNotesMach:find( 'ADD_EXTENDED', 1, true)
-- se trovata lavorazione trim e non è stata ancora allungata (nella parte finale)
if sProfFind and not sProfAdded then
EgtSetMachiningParam( MCH_MP.USERNOTES, sNotesMach .. 'ADD_EXTENDED'..';')
-- applico l'allungamento se non è percorso lock e non è una porta stretta
if not (sProfFind_LK and bNarrowDoor) then
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dAddLength)
end
end
end
end
if bSandFound and dAddSandLength and dAddSandLength > 0 then
sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES)
if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota cerco la lavorazione di profilatura
local sSandFind, _ = sNotesMach:find( 'SAND_', 1, true)
local sProfAdded, _ = sNotesMach:find( 'ADD_EXTENDED', 1, true)
-- se trovata lavorazione sand e non è stata ancora allungata (nella parte iniziale)
if sSandFind and not sProfAdded then
EgtSetMachiningParam( MCH_MP.USERNOTES, sNotesMach .. 'ADD_EXTENDED'..';')
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dAddSandLength)
end
end
end
local bSetMach = EgtSetMachiningGeometry( tEntId)
-- se creo effettivamente la lavorazione controllo se ho le note per la modifica degli attacchi
if not bNotGenMachining then
sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES)
for t = 1, #tEntId do
if tEntId[t] then
local sPathType = EgtGetInfo( tEntId[t], 'PathType', 's')
local sToolUse = EgtGetInfo( tEntId[t], 'ToolsUse', 's')
local sTypeLead = EgtGetInfo( tEntId[t], 'LeadType', 's')
local sInvDir = EgtGetInfo( tEntId[t], 'InvDir', 's')
local nDirType = EgtGetInfo( tEntId[t], 'RevMach', 'i')
local nStFromExt = EgtGetInfo( tEntId[t], 'StartFromExt', 'i')
if nDirType and sPathType and sPathType == 'NR' and not sToolUse then -- se percorso REV singolo
-- leggo il lato di lavoro
-- local nWorkSide = EgtGetMachiningParam( MCH_MP.WORKSIDE)
-- if nWorkSide and nWorkSide == MCH_MILL_WS.LEFT then -- se lato sinistro
-- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
-- elseif nWorkSide and nWorkSide == MCH_MILL_WS.RIGHT then -- se lato destro
-- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
-- end
--inverto il percorso di lavoro
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
if sTypeLead then -- se ho una nota di lead-in/out
MachiningBase.ModifyLiLo( sTypeLead, nDirType, sPathType, sToolUse, dBladePerpLeadIn, dPercRedFeed, sInvDir)
end
if nStFromExt then -- se ho una nota di lead-in/out dall'esterno
MachiningBase.ModifyLiLoToExt()
end
-- fermo il ciclo
break
end
end
-- se lavorazione ha le note opportune,
-- rifaccio il ciclo sulle entità/lavorazione per applicare la riduzione della lunghezza lavorata
if string.find( sNotesMach, 'HALF_LENGTH') then
for t = 1, #tEntId do
if tEntId[t] then
local dPathLen = EgtCurveLength( tEntId[t]) or 0.0
if dPathLen > 0 then -- se nelle note trovata la nota di ridurre il percorso
-- setto il valore di riduzione allungamento finale
EgtSetMachiningParam( MCH_MP.ENDADDLEN, -(( dPathLen/2)-1))
end
end
end
end
local nPosFound = string.find( sNotesMach, 'CUT_LENGTH')
if nPosFound then
local sParz = string.sub( sNotesMach, nPosFound)
nPosFound = string.find( sParz, ';')
local sTrimmed
if nPosFound then
sTrimmed = string.sub( sParz, 1, nPosFound-1)
else
sTrimmed = sParz
end
if sTrimmed and #sTrimmed > 0 then
local sValue = string.sub( sTrimmed, 12)
if sValue and #sTrimmed > 0 then
local dVal = tonumber( sValue)
if dVal and abs(dVal) > GEO.EPS_SMALL then
for t = 1, #tEntId do
if tEntId[t] then
local dPathLen = EgtCurveLength( tEntId[t]) or 0.0
if dPathLen > 0 then -- se nelle note trovata la nota di ridurre il percorso
-- setto il valore di riduzione allungamento finale
EgtSetMachiningParam( MCH_MP.ENDADDLEN, -( dPathLen - abs(dVal)))
end
end
end
end
end
end
end
-- se non genero la lavorazione leggo comunque le note
else
sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES)
end
local bApplyMach = EgtApplyMachining()
if not bNotGenMachining and ( not bSetMach or not bApplyMach) then
if not bSetMach or not bApplyMach then
local nIdErr, sIdErr = EgtGetLastMachMgrError()
DGD.EMC = DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[598], sMach, sOriName, sEntId, nIdErr, sIdErr)
else
DGD.EMC = DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[485], sMach, sOriName, sEntId)
end
return -1
end
if bNotGenMachining then
EgtRemoveOperation( nMach)
-- ripristino ultima lavorazione rimasta
local nOper = EgtGetLastActiveOperation() or GDB_ID.NULL
local nType = EgtGetOperationType( nOper)
if nType ~= MCH_OY.NONE and nType ~= MCH_OY.DISP then
EgtSetCurrMachining( nOper)
EgtApplyMachining()
end
nMach = nil
else
sTool = EgtGetMachiningParam( MCH_MP.TOOL )
-- if link value different than 0 write info to machining
if abs(nCheckLink) > 0 then
EgtSetInfo( nMach, 'Link', nCheckLink)
if #tParentId > 0 and tParentId[1] then
EgtSetInfo( nMach, 'Parent', tParentId[1])
end
-- if link value is negative disable the machining
if nCheckLink < 0 then
EgtSetOperationMode( nMach, false)
end
end
-- sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES)
end
return 1, nMach, sTool, sNotesMach
end
--------------------------------------------------------------------------------
function MachiningBase.AddMachining( sName, sMach, tEntId, dOverL, sOriName)
local sEntId = ''
local sNotesMach
for t = 1, #tEntId do
sEntId = sEntId .. tEntId[t] .. ','
end
if not sMach or ( sMach and #sMach == 0) then
DGD.ERM = DGD.ERM .. string.format( EgtDoorsMsg[483], sOriName, sEntId)
return true
end
local nMach = EgtAddMachining( sName, sMach)
if not nMach then
DGD.EMC = DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[484], sMach, sOriName, sEntId)
return false
end
if dOverL then
EgtSetMachiningParam( MCH_MP.OFFSL, dOverL)
end
if not EgtSetMachiningGeometry( tEntId) or not EgtApplyMachining() then
local nIdErr, sIdErr = EgtGetLastMachMgrError()
DGD.EMC = DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[598], sMach, sOriName, sEntId, nIdErr, sIdErr)
return false
end
-- ottengo le note lavorazione
sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES)
if string.find( sNotesMach, 'HALF_LENGTH') then
for t = 1, #tEntId do
if tEntId[t] then
local dPathLen = EgtCurveLength( tEntId[t]) or 0.0
if dPathLen > 0 then -- se nelle note trovata la nota di ridurre il percorso
-- setto il valore di riduzione allungamento finale
EgtSetMachiningParam( MCH_MP.ENDADDLEN, -(( dPathLen/2)-1))
end
end
end
end
return true
end
--------------------------------------------------------------------------------
function MachiningBase.MakeRoughPaths ( dSideOverMat, dMaxOverMat, dStepOverMat, nIdEnt, bTopBottPart, bFlip, bAlreadyMachSide, dBevelOffs, nScrapMode)
local bMadeMach = bAlreadyMachSide
if not bAlreadyMachSide and dMaxOverMat and dSideOverMat > dMaxOverMat then
-- creo passate di sgrossatura
local nHorStep = ceil(dSideOverMat / dStepOverMat)
-- se modalità remove scrap abilitata setto una sola passata
if nScrapMode and nScrapMode == 1 then
nHorStep = 1
end
local dHorStep = dStepOverMat
local nPassHor = 1
local nSideOffs = EgtIf( bFlip, -1, 1)
local nNumEnt1, nNumEnt2 = EgtCurveDomain( nIdEnt)
local bSimpleLine = (nNumEnt2 - nNumEnt1) == 1
local pIni = EgtSP( nIdEnt)
local pMid = EgtMP( nIdEnt)
local pEnd = EgtEP( nIdEnt)
local nParId = EgtGetParent(nIdEnt)
local dOffsBevel = 0
if dBevelOffs and dBevelOffs > 0 then -- se profilo bevel
dOffsBevel = dBevelOffs * nSideOffs
end
while nPassHor <= nHorStep do
local nLine
if bSimpleLine then
nLine = EgtArc3P( nParId, pIni, pMid, pEnd, GDB_RT.LOC)
else -- faccio la copia del percorso
nLine = EgtCopy( nIdEnt, nParId, GDB_RT.LOC)
EgtModifyCurveExtrusion( nLine, Z_AX(), GDB_RT.LOC)
end
EgtOffsetCurve( nLine, ( dOffsBevel + ( dHorStep * ( nPassHor-1) * nSideOffs)))
EgtModifyCurveExtrusion( nLine, Z_AX(), GDB_RT.GLOB)
if nLine then
bMadeMach = true
if bTopBottPart then
EgtSetName( nLine, 'ROUGH_H_' .. EgtNumToString(nPassHor,0))
else
EgtSetName( nLine, 'ROUGH_' .. EgtNumToString(nPassHor,0))
end
end
nPassHor = nPassHor + 1
end -- end while
end
return bMadeMach
end
-----------------------------------------------------------------
-- *** Adjust Geometries Functions (Operations) ***
-----------------------------------------------------------------
--------------------------------------------------------------------------------
function MachiningBase.AdjustBevel( EntId, EntName, bFirstStep, bNoVertCurve, bMakeGhostGeom, bNoModifyPath, bSkipOnSecCol)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- recupero flag di lavorazione
local nLocMach = EgtGetInfo( EntId, 'Mach', 'i') or 1
local sNewName = EntName
-- se diretto verso il basso
if vtExtr:getZ() < 0 then
-- sposto la curva, inverto l'estrusione
local dTh = EgtCurveThickness( EntId)
-- sposto la curva in basso lungo il versore
EgtMove( EntId, vtExtr * dTh, GDB_RT.GLOB)
if not bNoVertCurve then
if not bNoModifyPath then
-- rendo l'estrusione verticale e aggiusto lo spessore di conseguenza
EgtModifyCurveThickness( EntId, - dTh * vtExtr:getZ())
EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB)
end
else
-- sistemo l'estrusione e aggiusto lo spessore di conseguenza
EgtModifyCurveThickness( EntId, dTh)
EgtModifyCurveExtrusion( EntId, -vtExtr, GDB_RT.GLOB)
end
-- inverto la curva
EgtInvertCurve( EntId)
-- cambio il nome
if EntName == 'BU' then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, 'BD'..DGD.GHT)
else
EgtSetName( EntId, 'BD')
end
sNewName = 'BD'
elseif EntName == 'BU_H' then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, 'BD_H'..DGD.GHT)
else
EgtSetName( EntId, 'BD_H')
end
sNewName = 'BD'
elseif EntName == 'BU_LK' then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, 'BD_LK'..DGD.GHT)
else
EgtSetName( EntId, 'BD_LK')
end
sNewName = 'BD'
elseif EntName == 'BD' then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, 'BU'..DGD.GHT)
else
EgtSetName( EntId, 'BU')
end
sNewName = 'BU'
elseif EntName == 'BD_H' then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, 'BU_H'..DGD.GHT)
else
EgtSetName( EntId, 'BU_H')
end
sNewName = 'BU'
elseif EntName == 'BD_LK' then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, 'BU_LK'..DGD.GHT)
else
EgtSetName( EntId, 'BU_LK')
end
sNewName = 'BU'
elseif EntName then
if string.find( EntName, 'BU_Mach') then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, string.gsub( EntName, 'BU_Mach', 'BD'..DGD.GHT..'_Mach'))
else
EgtSetName( EntId, string.gsub( EntName, 'BU_Mach', 'BD_Mach'))
end
sNewName = 'BD'
elseif string.find( EntName,'BUEB') then -- bevel con edge break lato serratura
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, string.gsub( EntName, 'BUEB', 'BDEB') .. DGD.GHT)
else
EgtSetName( EntId, string.gsub( EntName, 'BUEB', 'BDEB'))
end
sNewName = 'BD'
elseif string.find( EntName, 'BD_Mach') then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, string.gsub( EntName, 'BD_Mach', 'BU'..DGD.GHT..'_Mach'))
else
EgtSetName( EntId, string.gsub( EntName, 'BD_Mach', 'BU_Mach'))
end
sNewName = 'BU'
elseif string.find( EntName,'BDEB') then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, string.gsub( EntName, 'BDEB', 'BUEB') .. DGD.GHT)
else
EgtSetName( EntId, string.gsub( EntName, 'BDEB', 'BUEB'))
end
sNewName = 'BU'
end
end
-- in seconda fase controllo la nota mach se devo ristabilirla o escluderla
if not bFirstStep then
if nLocMach >= 10 then
nLocMach = nLocMach - 10
elseif nLocMach > 0 then -- se è una che non avevo escluso la escludo
nLocMach = nLocMach + 10
else -- altrimenti la escludo perché è già stata fatta nella fase precedente
nLocMach = 11
end
EgtSetInfo( EntId, 'Mach', nLocMach)
else
-- se devo utilizzare seconda colonna
if bSkipOnSecCol then
-- nota seconda colonna
EgtSetInfo( EntId, 'Mach', 2)
end
end
else
if not bNoVertCurve and not bNoModifyPath then
-- rendo l'estrusione verticale e aggiusto lo spessore di conseguenza
local dTh = EgtCurveThickness( EntId)
EgtModifyCurveThickness( EntId, dTh * vtExtr:getZ())
EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB)
end
-- in seconda fase controllo la nota mach se devo ristabilirla o escluderla
if not bFirstStep then
if nLocMach >= 10 then
nLocMach = nLocMach - 10
elseif nLocMach > 0 then -- se è una che non avevo scluso la escludo
nLocMach = nLocMach + 10
else -- altrimenti la escludo perché è già stata fatta nella fase precedente
nLocMach = 11
end
EgtSetInfo( EntId, 'Mach', nLocMach)
else
-- se devo utilizzare seconda colonna
if bSkipOnSecCol then
-- nota seconda colonna
EgtSetInfo( EntId, 'Mach', 2)
end
end
end
return true, sNewName, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustConeCleanPaths( EntId, bMakeGhostGeom, bKeepDir, nSolidLayer)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- se diretto verso il basso
if vtExtr:getZ() < 0 then
-- prendo il punto medio in Z dall'id del solido passato o dalla geometria stessa
local b3Solid
if not nSolidLayer then
b3Solid = EgtGetBBoxGlob( EntId, GDB_BB.STANDARD)
else
b3Solid = EgtGetBBoxGlob( nSolidLayer, GDB_BB.STANDARD)
end
local ptMidZ = ( b3Solid:getMin():getZ() + b3Solid:getMax():getZ()) /2
EgtMirror( EntId, Point3d(0,0,ptMidZ), Z_AX(), GDB_ID.ROOT) -- faccio il mirror su asse Z
end
return true, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustThrouCurve( EntId, bMakeGhostGeom, bKeepDir, bKeepDirZPos, bSkipOnSecCol)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- se diretto verso il basso
if vtExtr:getZ() < 0 then
local dTh = EgtCurveThickness( EntId)
EgtMove( EntId, vtExtr * dTh, GDB_RT.GLOB)
EgtModifyCurveThickness( EntId, - dTh * vtExtr:getZ())
EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB)
if not bKeepDir then
EgtInvertCurve( EntId)
end
else
if bKeepDirZPos then
EgtInvertCurve( EntId)
end
end
-- se devo utilizzare seconda colonna
if bSkipOnSecCol then
-- nota seconda colonna
EgtSetInfo( EntId, 'Mach', 2)
else
-- nessuna nota
EgtRemoveInfo( EntId, 'Mach')
end
return true, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjPrfThrouCurveNew( EntId, bMakeGhostGeom, bFoundProperty, bNoVertCurve, bFirstStep, EntName)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
local sNewName = EntName
-- se diretto verso il basso
if vtExtr:getZ() < 0 then
-- sposto la curva, inverto l'estrusione
local dTh = EgtCurveThickness( EntId)
-- sposto la curva in basso lungo il versore
EgtMove( EntId, vtExtr * dTh, GDB_RT.GLOB)
if not bNoVertCurve then
-- rendo l'estrusione verticale e aggiusto lo spessore di conseguenza
EgtModifyCurveThickness( EntId, - dTh * vtExtr:getZ())
EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB)
else
-- sistemo l'estrusione e aggiusto lo spessore di conseguenza
EgtModifyCurveThickness( EntId, dTh)
EgtModifyCurveExtrusion( EntId, -vtExtr, GDB_RT.GLOB)
end
-- inverto la curva
EgtInvertCurve( EntId)
-- cambio il nome
if EntName == 'BU' then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, 'BD'..DGD.GHT)
else
EgtSetName( EntId, 'BD')
end
sNewName = 'BD'
elseif EntName == 'BD' then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, 'BU'..DGD.GHT)
else
EgtSetName( EntId, 'BU')
end
sNewName = 'BU'
elseif EntName then
if string.find( EntName, 'BU_Mach') then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, string.gsub( EntName, 'BU_Mach', 'BD'..DGD.GHT..'_Mach'))
else
EgtSetName( EntId, string.gsub( EntName, 'BU_Mach', 'BD_Mach'))
end
sNewName = 'BD'
elseif string.find( EntName, 'BD_Mach') then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, string.gsub( EntName, 'BD_Mach', 'BU'..DGD.GHT..'_Mach'))
else
EgtSetName( EntId, string.gsub( EntName, 'BD_Mach', 'BU_Mach'))
end
sNewName = 'BU'
end
end
else -- se diretto verso l'alto
if not bNoVertCurve then
-- rendo l'estrusione verticale e aggiusto lo spessore di conseguenza
local dTh = EgtCurveThickness( EntId)
EgtModifyCurveThickness( EntId, dTh * vtExtr:getZ())
EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB)
end
end
-- cerco se nella tabella c'è la chiave find, se c'è assegno la nota mach a 2
-- disabilito la ricerca perché ho già passato la variabile che indica se è stata trovata la proprietà
local bMatchProp = bFoundProperty
-- se ho trovato corrispondenza di proprietà
if bMatchProp then
-- nota seconda colonna
EgtSetInfo( EntId, 'Mach', 2)
else
-- nessuna nota
EgtRemoveInfo( EntId, 'Mach')
end
return true, EntId, sNewName
end
--------------------------------------------------------------------------------
function MachiningBase.AdjPrfThrouCurve( EntId, bMakeGhostGeom, tsProperties, sFind, bNoVertCurve, bFirstStep, EntName)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
local sNewName = EntName
-- se diretto verso il basso
if vtExtr:getZ() < 0 then
-- sposto la curva, inverto l'estrusione
local dTh = EgtCurveThickness( EntId)
-- sposto la curva in basso lungo il versore
EgtMove( EntId, vtExtr * dTh, GDB_RT.GLOB)
if not bNoVertCurve then
-- rendo l'estrusione verticale e aggiusto lo spessore di conseguenza
EgtModifyCurveThickness( EntId, - dTh * vtExtr:getZ())
EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB)
else
-- sistemo l'estrusione e aggiusto lo spessore di conseguenza
EgtModifyCurveThickness( EntId, dTh)
EgtModifyCurveExtrusion( EntId, -vtExtr, GDB_RT.GLOB)
end
-- inverto la curva
EgtInvertCurve( EntId)
-- cambio il nome
if EntName == 'BU' then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, 'BD'..DGD.GHT)
else
EgtSetName( EntId, 'BD')
end
sNewName = 'BD'
elseif EntName == 'BD' then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, 'BU'..DGD.GHT)
else
EgtSetName( EntId, 'BU')
end
sNewName = 'BU'
elseif EntName then
if string.find( EntName, 'BU_Mach') then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, string.gsub( EntName, 'BU_Mach', 'BD'..DGD.GHT..'_Mach'))
else
EgtSetName( EntId, string.gsub( EntName, 'BU_Mach', 'BD_Mach'))
end
sNewName = 'BD'
elseif string.find( EntName, 'BD_Mach') then
if bMakeGhostGeom or not bFirstStep then
EgtSetName( EntId, string.gsub( EntName, 'BD_Mach', 'BU'..DGD.GHT..'_Mach'))
else
EgtSetName( EntId, string.gsub( EntName, 'BD_Mach', 'BU_Mach'))
end
sNewName = 'BU'
end
end
else -- se diretto verso l'alto
if not bNoVertCurve then
-- rendo l'estrusione verticale e aggiusto lo spessore di conseguenza
local dTh = EgtCurveThickness( EntId)
EgtModifyCurveThickness( EntId, dTh * vtExtr:getZ())
EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB)
end
end
-- cerco se nella tabella c'è la chiave find, se c'è assegno la nota mach a 2
local bMatchProp = FindProperty( tsProperties, sFind)
-- se ho trovato corrispondenza di proprietà
if bMatchProp then
-- nota seconda colonna
EgtSetInfo( EntId, 'Mach', 2)
else
-- nessuna nota
EgtRemoveInfo( EntId, 'Mach')
end
return true, EntId, sNewName
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustVertCurve( EntId, bMakeGhostGeom)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- se diretto verso il basso
if vtExtr:getZ() < 0 then
local dTh = EgtCurveThickness( EntId)
EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB)
-- lavorazione 2nd
EgtSetInfo( EntId, 'Mach', 2)
else
-- lavorazione standard
EgtRemoveInfo( EntId, 'Mach')
end
return true, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustBladeVertCurve( EntId, bMakeGhostGeom)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- se diretto verso il basso
if vtExtr:getZ() < 0 then
local dTh = EgtCurveThickness( EntId)
EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB)
local sPathInfo = EgtGetInfo( EntId, 'PathType', 's')
local sToolsUse = EgtGetInfo( EntId, 'ToolsUse', 's')
if sPathInfo and sPathInfo == 'NR' and not sToolsUse then -- se percorso singolo genero prima colonna
-- lavorazione standard
EgtRemoveInfo( EntId, 'Mach')
else
-- lavorazione 2nd
EgtSetInfo( EntId, 'Mach', 2)
end
-- setto una nota aggiuntiva del parametro mach
EgtSetInfo( EntId, 'RevMach', 1)
else
-- lavorazione standard
EgtRemoveInfo( EntId, 'Mach')
end
return true, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustASplintWithBlade( EntId, bMakeGhostGeom, nDispType, bFlipDoor)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
MachiningBase.DefineASplint( EntId, nDispType, bFlipDoor, 2)
return true, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustThrouIsle( EntId, DimZ, ptMin, ptMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhostGeom, dExtraThruDepth)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- contatore disabilitazione lavorazione
local nNumSkip = nNumMachSkip
-- recupero spessore e verifico se passante
local dTh = EgtCurveThickness( EntId)
local bTrhu = ( abs( dTh) > DimZ - GEO.EPS_SMALL)
-- se passante, aggiunto affondamento
if bTrhu then
-- acquisisco nota per vedere se viene fatta da lama
local bBladeNote = EgtGetInfo( EntId, 'ByBlade', 'b') or false
local dOl = -2 -- valore in mm
if dExtraThruDepth then
dOl = -abs(dExtraThruDepth)
end
if not bBladeNote then -- assegno nota se non ha taglio di lama
EgtSetInfo( EntId, 'OL', dOl)
end
end
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- recupero flag di lavorazione
local nLocMach = EgtGetInfo( EntId, 'Mach', 'i') or 1
-- se versore fresa diretto come Z-,
if vtExtr:getZ() < 0 then
-- se passante, lo cambio in Z+
if bTrhu then
vtExtr = - vtExtr
local pIni = EgtSP( EntId, GDB_ID.ROOT)
if abs( pIni:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sotto
-- in seconda fase controllo la nota mach se devo ristabilirla o escluderla
if not bFirstStep then
-- leggo la nota Mach2nd che indica se l'entità è già stata lavorata
local nMach2nd = EgtGetInfo( EntId, 'Mach2nd', 'i') or 0
if nMach2nd == 0 then
if nLocMach >= 10 then
nLocMach = nLocMach - 10
elseif nLocMach > 0 then -- se è una che non avevo escluso la escludo
nLocMach = nLocMach + 10
else -- altrimenti la escludo perché è già stata fatta nella fase precedente
nLocMach = 11
end
EgtSetInfo( EntId, 'Mach', nLocMach)
end
end
-- se da lavorare ora
if nLocMach > 0 and nLocMach < 10 then
EgtMove( EntId, vtExtr * abs(dTh), GDB_RT.GLOB)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
end
elseif abs( pIni:getZ() - ptMax:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sopra
-- in seconda fase controllo la nota mach se devo ristabilirla o escluderla
if not bFirstStep then
-- leggo la nota Mach2nd che indica se l'entità è già stata lavorata
local nMach2nd = EgtGetInfo( EntId, 'Mach2nd', 'i') or 0
if nMach2nd == 0 then
if nLocMach >= 10 then
nLocMach = nLocMach - 10
elseif nLocMach > 0 then -- se è una che non avevo scluso la escludo
nLocMach = nLocMach + 10
else -- altrimenti la escludo perché è già stata fatta nella fase precedente
nLocMach = 11
end
EgtSetInfo( EntId, 'Mach', nLocMach)
end
end
-- se da lavorare ora
if nLocMach > 0 and nLocMach < 10 then
EgtMove( EntId, -vtExtr * abs(dTh), GDB_RT.GLOB)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
end
else -- altrimenti lo salto perché è in una Z diversa da sopra o sotto
EgtSetInfo( EntId, 'Mach', 0)
end
-- altrimenti lo salto
else
-- se non posso lavorare da sotto
if not bWorkUnder then
-- se non era ancora stato escluso, lo escludo sommando 10 al valore
if nLocMach < 10 then
nLocMach = nLocMach + 10
end
EgtSetInfo( EntId, 'Mach', nLocMach)
nNumSkip = nNumSkip + 1
else
nLocMach = 2
EgtSetInfo( EntId, 'Mach', nLocMach)
end
end
else
-- in seconda fase controllo la nota mach se devo ristabilirla o escluderla
if not bFirstStep then
-- leggo la nota Mach2nd che indica se l'entità è già stata lavorata
local nMach2nd = EgtGetInfo( EntId, 'Mach2nd', 'i') or 0
if nMach2nd == 0 then
if nLocMach >= 10 then
if nLocMach <= 21 then
nLocMach = nLocMach - 10
end
elseif nLocMach > 0 then -- se è una che non avevo escluso la escludo
nLocMach = nLocMach + 10
else -- altrimenti la escludo perché è già stata fatta nella fase precedente
nLocMach = 11
end
EgtSetInfo( EntId, 'Mach', nLocMach)
end
end
end
-- se da lavorare ora
if nLocMach > 0 and nLocMach < 10 then
local vtMPlane, dDist, dArea
-- verifico se il percorso è chiuso
if EgtCurveIsClosed( EntId) then
-- impongo senso di rotazione orario visto da sopra
vtMPlane, dDist, dArea = EgtCurveArea( EntId)
if abs( dArea) < 1 then
-- verifico se il percroso ha la nota che identifica una doubleline cioè un percorso composto da due linee sovrapposte
if not ( EgtGetInfo( EntId, 'DoubleLine', 'i') == 1) then
-- Rimando il valore originario in caso avessi skippato la lavorazione
return false, nNumMachSkip, EntId
end
end
-- altrimenti è aperto
else
-- faccio una copia del percorso
local sParnt = EgtGetParent( EntId)
local nNewEntId = EgtCopyGlob( EntId, sParnt)
-- chiudo il percorso
if EgtCloseCurveCompo( nNewEntId) then
-- impongo senso di rotazione orario visto da sopra
vtMPlane, dDist, dArea = EgtCurveArea( nNewEntId)
EgtErase(nNewEntId)
if dArea and abs( dArea) < 1 then
-- verifico se il percorso originario è una curvecompo
if EgtGetType( EntId) == GDB_TY.CRV_COMPO then
local _, nLast = EgtCurveDomain( EntId)
-- se è composto da una sola entità
if nLast == 1 then
-- rifaccio la copia
nNewEntId = EgtCopyGlob( EntId, sParnt)
-- esplodo e verifico che sia una linea
local nLocalGeom, nLast = EgtExplodeCurveCompo( nNewEntId)
if nLocalGeom and ( nLast > 1 or EgtGetType( nLocalGeom) ~= GDB_TY.CRV_LINE) then
if nLast > 1 then
for i = 1, nLast do
EgtErase( nLocalGeom + i - 1)
end
else
EgtErase( nLocalGeom)
end
-- Rimando il valore originario in caso avessi skippato la lavorazione
return false, nNumMachSkip, EntId
else
EgtErase( nLocalGeom)
return true, nNumSkip, EntId
end
else
-- Rimando il valore originario in caso avessi skippato la lavorazione
return false, nNumMachSkip, EntId
end
elseif EgtGetType( EntId) == GDB_TY.CRV_LINE then
return true, nNumSkip, EntId
else
-- Rimando il valore originario in caso avessi skippato la lavorazione
return false, nNumMachSkip, EntId
end
end
else
EgtErase(nNewEntId)
-- impongo senso di rotazione orario visto da sopra
vtMPlane, dDist, dArea = EgtCurveArea( EntId)
if dArea and abs( dArea) < 1 then
-- Rimando il valore originario in caso avessi skippato la lavorazione
return false, nNumMachSkip, EntId
end
end
end
local frEnt = EgtGetGlobFrame( EntId)
if vtMPlane then
vtMPlane:toGlob(frEnt)
if nLocMach ~= 2 then
if dArea and dArea * ( vtMPlane * vtExtr) > 0 then
EgtInvertCurve( EntId)
-- cerco se ho la nota OPEN che definisce quale entità è quella aperta per le svuotature
local sNumOpen = EgtGetInfo( EntId, 'OPEN', 'i')
if sNumOpen then
if sNumOpen > 0 then
EgtSetInfo( EntId, 'OPEN', 0)
else
local nNumEnt1, nNumEnt2 = EgtCurveDomain( EntId)
if nNumEnt2 > 1 then
EgtSetInfo( nHint, 'OPEN', nNumEnt2-1)
end
end
end
end
else
if dArea and dArea * ( vtMPlane * vtExtr) < 0 then
EgtInvertCurve( EntId)
-- cerco se ho la nota OPEN che definisce quale entità è quella aperta per le svuotature
local sNumOpen = EgtGetInfo( EntId, 'OPEN', 'i')
if sNumOpen then
if sNumOpen > 0 then
EgtSetInfo( EntId, 'OPEN', 0)
else
local nNumEnt1, nNumEnt2 = EgtCurveDomain( EntId)
if nNumEnt2 > 1 then
EgtSetInfo( nHint, 'OPEN', nNumEnt2-1)
end
end
end
end
end
end
--[[
local dAreaXY = EgtCurveAreaXY( EntId)
if dAreaXY and abs( dAreaXY) < 1 then
-- provo con EgtCurveArea
local vtV1, dDist, dArea = EgtCurveArea( EntId)
if dArea and abs( dArea) < 1 then
-- Rimando il valore originario in caso avessi skippato la lavorazione
return false, nNumMachSkip, EntId
else
dAreaXY = dArea
end
end
local frEnt = EgtFR( EgtGetParent( EntId), GDB_ID.ROOT)
if nLocMach ~= 2 then
if dAreaXY and dAreaXY * frEnt:getVersZ():getZ() > 0 then
EgtInvertCurve( EntId)
end
else
if dAreaXY and dAreaXY * frEnt:getVersZ():getZ() < 0 then
EgtInvertCurve( EntId)
end
end
]]--
end
return true, nNumSkip, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustHole( EntId, bMakeGhostGeom, bForceHorizontalDir)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
local vtMPlane, dDist, dArea = EgtCurveArea( EntId)
if bForceHorizontalDir then -- se c'è forzatura orizzontale
vtExtr:setZ( 0)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
-- EgtSetInfo( EntId, 'OL', 0.16)
-- lavorazione standard
EgtRemoveInfo( EntId, 'Mach')
end
-- impongo senso di rotazione orario relativo alla normale del versore
if abs( dArea) < 1 then
return false
end
local frEnt = EgtGetGlobFrame( EntId)
vtMPlane:toGlob(frEnt)
if dArea * ( vtMPlane * vtExtr) > 0 then
EgtInvertCurve( EntId)
end
return true, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjPreHoleAndPocket( EntId, bMakeGhostGeom, tsProperties, tsFind, bFoundProperty)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
local vtMPlane, dDist, dArea = EgtCurveArea( EntId)
-- impongo senso di rotazione orario relativo alla normale del versore
if abs( dArea) < 1 then
return false
end
local frEnt = EgtGetGlobFrame( EntId)
vtMPlane:toGlob(frEnt)
if dArea * ( vtMPlane * vtExtr) > 0 then
EgtInvertCurve( EntId)
end
-- cerco se nella tabella c'è la chiave find, se c'è assegno la nota mach a 2
local bMatchProp
if tsFind and tsProperties then
for g = 1, #tsFind do
for h = 1, #tsProperties do
if string.lower(tsProperties[h]) == string.lower(tsFind[g]) then
bMatchProp = true
end
end
end
end
-- verifico se la proprietà è già stata trovata (nuovo metodo),
-- è mutuamente esclusivo della ricerca nella tabella proprietà appena qua sopra
if bFoundProperty then
bMatchProp = true
end
-- se ho trovato corrispondenza di proprietà
if bMatchProp then
-- nota seconda colonna
EgtSetInfo( EntId, 'Mach', 2)
else
-- nessuna nota
EgtRemoveInfo( EntId, 'Mach')
end
return true, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustHead( EntId, nNumTopGeom, nNumBottomGeom, dPosShuttleChange, nForceUseShuttle)
-- controllo dalla nota se non è già stata lavorata prima
local nSetSide = EgtGetInfo( EntId, 'Mach', 'i') or 0
if nSetSide < 10 then
-- recupero il minimo e massimo valore in X e decido in base ai range dove metterlo
local b3Ent = EgtGetBBoxGlob( EntId, GDB_BB.STANDARD)
local dMin = b3Ent:getMin():getX()
local dMax = b3Ent:getMax():getX()
-- se ho forzato ad usare uno shuttle, setto a tutte le geometrie lo shuttle disponibile
if nForceUseShuttle and nForceUseShuttle > 0 then
if nForceUseShuttle == 1 then -- se forzo uso shuttle 1 (il valore assegnato a 3 è l'id della MTABLE)
nSetSide = 3 -- setto lower
nNumBottomGeom = nNumBottomGeom + 1
else -- altrimenti lo shuttle 2
nSetSide = 2 -- setto upper
nNumTopGeom = nNumTopGeom + 1
end
else
-- se il minimo geometria è tutto con lo shuttle superiore ( di destra)
if dMin >= dPosShuttleChange then
nSetSide = 2 -- setto upper
nNumTopGeom = nNumTopGeom + 1
else -- altrimenti sfora o è completamente nella parte dello shuttle inferiore ( di sinistra)
-- se il massimo è oltre il limite lo setto neutro
if dMax > dPosShuttleChange then
nSetSide = 0 -- setto neutro
else
nSetSide = 3 -- setto lower
nNumBottomGeom = nNumBottomGeom + 1
end
end
end
-- se neutro decido da che parte stare in base al numero delle rispettive parti
if nSetSide == 0 then
if nNumTopGeom == 0 then -- se shuttle alto senza assegnazioni lo assegno alto
nSetSide = 2
nNumTopGeom = nNumTopGeom + 1
else -- altrimenti shuttle alto ha già assegnazioni
if nNumBottomGeom == 0 then -- se shuttle basso senza assegnazioni lo assegno basso
nSetSide = 3 -- setto lower
nNumBottomGeom = nNumBottomGeom + 1
else -- altrimenti shuttle basso con già assegnazioni
-- confronto tra quale dei due ha più assegnazioni
if nNumBottomGeom >= nNumTopGeom then -- se shuttle basso ne ha uguali o di più lo assegno alto
nSetSide = 2
nNumTopGeom = nNumTopGeom + 1
else -- altrimenti shuttle basso ne ha di meno, assegno basso
nSetSide = 3 -- setto lower
nNumBottomGeom = nNumBottomGeom + 1
end
end
end
end
EgtSetInfo( EntId, 'Mach', nSetSide)
end
return true, nNumTopGeom, nNumBottomGeom, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustHeadOnASplint( EntId, nNumTopGeom, nNumBottomGeom, dPosShuttleChange, nForceUseShuttle,
nDispType, bFlipDoor, nMaxMach)
-- controllo dalla nota se non è già stata lavorata prima
local nSetSide = EgtGetInfo( EntId, 'Mach', 'i') or 0
if nSetSide < 10 then
-- verifico se è possibile lavorarla
nSetSide = MachiningBase.DefineASplint( EntId, nDispType, bFlipDoor, nMaxMach)
if nSetSide < 4 then
nSetSide = 0
-- recupero il minimo e massimo valore in X e decido in base ai range dove metterlo
local b3Ent = EgtGetBBoxGlob( EntId, GDB_BB.STANDARD)
local dMin = b3Ent:getMin():getX()
local dMax = b3Ent:getMax():getX()
-- se ho forzato ad usare uno shuttle, setto a tutte le geometrie lo shuttle disponibile
if nForceUseShuttle and nForceUseShuttle > 0 then
if nForceUseShuttle == 1 then -- se forzo uso shuttle 1 (il valore assegnato a 3 è l'id della MTABLE)
nSetSide = 3 -- setto lower
nNumBottomGeom = nNumBottomGeom + 1
else -- altrimenti lo shuttle 2
nSetSide = 2 -- setto upper
nNumTopGeom = nNumTopGeom + 1
end
else
-- se il minimo geometria è tutto con lo shuttle superiore ( di destra)
if dMin >= dPosShuttleChange then
nSetSide = 2 -- setto upper
nNumTopGeom = nNumTopGeom + 1
else -- altrimenti sfora o è completamente nella parte dello shuttle inferiore ( di sinistra)
-- se il massimo è oltre il limite lo setto neutro
if dMax > dPosShuttleChange then
nSetSide = 0 -- setto neutro
else
nSetSide = 3 -- setto lower
nNumBottomGeom = nNumBottomGeom + 1
end
end
end
-- se neutro decido da che parte stare in base al numero delle rispettive parti
if nSetSide == 0 then
if nNumTopGeom == 0 then -- se shuttle alto senza assegnazioni lo assegno alto
nSetSide = 2
nNumTopGeom = nNumTopGeom + 1
else -- altrimenti shuttle alto ha già assegnazioni
if nNumBottomGeom == 0 then -- se shuttle basso senza assegnazioni lo assegno basso
nSetSide = 3 -- setto lower
nNumBottomGeom = nNumBottomGeom + 1
else -- altrimenti shuttle basso con già assegnazioni
-- confronto tra quale dei due ha più assegnazioni
if nNumBottomGeom >= nNumTopGeom then -- se shuttle basso ne ha uguali o di più lo assegno alto
nSetSide = 2
nNumTopGeom = nNumTopGeom + 1
else -- altrimenti shuttle basso ne ha di meno, assegno basso
nSetSide = 3 -- setto lower
nNumBottomGeom = nNumBottomGeom + 1
end
end
end
end
EgtSetInfo( EntId, 'Mach', nSetSide)
end
end
return true, nNumTopGeom, nNumBottomGeom, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustHorizDrillX( EntId, bMakeGhostGeom, bSelecExit, nProbeMode)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- recupero versore estrusione/fresa
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- impongo versore fresa orizzontale
if abs( vtExtr:getZ()) > GEO.EPS_ZERO then
vtExtr:setZ( 0)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
EgtSetInfo( EntId, 'OL', 0.16)
end
if bSelecExit then
local bLetExit
-- lavorazione frontale (destra o sinistra)
-- se probemode disabilitato confronto con valore quasi o nullo
if nProbeMode < 2 and abs( vtExtr:getY()) < GEO.EPS_ZERO then
bLetExit = true
-- se ha fallito l'orientamento e sono in probe mode 2 confronto con un valore più grande
elseif nProbeMode == 2 and abs( vtExtr:getY()) < 2 then
bLetExit = true
-- impongo versore Y a 0
vtExtr:setY( 0)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
end
if bLetExit then
-- se diretto verso SX
if vtExtr:getX() < GEO.EPS_ZERO then
EgtRemoveInfo( EntId, 'Mach')
else
-- lavorazione diretta verso DX
EgtSetInfo( EntId, 'Mach', 2)
end
end
end
return true, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustHorizDrillY( EntId, bMakeGhostGeom, bSelecExit, nProbeMode)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- recupero versore estrusione/fresa
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- impongo versore fresa orizzontale
if abs( vtExtr:getZ()) > GEO.EPS_ZERO then
vtExtr:setZ( 0)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
EgtSetInfo( EntId, 'OL', 0.16)
end
if bSelecExit then
local bLetExit
-- lavorazione frontale (dietro o davanti)
-- se probemode disabilitato confronto con valore quasi o nullo
if nProbeMode < 2 and abs( vtExtr:getX()) < GEO.EPS_ZERO then
bLetExit = true
-- se ha fallito l'orientamento e sono in probe mode 2 confronto con un valore più grande
elseif nProbeMode == 2 and abs( vtExtr:getX()) < 2 then
bLetExit = true
-- impongo versore X a 0
vtExtr:setX( 0)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
end
if bLetExit then
-- se diretto verso davanti
if vtExtr:getY() < GEO.EPS_ZERO then
EgtRemoveInfo( EntId, 'Mach')
else
-- lavorazione Dietro
EgtSetInfo( EntId, 'Mach', 2)
end
end
end
return true, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustHorizAS( EntId, bMakeGhostGeom)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- recupero versore estrusione/fresa
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- se orizzontale
if abs( vtExtr:getZ()) < GEO.EPS_ZERO then
-- lavorazione standard
EgtRemoveInfo( EntId, 'Mach')
-- se diretto in su
elseif vtExtr:getZ() > 0 then
-- lavorazione Up
EgtSetInfo( EntId, 'Mach', 2)
-- altrimenti diretto in giù
else
-- lavorazione Dw
EgtSetInfo( EntId, 'Mach', 3)
end
-- impongo versore fresa orizzontale
if abs( vtExtr:getZ()) > GEO.EPS_ZERO then
vtExtr:setZ( 0)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
EgtSetInfo( EntId, 'OL', 0.16)
end
return true, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustHorNegativeAS( EntId, bMakeGhostGeom)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- recupero versore estrusione/fresa
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- se orizzontale
if abs( vtExtr:getZ()) < GEO.EPS_ZERO then
-- lavorazione standard
EgtRemoveInfo( EntId, 'Mach')
-- se diretto in su
elseif vtExtr:getZ() > 0 then
-- lavorazione Up
EgtSetInfo( EntId, 'Mach', 2)
-- altrimenti diretto in giù
else
-- lavorazione Dw
EgtSetInfo( EntId, 'Mach', 3)
end
-- se è negativo impongo versore fresa orizzontale
if vtExtr:getZ() < GEO.EPS_ZERO then
vtExtr:setZ( 0)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
EgtSetInfo( EntId, 'OL', 0.16)
end
return true, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustMortise( EntId, nNumMachSkip, bNoWorkUnderSquare, bMakeGhostGeom, bNoWorkUpSquare,
bForceHorizontalDir)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- contatore disabilitazione lavorazione
local nNumSkip = nNumMachSkip
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
local vtMPlane, dDist, dArea = EgtCurveArea( EntId)
-- se orizzontale
if abs( vtExtr:getZ()) < GEO.EPS_ZERO then
-- lavorazione standard
EgtRemoveInfo( EntId, 'Mach')
-- se diretto in su
elseif vtExtr:getZ() > 0 then
-- lavorazione Up a meno che c'è la forzatura orizzontale
if bForceHorizontalDir then -- se c'è forzatura orizzontale
vtExtr:setZ( 0)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
EgtSetInfo( EntId, 'OL', 0.16)
-- lavorazione standard
EgtRemoveInfo( EntId, 'Mach')
else
if bNoWorkUpSquare then -- se non è possibile lavorare soprasquadra
EgtSetInfo( EntId, 'Mach', 12)
nNumSkip = nNumSkip + 1
else
EgtSetInfo( EntId, 'Mach', 2)
end
end
-- altrimenti diretto in giù
else
-- lavorazione Dw a meno che c'è la forzatura orizzontale
if bForceHorizontalDir then -- se c'è forzatura orizzontale
vtExtr:setZ( 0)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
EgtSetInfo( EntId, 'OL', 0.16)
-- lavorazione standard
EgtRemoveInfo( EntId, 'Mach')
else
if bNoWorkUnderSquare then -- se non è possibile lavorare sottosquadra
EgtSetInfo( EntId, 'Mach', 13)
nNumSkip = nNumSkip + 1
else
EgtSetInfo( EntId, 'Mach', 3)
end
end
end
if vtMPlane then
local frEnt = EgtGetGlobFrame( EntId)
vtMPlane:toGlob(frEnt)
if dArea * ( vtMPlane * vtExtr) > 0 then
EgtInvertCurve( EntId)
end
end
return true, nNumSkip, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustBevelChisel( EntId, nNumMachSkip, bNoWorkUnderSquare, bMakeGhostGeom, bNoWorkUpSquare, bForceChiselHoriz)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- contatore disabilitazione lavorazione
local nNumSkip = nNumMachSkip
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
local vtMPlane, dDist, dArea = EgtCurveArea( EntId)
-- se orizzontale
if abs( vtExtr:getZ()) < GEO.EPS_ZERO then
-- lavorazione standard
EgtRemoveInfo( EntId, 'Mach')
-- se diretto in su
elseif vtExtr:getZ() > 0 then
-- lavorazione Up
if bNoWorkUpSquare then -- se non è possibile lavorare soprasquadra
EgtSetInfo( EntId, 'Mach', 12)
nNumSkip = nNumSkip + 1
else
EgtSetInfo( EntId, 'Mach', 2)
if bForceChiselHoriz then
EgtRemoveInfo( EntId, 'Mach')
vtExtr:setZ( 0)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
-- EgtSetInfo( EntId, 'OL', 0.16)
end
end
-- altrimenti diretto in giù
else
-- lavorazione Dw
if bNoWorkUnderSquare then -- se non è possibile lavorare sottosquadra
EgtSetInfo( EntId, 'Mach', 13)
nNumSkip = nNumSkip + 1
else
EgtSetInfo( EntId, 'Mach', 3)
if bForceChiselHoriz then
EgtRemoveInfo( EntId, 'Mach')
vtExtr:setZ( 0)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
-- EgtSetInfo( EntId, 'OL', 0.16)
end
end
end
if vtMPlane then
local frEnt = EgtGetGlobFrame( EntId)
vtMPlane:toGlob(frEnt)
if dArea * ( vtMPlane * vtExtr) > 0 then
EgtInvertCurve( EntId)
end
end
return true, nNumSkip, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustHeadChisel( EntId, bMakeGhostGeom, bWorkOnlyHoriz, nNumMachSkip, bNoWorkUpSquare, bNoWorkUnderSquare)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- contatore disabilitazione lavorazione
local nNumSkip = nNumMachSkip
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
local vtMPlane, dDist, dArea = EgtCurveArea( EntId)
-- se area piccola esco
if dArea and abs( dArea) < 1 then
return false
end
-- se valore quasi o nullo
if abs( vtExtr:getX()) < GEO.EPS_ZERO then
-- lavorazione frontale (dietro o davanti)
EgtRemoveInfo( EntId, 'Mach')
-- se abilitata verifica e modifica versore z per lavorazione orizzontale ( non segue il bevel)
if bWorkOnlyHoriz then
-- se non orizzontale impongo versore fresa orizzontale
if abs( vtExtr:getZ()) > GEO.EPS_ZERO then
vtExtr:setZ( 0)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
-- EgtSetInfo( EntId, 'OL', 0.16)
end
else
-- se diretto in su
if vtExtr:getZ() > 0 then
-- lavorazione Up
if bNoWorkUpSquare then -- se non è possibile lavorare soprasquadra
EgtSetInfo( EntId, 'Mach', 11)
nNumSkip = nNumSkip + 1
else
EgtSetInfo( EntId, 'Mach', 1)
end
-- altrimenti diretto in giù
elseif vtExtr:getZ() < 0 then
-- lavorazione Dw
if bNoWorkUnderSquare then -- se non è possibile lavorare sottosquadra
EgtSetInfo( EntId, 'Mach', 11)
nNumSkip = nNumSkip + 1
else
EgtSetInfo( EntId, 'Mach', 1)
end
end
end
-- se diretto verso DX
elseif vtExtr:getX() > 0 then
-- lavorazione DX
EgtSetInfo( EntId, 'Mach', 2)
-- altrimenti diretto s SX
else
-- lavorazione SX
EgtSetInfo( EntId, 'Mach', 3)
end
-- impongo senso di rotazione orario relativo alla normale del versore
if vtMPlane then
local frEnt = EgtGetGlobFrame( EntId)
vtMPlane:toGlob(frEnt)
if dArea * ( vtMPlane * vtExtr) > 0 then
EgtInvertCurve( EntId)
end
end
return true, EntId, nNumSkip
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustVertHole( EntId, DimZ, ptMin, ptMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhostGeom, dExtraThruDepth)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- contatore disabilitazione lavorazione
local nNumSkip = nNumMachSkip
local nTypeGeom = 0 -- 1: passante up, 2: passante dw, 3: cieca up, 4: cieca dw
-- recupero spessore e verifico se passante
local dTh = EgtCurveThickness( EntId)
local bTrhu = ( abs( dTh) > DimZ - GEO.EPS_SMALL)
-- se passante, aggiunto affondamento
if bTrhu then
local dOl = -2 -- valore in mm
if dExtraThruDepth then
dOl = -abs(dExtraThruDepth)
end
EgtSetInfo( EntId, 'OL', dOl)
end
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- recupero flag di lavorazione
local nLocMach = EgtGetInfo( EntId, 'Mach', 'i') or 1
-- se versore fresa diretto come Z- (da sotto)
if vtExtr:getZ() < 0 then
-- se passante, lo cambio in Z+
if bTrhu then
vtExtr = - vtExtr
local pIni = EgtSP( EntId, GDB_ID.ROOT)
if abs( pIni:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then -- se il foro parte sulla faccia sotto
-- in seconda fase controllo la nota mach se devo ristabilirla o escluderla
if not bFirstStep then
-- leggo la nota Mach2nd che indica se l'entità è già stata lavorata
local nMach2nd = EgtGetInfo( EntId, 'Mach2nd', 'i') or 0
if nMach2nd == 0 then
-- se è una geometria che avevo escluso la riabilito
if nLocMach >= 10 then
nLocMach = nLocMach - 10
elseif nLocMach > 0 then -- se è una che non avevo scluso la escludo
nLocMach = nLocMach + 10
else -- altrimenti la escludo perché è già stata fatta nella fase precedente
nLocMach = 11
end
EgtSetInfo( EntId, 'Mach', nLocMach)
end
end
-- se da lavorare ora
if nLocMach > 0 and nLocMach < 10 then
EgtMove( EntId, vtExtr * abs(dTh), GDB_RT.GLOB)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
end
nTypeGeom = 2
elseif abs( pIni:getZ() - ptMax:getZ()) < GEO.EPS_SMALL then -- se il foro parte sulla faccia sopra
-- in seconda fase controllo la nota mach se devo ristabilirla o escluderla
if not bFirstStep then
-- leggo la nota Mach2nd che indica se l'entità è già stata lavorata
local nMach2nd = EgtGetInfo( EntId, 'Mach2nd', 'i') or 0
if nMach2nd == 0 then
if nLocMach >= 10 then
if nLocMach <= 21 then
nLocMach = nLocMach - 10
end
elseif nLocMach > 0 then -- se è una che non avevo escluso la escludo
nLocMach = nLocMach + 10
else -- altrimenti la escludo perché è già stata fatta nella fase precedente
nLocMach = 11
end
EgtSetInfo( EntId, 'Mach', nLocMach)
end
end
-- se da lavorare ora
if nLocMach > 0 and nLocMach < 10 then
EgtMove( EntId, -vtExtr * abs(dTh), GDB_RT.GLOB)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
end
nTypeGeom = 2
else -- altrimenti lo salto perché è in una Z diversa da sopra o sotto
EgtSetInfo( EntId, 'Mach', 0)
end
-- altrimenti non passante
else
-- se non posso lavorare da sotto
if not bWorkUnder then
-- se non era ancora stato escluso, lo escludo sommando 10 al valore
if nLocMach < 10 then
nLocMach = nLocMach + 10
end
EgtSetInfo( EntId, 'Mach', nLocMach)
nNumSkip = nNumSkip + 1
else
nLocMach = 2
EgtSetInfo( EntId, 'Mach', nLocMach)
end
nTypeGeom = 4
end
else -- versore Z diretto in Z+
-- in seconda fase controllo la nota mach se devo ristabilirla o escluderla
if not bFirstStep then
-- leggo la nota Mach2nd che indica se l'entità è già stata lavorata
local nMach2nd = EgtGetInfo( EntId, 'Mach2nd', 'i') or 0
if nMach2nd == 0 then
if nLocMach >= 10 then
if nLocMach <= 21 then
nLocMach = nLocMach - 10
end
elseif nLocMach > 0 then -- se è una che non avevo scluso la escludo
nLocMach = nLocMach + 10
else -- altrimenti la escludo perché è già stata fatta nella fase precedente
nLocMach = 11
end
EgtSetInfo( EntId, 'Mach', nLocMach)
end
end
if bTrhu then
nTypeGeom = 1
else
nTypeGeom = 3
end
end
-- se da lavorare ora
if nLocMach > 0 and nLocMach < 10 then
local vtMPlane, dDist, dArea
-- verifico se il percorso è chiuso
if EgtCurveIsClosed( EntId) then
-- impongo senso di rotazione orario visto da sopra
vtMPlane, dDist, dArea = EgtCurveArea( EntId)
if abs( dArea) < 1 then
-- Rimando il valore originario in caso avessi skippato la lavorazione
return false, nNumMachSkip, EntId
end
-- altrimenti è aperto
else
-- faccio una copia del percorso
local sParnt = EgtGetParent( EntId)
local nNewEntId = EgtCopyGlob( EntId, sParnt)
-- chiudo il percorso
if EgtCloseCurveCompo( nNewEntId) then
-- impongo senso di rotazione orario visto da sopra
vtMPlane, dDist, dArea = EgtCurveArea( nNewEntId)
EgtErase(nNewEntId)
if dArea and abs( dArea) < 1 then
-- Rimando il valore originario in caso avessi skippato la lavorazione
return false, nNumMachSkip, EntId
end
else
EgtErase(nNewEntId)
-- impongo senso di rotazione orario visto da sopra
vtMPlane, dDist, dArea = EgtCurveArea( EntId)
if not dArea or abs( dArea) < 1 then
-- Rimando il valore originario in caso avessi skippato la lavorazione
return false, nNumMachSkip, EntId
end
end
end
local frEnt = EgtGetGlobFrame( EntId)
if vtMPlane then
vtMPlane:toGlob(frEnt)
if nLocMach ~= 2 then
if dArea and dArea * ( vtMPlane * vtExtr) > 0 then
EgtInvertCurve( EntId)
end
else
if dArea and dArea * ( vtMPlane * vtExtr) < 0 then
EgtInvertCurve( EntId)
end
end
end
--[[
-- impongo senso di rotazione orario visto da sopra
local vtMPlane, dDist, dArea = EgtCurveArea( EntId)
if not dArea or abs( dArea) < 1 then
-- Rimando il valore originario in caso avessi skippato la lavorazione
return false, nNumMachSkip, EntId
end
local frEnt = EgtGetGlobFrame( EntId)
vtMPlane:toGlob(frEnt)
if nLocMach ~= 2 then
if dArea * ( vtMPlane * vtExtr) > 0 then
EgtInvertCurve( EntId)
end
else
if dArea * ( vtMPlane * vtExtr) < 0 then
EgtInvertCurve( EntId)
end
end
]]--
--[[
local dAreaXY = EgtCurveAreaXY( EntId)
if dAreaXY and abs( dAreaXY) < 1 then
-- provo con EgtCurveArea
local vtV1, dDist, dArea = EgtCurveArea( EntId)
if dArea and abs( dArea) < 1 then
-- Rimando il valore originario in caso avessi skippato la lavorazione
return false, nNumMachSkip, EntId
else
dAreaXY = dArea
end
end
local frEnt = EgtFR( EgtGetParent( EntId), GDB_ID.ROOT)
if nLocMach ~= 2 then
if dAreaXY and dAreaXY * frEnt:getVersZ():getZ() > 0 then
EgtInvertCurve( EntId)
end
else
if dAreaXY and dAreaXY * frEnt:getVersZ():getZ() < 0 then
EgtInvertCurve( EntId)
end
end
]]--
end
return true, nNumSkip, EntId, nTypeGeom
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustProbeHole( EntId, DimZ, ptMin, ptMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhostGeom)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- contatore disabilitazione lavorazione
local nNumSkip = nNumMachSkip
-- recupero spessore e verifico se passante
local dTh = EgtCurveThickness( EntId)
local bTrhu = ( abs( dTh) > DimZ - GEO.EPS_SMALL)
-- se passante, aggiunto affondamento
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- recupero flag di lavorazione
local nLocMach = EgtGetInfo( EntId, 'Mach', 'i') or 1
-- se versore fresa diretto come Z-,
if vtExtr:getZ() < 0 then
-- se passante, lo cambio in Z+
if bTrhu then
vtExtr = - vtExtr
local pIni = EgtSP( EntId, GDB_ID.ROOT)
if abs( pIni:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then -- se il foro parte sulla faccia sotto
-- in seconda fase controllo la nota mach se devo ristabilirla o escluderla
if not bFirstStep then
-- se è una geometria che avevo escluso la riabilito
if nLocMach >= 10 then
nLocMach = nLocMach - 10
elseif nLocMach > 0 then -- se è una che non avevo escluso la escludo
nLocMach = nLocMach + 10
else -- altrimenti la escludo perché è già stata fatta nella fase precedente
nLocMach = 11
end
EgtSetInfo( EntId, 'Mach', nLocMach)
end
-- se da lavorare ora
if nLocMach > 0 and nLocMach < 10 then
EgtMove( EntId, vtExtr * abs(dTh), GDB_RT.GLOB)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
end
elseif abs( pIni:getZ() - ptMax:getZ()) < GEO.EPS_SMALL then -- se il foro parte sulla faccia sopra
-- in seconda fase controllo la nota mach se devo ristabilirla o escluderla
if not bFirstStep then
if nLocMach >= 10 then
nLocMach = nLocMach - 10
elseif nLocMach > 0 then -- se è una che non avevo scluso la escludo
nLocMach = nLocMach + 10
else -- altrimenti la escludo perché è già stata fatta nella fase precedente
nLocMach = 11
end
EgtSetInfo( EntId, 'Mach', nLocMach)
end
-- se da lavorare ora
if nLocMach > 0 and nLocMach < 10 then
EgtMove( EntId, -vtExtr * abs(dTh), GDB_RT.GLOB)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
end
else -- altrimenti lo salto perché è in una Z diversa da sopra o sotto
EgtSetInfo( EntId, 'Mach', 0)
end
-- altrimenti lo salto
else
-- se non posso lavorare da sotto
if not bWorkUnder then
-- se non era ancora stato escluso, lo escludo sommando 10 al valore
if nLocMach < 10 then
nLocMach = nLocMach + 10
end
EgtSetInfo( EntId, 'Mach', nLocMach)
nNumSkip = nNumSkip + 1
else
nLocMach = 2
EgtSetInfo( EntId, 'Mach', nLocMach)
end
end
else
-- in seconda fase controllo la nota mach se devo ristabilirla o escluderla
if not bFirstStep then
if nLocMach >= 10 then
nLocMach = nLocMach - 10
elseif nLocMach > 0 then -- se è una che non avevo scluso la escludo
nLocMach = nLocMach + 10
else -- altrimenti la escludo perché è già stata fatta nella fase precedente
nLocMach = 11
end
EgtSetInfo( EntId, 'Mach', nLocMach)
end
end
-- se da lavorare ora
if nLocMach > 0 and nLocMach < 10 then
-- impongo senso di rotazione orario visto da sopra
local dAreaXY
_ , _ , dAreaXY = EgtCurveArea( EntId)
if dAreaXY and abs( dAreaXY) < 0.1 then
-- Rimando il valore originario in caso avessi skippato la lavorazione
return false, nNumMachSkip
end
local frEnt = EgtFR( EgtGetParent( EntId), GDB_ID.ROOT)
if nLocMach ~= 2 then
if dAreaXY and dAreaXY * frEnt:getVersZ():getZ() > 0 then
EgtInvertCurve( EntId)
end
else
if dAreaXY and dAreaXY * frEnt:getVersZ():getZ() < 0 then
EgtInvertCurve( EntId)
end
end
EgtSetInfo( EntId, 'ProbeMachZ', 3)
end
return true, nNumSkip, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustProbeMill( EntId, DimZ, ptMin, ptMax, nNumMachSkip,
bFirstStep, bNoWorkUnderSquare, bMakeGhostGeom, bNoWorkUpSquare, dThickPrb,
dDepthPrb)
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- se versore fresa diretto come Z-,
if vtExtr:getZ() < 0 then
EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB)
end
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- contatore disabilitazione lavorazione
local nNumSkip = nNumMachSkip
-- recupero spessore e verifico se passante
local dTh = EgtCurveThickness( EntId)
local bTrhu = ( abs( dTh) > DimZ - GEO.EPS_SMALL)
-- recupero flag di lavorazione
local nLocMach = EgtGetInfo( EntId, 'Mach', 'i') or 1
local sProfile = EgtGetInfo( EntId, 'ProfSide', 's') or ''
-- verifico direzione lavorazione
local pt1 = EgtSP( EntId, GDB_ID.ROOT)
local pt2 = EgtEP( EntId, GDB_ID.ROOT)
-- calcolo direzione entrante
vtExtr = pt2 - pt1; vtExtr:normalize()
-- se si trova a Z0 lo sposto a quota spessore porta
if abs( pt1:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then
EgtMove( EntId, Point3d( 0, 0, ( ptMax:getZ()-ptMin:getZ())), GDB_RT.GLOB)
end
-- se vettore estrusione è all'interno della tangente di 3° proseguo con la verifica
if abs(vtExtr:getZ()) < 0.0525 then
-- se non sono al primo giro setto profili bevel invertiti
if not bFirstStep and sProfile == 'BD' then
sProfile = 'BU'
elseif not bFirstStep and sProfile == 'BU' then
sProfile = 'BD'
end
if sProfile == 'BD' then
if bNoWorkUnderSquare then -- se non è possibile lavorare sottosquadra
EgtSetInfo( EntId, 'Mach', 13)
nNumSkip = nNumSkip + 1
EgtModifyCurveThickness( EntId, 0)
else
EgtSetInfo( EntId, 'Mach', 3)
EgtModifyCurveThickness( EntId, -( dThickPrb + dDepthPrb))
end
elseif sProfile == 'BU' then
if bNoWorkUpSquare then -- se non è possibile lavorare soprasquadra
EgtSetInfo( EntId, 'Mach', 12)
nNumSkip = nNumSkip + 1
EgtModifyCurveThickness( EntId, 0)
else
EgtSetInfo( EntId, 'Mach', 2)
EgtModifyCurveThickness( EntId, -dDepthPrb)
end
else
-- lavorazione standard
EgtRemoveInfo( EntId, 'Mach')
-- -- elimino il percorso ProbeSidePoint_ per non lavorarlo in un a fase successiva
-- if bFirstStep then
-- local nPar = EgtGetParent(EntId)
-- local tEnt = MachiningBase.FindGroupWithPartName( nPar, sParzName..'_secure')
-- if tEnt and #tEnt > 0 then
-- for i = 1, #tEnt do
-- EgtErase(tEnt[i])
-- end
-- end
-- tEnt = MachiningBase.FindGroupWithPartName( nPar, sParzName..'_keyway')
-- if tEnt and #tEnt > 0 then
-- for i = 1, #tEnt do
-- EgtErase(tEnt[i])
-- end
-- end
-- end
end
-- se diretto verso X+
if vtExtr:getX() > 0.98 then
EgtSetInfo( EntId, 'ProbeMachXY', 1) -- E101 = 1
-- altrimenti se diretto verso X-
elseif vtExtr:getX() < -0.98 then
EgtSetInfo( EntId, 'ProbeMachXY', -1) -- E101 = 4
-- altrimenti se diretto verso Y+
elseif vtExtr:getY() > 0.98 then
EgtSetInfo( EntId, 'ProbeMachXY', 2) -- E101 = 2
-- altrimenti se diretto verso Y-
elseif vtExtr:getY() < -0.98 then
EgtSetInfo( EntId, 'ProbeMachXY', -2) -- E101 = 6
else
EgtSetInfo( EntId, 'Mach', nLocMach + 20)
return false, nNumSkip, EntId
end
else
EgtSetInfo( EntId, 'Mach', nLocMach + 20)
return false, nNumSkip, EntId
end
return true, nNumSkip, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.AdjustVertAsOnHeads( EntId, bMakeGhostGeom)
if bMakeGhostGeom then
EntId = MachiningBase.MakeGhostCopy( EntId)
end
-- recupero versore estrusione/fresa
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- recupero punti inziale e finale
local pIni = EgtSP( EntId, GDB_ID.ROOT)
local pNewIni = Point3d( pIni)
local pEnd = EgtEP( EntId, GDB_ID.ROOT)
local pNewEnd = Point3d( pEnd)
local bExit = true
-- se punti diversi
if dist( pIni, pEnd) > GEO.EPS_SMALL then
-- se versore Y verso Y+ (faccia dietro)
if vtExtr:getY() > 0.99 then
-- se punto iniziale ha Y verso Y-
if pIni:getY() < ( pEnd:getY() - GEO.EPS_SMALL) then
-- ricostruisco il percorso tenendo la posizione di Y più interno
pNewEnd = Point3d( pEnd:getX(), pIni:getY(), pEnd:getZ())
-- se punto iniziale ha Y verso Y+
elseif pIni:getY() > ( pEnd:getY() + GEO.EPS_SMALL) then
-- ricostruisco il percorso tenendo la posizione di Y più interno
pNewIni = Point3d( pIni:getX(), pEnd:getY(), pIni:getZ())
end
-- se versore Y verso Y+ (faccia dietro)
elseif vtExtr:getY() < -0.99 then
-- se punto iniziale ha Y verso Y-
if pIni:getY() < ( pEnd:getY() - GEO.EPS_SMALL) then
-- ricostruisco il percorso tenendo la posizione di Y più interno
pNewIni = Point3d( pIni:getX(), pEnd:getY(), pIni:getZ())
-- se punto iniziale ha Y verso Y+
elseif pIni:getY() > ( pEnd:getY() + GEO.EPS_SMALL) then
-- ricostruisco il percorso tenendo la posizione di Y più interno
pNewEnd = Point3d( pEnd:getX(), pIni:getY(), pEnd:getZ())
end
end
-- se ho cambiato almeno 1 punto ricotruisco il percorso
if not AreSamePointExact( pIni, pNewIni) or not AreSamePointExact( pEnd, pNewEnd) then
nParent = EgtGetParent( EntId)
local sName = EgtGetName( EntId)
EgtErase (EntId)
EntId = EgtLine( nParent, pNewIni, pNewEnd, GDB_RT.GLOB)
EgtSetName( EntId, sName)
EgtModifyCurveThickness( EntId, 0)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_ID.ROOT)
EgtSetStatus( EntId, GDB_ST.OFF)
end
else
bExit = false
end
-- lavorazione standard
EgtRemoveInfo( EntId, 'Mach')
return bExit, EntId
end
--------------------------------------------------------------------------------
function MachiningBase.InvertGeom( EntId)
-- recupero spessore e verifico se passante
local dTh = EgtCurveThickness( EntId)
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- recupero flag di lavorazione
local nLocMach = EgtGetInfo( EntId, 'Mach', 'i') or 1
vtExtr = - vtExtr
-- se da lavorare ora
if nLocMach > 0 and nLocMach < 10 then
EgtMove( EntId, vtExtr * abs(dTh), GDB_RT.GLOB)
EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB)
if nLocMach == 1 then
-- nLocMach = nLocMach + 10 + 1
nLocMach = 2
elseif nLocMach == 2 then
-- nLocMach = nLocMach + 10 - 1
nLocMach = 1
-- else -- altrimenti la escludo perché è già stata fatta nella fase precedente
-- nLocMach = nLocMach + 10
end
EgtSetInfo( EntId, 'Mach', nLocMach)
end
return true
end
-----------------------------------------------------------------
-- *** Test Functions ***
-----------------------------------------------------------------
--------------------------------------------------------------------------------
function MachiningBase.TestThrouIsle( EntId, DimZ, ptMin, ptMax, bWorkUnder)
-- skip geometria, con spessore passante e geometria valida restituisce 0 perché è neutro
-- restituisce +1 se è sotto, restituisce -1 se è sopra
local nSkipGeom
local nTypeGeom = 0 -- 1: passante up, 2: passante dw, 3: cieca up, 4: cieca dw
-- recupero spessore e verifico se passante
local dTh = EgtCurveThickness( EntId)
local bTrhu = ( abs( dTh) > DimZ - GEO.EPS_SMALL)
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- se versore fresa diretto come Z-,
if vtExtr:getZ() < 0 then
-- se passante, lo cambio in Z+
if bTrhu then
local pIni = EgtSP( EntId, GDB_ID.ROOT)
if abs( pIni:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sotto
nSkipGeom = 0
nTypeGeom = 2
elseif abs( pIni:getZ() - ptMax:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sopra
nSkipGeom = 0
nTypeGeom = 2
end
-- altrimenti lo salto
else
if not bWorkUnder then
nSkipGeom = 1
else
nSkipGeom = 0
end
nTypeGeom = 4
end
else -- altrimenti versore fresa diretto come Z+
if bTrhu then
local pIni = EgtSP( EntId, GDB_ID.ROOT)
if abs( pIni:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sotto
nSkipGeom = 0
nTypeGeom = 1
elseif abs( pIni:getZ() - ptMax:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sopra
nSkipGeom = 0
nTypeGeom = 1
end
-- altrimenti lo salto
else
nSkipGeom = -1
nTypeGeom = 3
end
end
-- verifico se il percorso è chiuso
if EgtCurveIsClosed( EntId) then
-- verifico se area è troppo piccola
local vtMPlane, dDist, dArea = EgtCurveArea( EntId)
if abs( dArea) < 1 then
return false
end
-- altrimenti è aperto
else
-- faccio una copia del percorso
local sParnt = EgtGetParent( EntId)
local nNewEntId = EgtCopyGlob( EntId, sParnt)
-- chiudo il percorso
if EgtCloseCurveCompo( nNewEntId) then
local vtMPlane, dDist, dArea = EgtCurveArea( nNewEntId)
-- cancello percorso copia
EgtErase(nNewEntId)
if dArea and abs( dArea) < 1 then
return false
end
else
-- cancello percorso copia
EgtErase(nNewEntId)
-- verifico se area è troppo piccola
local vtMPlane, dDist, dArea = EgtCurveArea( EntId)
if dArea and abs( dArea) < 1 then
return false
end
end
end
--[[
local dAreaXY = EgtCurveAreaXY( EntId)
if dAreaXY and abs( dAreaXY) < 1 then
-- provo con EgtCurveArea
local vtV1, dDist, dArea = EgtCurveArea( EntId)
if dArea and abs( dArea) < 1 then
return false
else
dAreaXY = dArea
end
end
]]--
return true, nSkipGeom, nTypeGeom
end
--------------------------------------------------------------------------------
function MachiningBase.TestVertHole( EntId, DimZ, ptMin, ptMax, bWorkUnder)
-- skip geometria, con spessore passante e geometria valida restituisce 0 perché è neutro
-- restituisce +1 se è sotto, restituisce -1 se è sopra
local nSkipGeom
local nTypeGeom = 0 -- 1: passante up, 2: passante dw, 3: cieca up, 4: cieca dw
-- recupero spessore e verifico se passante
local dTh = EgtCurveThickness( EntId)
local bTrhu = ( abs( dTh) > DimZ - GEO.EPS_SMALL)
-- recupero versore estrusione
local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT)
-- se versore fresa diretto come Z-,
if vtExtr:getZ() < 0 then
-- se passante, lo cambio in Z+
if bTrhu then
local pIni = EgtSP( EntId, GDB_ID.ROOT)
if abs( pIni:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then -- se il foro parte sulla faccia sotto
nSkipGeom = 0
nTypeGeom = 2
elseif abs( pIni:getZ() - ptMax:getZ()) < GEO.EPS_SMALL then -- se il foro parte sulla faccia sopra
nSkipGeom = 0
nTypeGeom = 2
end
-- altrimenti lo salto
else
if not bWorkUnder then
nSkipGeom = 1
else
nSkipGeom = 0
end
nTypeGeom = 4
end
else -- altrimenti versore fresa diretto come Z+
if bTrhu then
local pIni = EgtSP( EntId, GDB_ID.ROOT)
if abs( pIni:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sotto
nSkipGeom = 0
nTypeGeom = 1
elseif abs( pIni:getZ() - ptMax:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sopra
nSkipGeom = 0
nTypeGeom = 1
end
-- altrimenti lo salto
else
nSkipGeom = -1
nTypeGeom = 3
end
end
-- verifico se il percorso è chiuso
if EgtCurveIsClosed( EntId) then
-- verifico se area è troppo piccola
local vtMPlane, dDist, dArea = EgtCurveArea( EntId)
if abs( dArea) < 1 then
return false
end
-- altrimenti è aperto
else
-- faccio una copia del percorso
local sParnt = EgtGetParent( EntId)
local nNewEntId = EgtCopyGlob( EntId, sParnt)
-- chiudo il percorso
if EgtCloseCurveCompo( nNewEntId) then
local vtMPlane, dDist, dArea = EgtCurveArea( nNewEntId)
-- cancello percorso copia
EgtErase(nNewEntId)
if dArea and abs( dArea) < 1 then
return false
end
else
-- cancello percorso copia
EgtErase(nNewEntId)
-- verifico se area è troppo piccola
local vtMPlane, dDist, dArea = EgtCurveArea( EntId)
if not dArea or abs( dArea) < 1 then
return false
end
end
end
--[[
-- verifico se area è troppo piccola
local vtMPlane, dDist, dArea = EgtCurveArea( EntId)
if not dArea or abs( dArea) < 1 then
return false
end
]]--
--[[
local dAreaXY = EgtCurveAreaXY( EntId)
if dAreaXY and abs( dAreaXY) < 1 then
-- provo con EgtCurveArea
local vtV1, dDist, dArea = EgtCurveArea( EntId)
if dArea and abs( dArea) < 1 then
return false
else
dAreaXY = dArea
end
end
]]--
return true, nSkipGeom, nTypeGeom
end
--------------------------------------------------------------------------------
function MachiningBase.TestMachining( sMach, EntId, bCheckPos)
-- verifico inserimento e applicazione della lavorazione alla geometria
if not sMach or ( sMach and #sMach == 0) then
return false, sMach
end
local nMach = EgtAddMachining( 'Dummy', sMach)
if not nMach then
return false
end
local bOk = EgtSetMachiningGeometry( EntId) and EgtApplyMachining()
local bBoxMach
if bOk and bCheckPos then
bBoxMach = EgtGetBBoxGlob ( nMach, GDB_BB.STANDARD)
end
EgtRemoveOperation( nMach)
-- ripristino ultima lavorazione rimasta
local nOper = EgtGetLastActiveOperation() or GDB_ID.NULL
local nType = EgtGetOperationType( nOper)
if nType ~= MCH_OY.NONE and nType ~= MCH_OY.DISP then
EgtSetCurrMachining( nOper)
EgtApplyMachining()
end
return bOk, sMach, bBoxMach
end
-----------------------------------------------------------------
-- *** MachTable Functions ***
-----------------------------------------------------------------
--------------------------------------------------------------------------------
function MachiningBase.GetToolDiamFromAttrib( sName, nInd)
--[[
local sCamData = 'CurrCamInfo'
local mCamData = require( sCamData)
local MachiningsTable = mCamData[DGD.MCC].MachiningsTable
local MachName = mCamData[DGD.MCC].MachName
local sLocMachname
local MTable = require( MachiningsTable)
]]--
-- prendo dalle note il nome tabella e poi da questa le macchine indicate
-- devo cercare per ogni macchina, che esiste
-- cerco nella tabella le associazioni che siano abilitate, che abbiano la macchina compatibile,
-- che ci sia il nome geometria corrispondente
local MachiningsTable = EgtGetInfo( DGD.PZ, 'MTable')
local MachiningsPath = EgtGetInfo( DGD.PZ, 'MTablePath')
-- se tavola non trovata esco subito
if not MachiningsTable or not MachiningsPath then return -8 end
local M = dofile( MachiningsPath..MachiningsTable..'.mtl')
local MTable = M.MTable
local MachinesName = M.MMachineData
local sLocMachId
local sMachine
-- per ogni macchina faccio il giro della tabella
for j = 1, #MachinesName do
sMachine = MachinesName[j].MachName
-- imposto la macchina corrente
if sMachine and EgtSetCurrMachine( sMachine) then
for i = 1, #MTable do
if MTable[i].On ~= 0 then
-- se non presente il nome macchina di default setto l'associazione per la macchina 1
sLocMachId = MTable[i].MachId
if not sLocMachId then sLocMachId = 1 end
if string.lower(MTable[i].Name) == string.lower(sName) and sLocMachId == j then
-- recupero il nome della lavorazione
local sMach
if nInd == 2 then
sMach = MTable[i].MachUp
elseif nInd == 3 then
sMach = MTable[i].MachDw
else
sMach = MTable[i].Mach
end
if not sMach then return -1 end -- errore su lavorazione non trovata
-- imposto la lavorazione come corrente
if not EgtMdbSetCurrMachining( sMach) then return -2, nil, sMach end
-- recupero l'utensile della lavorazione
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if not sTuuid then return -3, nil, sMach end
local sTool = EgtTdbGetToolFromUUID( sTuuid)
if not sTool then return -4, nil, sMach end
EgtTdbSetCurrTool( sTool)
local dDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
if not dDiam then return -5, nil, sMach end
return dDiam, nil, sMach
end
end
end
end
end
return - 6
end
--------------------------------------------------------------------------------
function MachiningBase.GetToolDataFromAttrib( sName, nInd, bReadNotes, bForceReadThick)
-- prendo dalle note il nome tabella e poi da questa le macchine indicate
-- devo cercare per ogni macchina, che esiste
-- cerco nella tabella le associazioni che siano abilitate, che abbiano la macchina compatibile,
-- che ci sia il nome geometria corrispondente
local MachiningsTable = EgtGetInfo( DGD.PZ, 'MTable')
local MachiningsPath = EgtGetInfo( DGD.PZ, 'MTablePath')
-- se tavola non trovata esco subito
if not MachiningsTable or not MachiningsPath then return -8 end
local M = dofile( MachiningsPath..MachiningsTable..'.mtl')
local MTable = M.MTable
local MachinesName = M.MMachineData
local sLocMachId
local sMachine
-- per ogni macchina faccio il giro della tabella
for j = 1, #MachinesName do
sMachine = MachinesName[j].MachName
-- imposto la macchina corrente
if sMachine and EgtSetCurrMachine( sMachine) then
for i = 1, #MTable do
if MTable[i].On ~= 0 then
-- se non presente il nome macchina di default setto l'associazione per la macchina 1
sLocMachId = MTable[i].MachId
if not sLocMachId then sLocMachId = 1 end
if string.lower(MTable[i].Name) == string.lower(sName) and sLocMachId == j then
-- recupero il nome della lavorazione
local sMach
if nInd == 2 then
sMach = MTable[i].MachUp
elseif nInd == 3 then
sMach = MTable[i].MachDw
else
sMach = MTable[i].Mach
end
if not sMach then return -1 end
-- imposto la lavorazione come corrente
if not EgtMdbSetCurrMachining( sMach) then return -2, nil, sMach end
-- recupero l'eventuale nota
local sMachNotes = ''
if bReadNotes then
sMachNotes = EgtMdbGetCurrMachiningParam( MCH_MP.USERNOTES)
end
-- recupero l'utensile della lavorazione
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if not sTuuid then return -3, nil, sMach end
local sTool = EgtTdbGetToolFromUUID( sTuuid)
if not sTool then return -4, nil, sMach end
EgtTdbSetCurrTool( sTool)
local dDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
if not dDiam then return -5, nil, sMach end -- se non trovato diametro esco
local dHWork = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)
if not dHWork then return -7, nil, sMach end -- se non trovato massimo materiale esco
local dHType = EgtTdbGetCurrToolParam( MCH_TP.TYPE)
local dThBlade
-- se forzata lettura spessore lama
if bForceReadThick then
-- se tipo utensile lama
if dHType == MCH_TY.SAW_STD or dHType == MCH_TY.SAW_FLAT then
dThBlade = EgtTdbGetCurrToolParam( MCH_TP.THICK)
-- se è tipo fresa allaora lo spessore lama setto uguale all'altezza tagliente
elseif dHType == MCH_TY.MILL_STD or dHType == MCH_TY.MILL_NOTIP then
dThBlade = dHWork
end
-- se utensile lama
elseif dHType == MCH_TY.SAW_STD or dHType == MCH_TY.SAW_FLAT then
dThBlade = EgtTdbGetCurrToolParam( MCH_TP.THICK)
end
-- ritorno i valori diametro utensile e lunghezza massima
return dDiam, dHWork, sMach, dThBlade, sMachNotes
end
end
end
end
end
return - 6
end
return MachiningBase