Merge remote-tracking branch 'origin/CAM_Auto'

This commit is contained in:
andrea.villa
2024-10-03 12:25:22 +02:00
10 changed files with 520 additions and 266 deletions
+4 -1
View File
@@ -135,7 +135,10 @@
"EgtMdbSave",
"EgtMoveRawPart",
"EgtCurveThickness",
"EgtSetCurrMachining"
"EgtSetCurrMachining",
"EgtCAvSetStdTool",
"EgtCAvToolPosStm",
"EgtCAvToolPosBox"
],
"Lua.diagnostics.disable": [
"empty-block"
+12 -5
View File
@@ -12,11 +12,18 @@ local WinData = require( 'WinData')
function FeatureData.GetDrillingData( Proc)
local bOk, ptCentre, vtDir, dRadius = EgtCurveIsACircle( Proc.id)
Proc.dDiam = dRadius * 2
Proc.dLen = abs( EgtCurveThickness( Proc.id)) or 0
vtDir = EgtCurveExtrusion( Proc.id)
local Frame = EgtGetGlobFrame( Proc.id)
-- trasformo punti e vettori in globale
ptCentre:toGlob( Frame)
vtDir:toGlob( Frame)
Proc.dDiameter = dRadius * 2
Proc.dLength = abs( EgtCurveThickness( Proc.id)) or 0
Proc.ptCentre = ptCentre
Proc.vtDir = vtDir
Proc.ReferenceSide = EgtGetInfo( Proc.id, 'REFERENCE_SIDE', 's') or nil
return Proc
end
@@ -28,14 +35,14 @@ function FeatureData.GetCuttingData( Proc)
end
-------------------------------------------------------------------------------------------------------------
-- Recupero dati foro
-- Recupero dati svuotatura
function FeatureData.GetPocketingData( Proc)
return Proc
end
-------------------------------------------------------------------------------------------------------------
-- Recupero dati foro
-- Recupero dati per fresatura
function FeatureData.GetMillingData( Proc)
return Proc
+1 -10
View File
@@ -35,16 +35,7 @@ end
---------------------------------------------------------------------
----------------------------- PIECES ------------------------------
---------------------------------------------------------------------
function Identity.GetPieceIndexPart( PARTS, idGeom)
local nIndexPart
for i = 1, #PARTS do
if PARTS[i].id == idGeom then
nIndexPart = i
break
end
end
return nIndexPart
end
---------------------------------------------------------------------
return Identity
+231 -151
View File
@@ -122,7 +122,35 @@ end
-------------------------------------------------------------------------------------------------------------
-- funzione per cercare utensile tipo PUNTA A FORARE con certe caratteristiche
-- TODO da fare
function MachiningLib.FindDrill()
function MachiningLib.FindDrill( Proc, ToolSearchParameters)
local ToolInfo = {}
if not ToolSearchParameters.dTolerance then
ToolSearchParameters.dTolerance = 0
end
local nBestToolIndex
for i = 1, #TOOLS do
local bIsToolCompatible = false
-- TODO per il momento si cercano solo le punte. Bisognerebbe valutare anche frese che possono lavorare di testa
if TOOLS[i].sFamily == 'DRILLBIT' then
bIsToolCompatible = true
end
if bIsToolCompatible then
--TODO per il momento si prende il primo utensile con lo stesso diametro, senza considerare altri parametri tipo lunghezza ecc...
if abs( TOOLS[i].dDiameter - ToolSearchParameters.dDiameter) < ToolSearchParameters.dTolerance + GEO.EPS_SMALL * 10 then
if not nBestToolIndex then
nBestToolIndex = i
break
end
end
end
end
ToolInfo.nToolIndex = nBestToolIndex
return ToolInfo
end
-------------------------------------------------------------------------------------------------------------
@@ -134,19 +162,50 @@ function MachiningLib.GetPhaseMach( Proc)
nPhase = Proc.nPhase
-- altrimenti si calcola il comportamento standard
else
if Proc.sEntityName == 'Left' or Proc.sEntityName == 'Out' then
nPhase = 1
end
if Proc.sEntityName == 'Right' or Proc.sEntityName == 'In' then
nPhase = 2
-- se macchina tipo LINEA
if WinData.MACH_TYPE == 'LINE' then
if Proc.AffectedFaces.bTop then
nPhase = 1
end
if Proc.AffectedFaces.bFront or Proc.AffectedFaces.bLeft then
nPhase = EgtIf( WinData.FIRST_PHASE_LOAD == 'PUSH', 1, 2)
end
if Proc.AffectedFaces.bBack or Proc.AffectedFaces.bRight then
nPhase = EgtIf( WinData.FIRST_PHASE_LOAD == 'PUSH', 2, 1)
end
-- se macchina tipo PANTOGRAFO
else
if Proc.AffectedFaces.bTop or Proc.AffectedFaces.bLeft or Proc.AffectedFaces.bRight then
nPhase = 1
end
if Proc.AffectedFaces.bFront then
nPhase = EgtIf( WinData.FIRST_PHASE_LOAD == 'PUSH', 1, 2)
end
if Proc.AffectedFaces.bBack then
nPhase = EgtIf( WinData.FIRST_PHASE_LOAD == 'PUSH', 2, 1)
end
end
end
return nPhase
end
-------------------------------------------------------------------------------------------------------------
-- funzione che ritorna la distanza di sicurezza da aggiungere alla lavorazione di foratura per evitare colisioni in rapido
function MachiningLib.GetDrillAdditionalSafeDistanceToRaw( Proc, Part, Machining)
-- se non è foro esco subito
if Proc.sType ~= 'Hole' then
return 0
end
local bVirtualToolOk = EgtCAvSetStdTool( TOOLS[Machining.nToolIndex].dLength, TOOLS[Machining.nToolIndex].dDiameter, 0)
local dStartSafetyLength = EgtCAvToolPosBox( Proc.ptCentre, Proc.vtDir, Part.b3RawPart, Proc.vtDir)
-- si riporta valore calcolato sulla punta utensile
dStartSafetyLength = dStartSafetyLength - TOOLS[Machining.nToolIndex].dLength
return dStartSafetyLength + 5 -- si aggiungono 5mm di sicurezza extra
end
-------------------------------------------------------------------------------------------------------------
-- salva in lista globale la lavorazione appena calcolata
function MachiningLib.AddNewMachining( ProcToAdd, MachiningToAdd, AuxInfoToAdd)
function MachiningLib.AddNewMachining( ProcToAdd, MachiningToAdd, AuxiliaryDataToAdd)
-- Controllo parametri obbligatori
if not MachiningToAdd.nType or not MachiningToAdd.nToolIndex or not MachiningToAdd.Geometry or not ProcToAdd.id then
return false
@@ -180,7 +239,7 @@ function MachiningLib.AddNewMachining( ProcToAdd, MachiningToAdd, AuxInfoToAdd)
local Machining = {}
Machining.Proc = ProcToAdd
Machining.Machining = MachiningToAdd
Machining.AuxInfo = AuxInfoToAdd
Machining.AuxiliaryData = AuxiliaryDataToAdd
table.insert( MACHININGS, Machining)
return true
end
@@ -192,161 +251,182 @@ function MachiningLib.AddOperation( OperationToInsert)
local sErr = ''
local bAreAllMachiningApplyOk = true
-- creazione lavorazione
local nOperationId = EgtCreateMachining( OperationToInsert.Machining.sOperationName, OperationToInsert.Machining.nType, OperationToInsert.Machining.sToolName)
EgtSetCurrMachining( nOperationId)
-- parametri generali lavorazione
local MachiningParameters = {
{ sName = 'sDepth', nMchParam = MCH_MP.DEPTH_STR},
{ sName = 'bInvert', nMchParam = MCH_MP.INVERT},
{ sName = 'nWorkside', nMchParam = MCH_MP.WORKSIDE},
{ sName = 'nFaceuse', nMchParam = MCH_MP.FACEUSE},
{ sName = 'nSCC', nMchParam = MCH_MP.SCC},
{ sName = 'bToolInvert', nMchParam = MCH_MP.TOOLINVERT},
{ sName = 'sBlockedAxis', nMchParam = MCH_MP.BLOCKEDAXIS},
{ sName = 'sInitialAngles', nMchParam = MCH_MP.INITANGS},
{ sName = 'nHeadSide', nMchParam = MCH_MP.HEADSIDE},
{ sName = 'nSubType', nMchParam = MCH_MP.SUBTYPE},
{ sName = 'dOverlap', nMchParam = MCH_MP.OVERL},
{ sName = 'nStepType', nMchParam = MCH_MP.STEPTYPE},
{ sName = 'dStartSafetyLength', nMchParam = MCH_MP.STARTPOS},
{ sName = 'dReturnPos', nMchParam = MCH_MP.RETURNPOS},
{ sName = 'dRadialOffset', nMchParam = MCH_MP.OFFSR},
{ sName = 'dLongitudinalOffset', nMchParam = MCH_MP.OFFSL},
{ sName = 'dStartSlowLen', nMchParam = MCH_MP.STARTSLOWLEN},
{ sName = 'dEndSlowLen', nMchParam = MCH_MP.ENDSLOWLEN},
{ sName = 'dThrouAddLen', nMchParam = MCH_MP.THROUADDLEN},
{ sName = 'sSystemNotes', nMchParam = MCH_MP.SYSNOTES},
{ sName = 'sUserNotes', nMchParam = MCH_MP.USERNOTES}
}
if nOperationId then
-- impostazione geometria
EgtSetMachiningGeometry( OperationToInsert.Machining.Geometry)
-- parametri relativi allo step
MachiningParameters.Steps = {
{ sName = 'nStepType', nMchParam = MCH_MP.STEPTYPE},
{ sName = 'dStep', nMchParam = MCH_MP.STEP},
{ sName = 'dSideStep', nMchParam = MCH_MP.SIDESTEP}
}
-- impostazione parametri lavorazione
if OperationToInsert.Machining.sDepth then
EgtSetMachiningParam( MCH_MP.DEPTH_STR, OperationToInsert.Machining.sDepth)
end
if OperationToInsert.Machining.bInvert then
EgtSetMachiningParam( MCH_MP.INVERT, OperationToInsert.Machining.bInvert)
end
if OperationToInsert.Machining.nWorkSide then
EgtSetMachiningParam( MCH_MP.WORKSIDE, OperationToInsert.Machining.nWorkSide)
end
if OperationToInsert.Machining.nFaceuse then
EgtSetMachiningParam( MCH_MP.FACEUSE, OperationToInsert.Machining.nFaceuse)
end
if OperationToInsert.Machining.nSCC then
EgtSetMachiningParam( MCH_MP.SCC, OperationToInsert.Machining.nSCC)
end
if OperationToInsert.Machining.bToolInvert then
EgtSetMachiningParam( MCH_MP.TOOLINVERT, OperationToInsert.Machining.bToolInvert)
end
if OperationToInsert.Machining.sBlockedAxis then
EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, OperationToInsert.Machining.sBlockedAxis)
end
if OperationToInsert.Machining.sInitialAngles then
EgtSetMachiningParam( MCH_MP.INITANGS, OperationToInsert.Machining.sInitialAngles)
end
if OperationToInsert.Machining.nHeadSide then
EgtSetMachiningParam( MCH_MP.HEADSIDE, OperationToInsert.Machining.nHeadSide)
end
if OperationToInsert.Machining.nSubType then
EgtSetMachiningParam( MCH_MP.SUBTYPE, OperationToInsert.Machining.nSubType)
end
if OperationToInsert.Machining.dOverlap then
EgtSetMachiningParam( MCH_MP.OVERL, OperationToInsert.Machining.dOverlap)
end
-- parametri relativi all'approccio
MachiningParameters.LeadIn = {
{ sName = 'nType', nMchParam = MCH_MP.LEADINTYPE},
{ sName = 'dStartAddLength', nMchParam = MCH_MP.STARTADDLEN},
{ sName = 'dTangentDistance', nMchParam = MCH_MP.LITANG},
{ sName = 'dPerpDistance', nMchParam = MCH_MP.LIPERP},
{ sName = 'dElevation', nMchParam = MCH_MP.LIELEV},
{ sName = 'dCompLength', nMchParam = MCH_MP.LICOMPLEN}
}
-- step
if OperationToInsert.Machining.Steps then
if OperationToInsert.Machining.Steps.dStepType then
EgtSetMachiningParam( MCH_MP.STEPTYPE, OperationToInsert.Machining.Steps.dStepType)
end
if OperationToInsert.Machining.Steps.dStep then
EgtSetMachiningParam( MCH_MP.STEP, OperationToInsert.Machining.Steps.dStep)
end
if OperationToInsert.Machining.Steps.dSideStep then
EgtSetMachiningParam( MCH_MP.SIDESTEP, OperationToInsert.Machining.Steps.dSideStep)
end
end
-- parametri relativi alla retrazione
MachiningParameters.LeadOut = {
{ sName = 'nType', nMchParam = MCH_MP.LEADOUTTYPE},
{ sName = 'dEndAddLength', nMchParam = MCH_MP.ENDADDLEN},
{ sName = 'dTangentDistance', nMchParam = MCH_MP.LOTANG},
{ sName = 'dPerpDistance', nMchParam = MCH_MP.LOPERP},
{ sName = 'dElevation', nMchParam = MCH_MP.LOELEV},
{ sName = 'dCompLength', nMchParam = MCH_MP.LOCOMPLEN}
}
if OperationToInsert.Machining.dStartPos then
EgtSetMachiningParam( MCH_MP.STARTPOS, OperationToInsert.Machining.dStartPos)
end
if OperationToInsert.Machining.dReturnPos then
EgtSetMachiningParam( MCH_MP.RETURNPOS, OperationToInsert.Machining.dReturnPos)
end
-- parametri da scrivere nelle note utente
local UserNotes = {
{ sName = 'dMaxElev', sMchParam = 'MaxElev'}
}
if OperationToInsert.Machining.dRadialOffset then
EgtSetMachiningParam( MCH_MP.OFFSR, OperationToInsert.Machining.dRadialOffset)
end
if OperationToInsert.Machining.dLongitudinalOffset then
EgtSetMachiningParam( MCH_MP.OFFSL, OperationToInsert.Machining.dLongitudinalOffset)
end
-- parametri da scrivere nelle note di sistema
local SystemNotes = {
}
-- paraemtri attacco
if OperationToInsert.Machining.LeadIn then
if OperationToInsert.Machining.LeadIn.nType then
EgtSetMachiningParam( MCH_MP.LEADINTYPE, OperationToInsert.Machining.LeadIn.nType)
end
if OperationToInsert.Machining.LeadIn.dStartAddLength then
EgtSetMachiningParam( MCH_MP.STARTADDLEN, OperationToInsert.Machining.LeadIn.dStartAddLength)
end
if OperationToInsert.Machining.LeadIn.dTangentDistance then
EgtSetMachiningParam( MCH_MP.LITANG, OperationToInsert.Machining.LeadIn.dTangentDistance)
end
if OperationToInsert.Machining.LeadIn.dPerpDistance then
EgtSetMachiningParam( MCH_MP.LIPERP, OperationToInsert.Machining.LeadIn.dPerpDistance)
end
if OperationToInsert.Machining.LeadIn.dElevation then
EgtSetMachiningParam( MCH_MP.LIELEV, OperationToInsert.Machining.LeadIn.dElevation)
end
if OperationToInsert.Machining.LeadIn.dCompLength then
EgtSetMachiningParam( MCH_MP.LICOMPLEN, OperationToInsert.Machining.LeadIn.dCompLength)
end
end
-- parametri uscita
if OperationToInsert.Machining.LeadOut then
if OperationToInsert.Machining.LeadOut.nType then
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, OperationToInsert.Machining.LeadOut.nType)
end
if OperationToInsert.Machining.LeadOut.dEndAddLength then
EgtSetMachiningParam( MCH_MP.ENDADDLEN, OperationToInsert.Machining.LeadOut.dEndAddLength)
end
if OperationToInsert.Machining.LeadOut.dTangentDistance then
EgtSetMachiningParam( MCH_MP.LOTANG, OperationToInsert.Machining.LeadOut.dTangentDistance)
end
if OperationToInsert.Machining.LeadOut.dPerpDistance then
EgtSetMachiningParam( MCH_MP.LOPERP, OperationToInsert.Machining.LeadOut.dPerpDistance)
end
if OperationToInsert.Machining.LeadOut.dElevation then
EgtSetMachiningParam( MCH_MP.LOELEV, OperationToInsert.Machining.LeadOut.dElevation)
end
if OperationToInsert.Machining.LeadOut.dCompLength then
EgtSetMachiningParam( MCH_MP.LOCOMPLEN, OperationToInsert.Machining.LeadOut.dCompLength)
end
end
local nClonesToAdd = 1
if OperationToInsert.AuxiliaryData.Clones then
nClonesToAdd = #OperationToInsert.AuxiliaryData.Clones
end
for j = 1, nClonesToAdd do
-- creazione lavorazione
local nOperationId = EgtCreateMachining( OperationToInsert.Machining.sOperationName, OperationToInsert.Machining.nType, OperationToInsert.Machining.sToolName)
if OperationToInsert.Machining.dStartSlowLen then
EgtSetMachiningParam( MCH_MP.STARTSLOWLEN, OperationToInsert.Machining.dStartSlowLen)
end
if OperationToInsert.Machining.dEndSlowLen then
EgtSetMachiningParam( MCH_MP.ENDSLOWLEN, OperationToInsert.Machining.dEndSlowLen)
end
if OperationToInsert.Machining.dThrouAddLen then
EgtSetMachiningParam( MCH_MP.THROUADDLEN, OperationToInsert.Machining.dThrouAddLen)
end
if nOperationId then
-- impostazione geometria
EgtSetMachiningGeometry( OperationToInsert.Machining.Geometry)
-- parametri da settare nelle note di sistema
-- TODO da decidere quali sono le note da salvare qui. Probabilmente tutte quelle relative all'ordine delle lavorazioni
local sSystemNotes = EgtGetMachiningParam( MCH_MP.SYSNOTES)
--if OperationToInsert.Machining.nMachiningOrder then
-- sSystemNotes = EgtSetValInNotes( sSystemNotes, 'MachiningOrder', OperationToInsert.Machining.nMachiningOrder)
--end
EgtSetMachiningParam( MCH_MP.SYSNOTES, sSystemNotes)
-- impostazione parametri lavorazione
-- TODO scrivere sempre Steps, LeadIn, LeadOut nelle tabelle in modo da non dover controllare ogni volta che ci siano
for k = 1, #MachiningParameters do
local sValue
if OperationToInsert.AuxiliaryData.Clones and OperationToInsert.AuxiliaryData.Clones[j][MachiningParameters[k].sName] then
sValue = OperationToInsert.AuxiliaryData.Clones[j][MachiningParameters[k].sName]
elseif OperationToInsert.Machining[MachiningParameters[k].sName] then
sValue = OperationToInsert.Machining[MachiningParameters[k].sName]
end
if sValue then
EgtSetMachiningParam( MachiningParameters[k].nMchParam, sValue)
end
end
for k = 1, #MachiningParameters.Steps do
local sValue
if OperationToInsert.AuxiliaryData.Clones and OperationToInsert.AuxiliaryData.Clones[j].Steps and OperationToInsert.AuxiliaryData.Clones[j].Steps[MachiningParameters.Steps[k].sName] then
sValue = OperationToInsert.AuxiliaryData.Clones[j].Steps[MachiningParameters.Steps[k].sName]
elseif OperationToInsert.Machining.Steps and OperationToInsert.Machining.Steps[MachiningParameters.Steps[k].sName] then
sValue = OperationToInsert.Machining.Steps[MachiningParameters.Steps[k].sName]
end
if sValue then
EgtSetMachiningParam( MachiningParameters.Steps[k].nMchParam, sValue)
end
end
for k = 1, #MachiningParameters.LeadIn do
local sValue
if OperationToInsert.AuxiliaryData.Clones and OperationToInsert.AuxiliaryData.Clones[j].LeadIn and OperationToInsert.AuxiliaryData.Clones[j].LeadIn[MachiningParameters.LeadIn[k].sName] then
sValue = OperationToInsert.AuxiliaryData.Clones[j].LeadIn[MachiningParameters.LeadIn[k].sName]
elseif OperationToInsert.Machining.LeadIn and OperationToInsert.Machining.LeadIn[MachiningParameters.LeadIn[k].sName] then
sValue = OperationToInsert.Machining.LeadIn[MachiningParameters.LeadIn[k].sName]
end
if sValue then
EgtSetMachiningParam( MachiningParameters.LeadIn[k].nMchParam, sValue)
end
end
for k = 1, #MachiningParameters.LeadOut do
local sValue
if OperationToInsert.AuxiliaryData.Clones and OperationToInsert.AuxiliaryData.Clones[j].LeadOut and OperationToInsert.AuxiliaryData.Clones[j].LeadOut[MachiningParameters.LeadOut[k].sName] then
sValue = OperationToInsert.AuxiliaryData.Clones[j].LeadOut[MachiningParameters.LeadOut[k].sName]
elseif OperationToInsert.Machining.LeadOut and OperationToInsert.Machining.LeadOut[MachiningParameters.LeadOut[k].sName] then
sValue = OperationToInsert.Machining.LeadOut[MachiningParameters.LeadOut[k].sName]
end
if sValue then
EgtSetMachiningParam( MachiningParameters.LeadOut[k].nMchParam, sValue)
end
end
for k = 1, #UserNotes do
local sValue
if OperationToInsert.AuxiliaryData.Clones and OperationToInsert.AuxiliaryData.Clones[j][UserNotes[k].sName] then
sValue = OperationToInsert.AuxiliaryData.Clones[j][UserNotes[k].sName]
elseif OperationToInsert.Machining[UserNotes[k].sName] then
sValue = OperationToInsert.Machining[UserNotes[k].sName]
end
if sValue then
local sUserNotes = ''
sUserNotes = EgtSetValInNotes( sUserNotes, UserNotes[k].sMchParam, sValue)
EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes)
end
end
-- parametri da settare nelle note di sistema
-- TODO da decidere quali sono le note da salvare qui. Probabilmente tutte quelle relative all'ordine delle lavorazioni
--if OperationToInsert.Machining.nMachiningOrder then
-- sSystemNotes = EgtSetValInNotes( sSystemNotes, 'MachiningOrder', OperationToInsert.Machining.nMachiningOrder)
--end
for k = 1, #SystemNotes do
local sValue
if OperationToInsert.AuxiliaryData.Clones and OperationToInsert.AuxiliaryData.Clones[j][SystemNotes[k].sName] then
sValue = OperationToInsert.AuxiliaryData.Clones[j][SystemNotes[k].sName]
elseif OperationToInsert.Machining[SystemNotes[k].sName] then
sValue = OperationToInsert.Machining[SystemNotes[k].sName]
end
if sValue then
local sSystemNotes = ''
sSystemNotes = EgtSetValInNotes( sSystemNotes, SystemNotes[k].sMchParam, sValue)
EgtSetMachiningParam( MCH_MP.SYSNOTES, sSystemNotes)
end
end
-- parametri da settare nelle note utente
local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES)
if OperationToInsert.Machining.dMaxElev then
sUserNotes = EgtSetValInNotes( sUserNotes, 'MaxElev', OperationToInsert.Machining.dMaxElev)
end
EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes)
local b3MachEncumbrance = nil
local bIsApplyOk = MachiningLib.ApplyMachining( true, false)
if not bIsApplyOk then
bAreAllMachiningApplyOk = false
nErr, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nOperationId, false)
else
local nClId = EgtGetFirstNameInGroup( nOperationId, 'CL')
local ptMin = EgtGetInfo( nClId, 'MMIN', 'p')
local ptMax = EgtGetInfo( nClId, 'MMAX', 'p')
-- box percorso lavorazione
if ptMin and ptMax then
local dToolRadius = TOOLS[OperationToInsert.Machining.nToolIndex].dTotDiameter / 2
if dToolRadius then
ptMin = ptMin - Vector3d( dToolRadius, 0, 0)
ptMax = ptMax + Vector3d( dToolRadius, 0, 0)
end
end
b3MachEncumbrance = BBox3d( ptMin, ptMax)
end
local b3MachEncumbrance = nil
local bIsApplyOk = MachiningLib.ApplyMachining( true, false)
if not bIsApplyOk then
bAreAllMachiningApplyOk = false
nErr, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nOperationId, false)
return bIsApplyOk, sErr, b3MachEncumbrance
else
local nClId = EgtGetFirstNameInGroup( nOperationId, 'CL')
local ptMin = EgtGetInfo( nClId, 'MMIN', 'p')
local ptMax = EgtGetInfo( nClId, 'MMAX', 'p')
-- box percorso lavorazione
b3MachEncumbrance = BBox3d( ptMin, ptMax)
return false, 'UNEXPECTED ERROR: Error on creating machining'
end
return bIsApplyOk, sErr, b3MachEncumbrance
else
return false, 'UNEXPECTED ERROR: Error on creating machining'
end
end
+121 -64
View File
@@ -113,15 +113,13 @@ function WinExec.GetToolsFromDB()
-- se verifica condizioni minime, recupero tutti gli altri dati
if bToolLoadedOnSetup and sToolType then
-- TODO Tool.AName -> da rimuovere perchè non serve. Per il momento lo manteniamo solo perchè è più facile vedere e interpretare la lista utensili nella watch di zerobrane
-- Nell'utilizzo, si legge sempre il Tool.Name
Tool.AName = Tool.sName
Tool.sTcPos = sToolTCPos
Tool.sFamily = sToolFamily
Tool.sType = sToolType
Tool.nTypeId = nToolTypeId
Tool.dMaxMaterial = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)
Tool.dDiameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
Tool.dTotDiameter = EgtTdbGetCurrToolParam( MCH_TP.TOTDIAM)
Tool.dLength = EgtTdbGetCurrToolParam( MCH_TP.LEN)
Tool.dSpeed = EgtTdbGetCurrToolParam( MCH_TP.SPEED)
Tool.bIsCCW = Tool.dSpeed < 0
@@ -130,10 +128,9 @@ function WinExec.GetToolsFromDB()
Tool.Feeds.dStartFeed = EgtTdbGetCurrToolParam( MCH_TP.STARTFEED)
Tool.Feeds.dEndFeed = EgtTdbGetCurrToolParam( MCH_TP.ENDFEED)
Tool.Feeds.dTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED)
-- TODO serve funzione in WinData che data la posizione dell'utensile e della testa, capisca il montaggio (testa sopra - testa sotto - aggregato - ecc...)
Tool.sHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD)
Tool.SetupInfo = {}
Tool.SetupInfo = WinData.GetSetupInfo( Tool.sHead)
Tool.SetupInfo = WinData.GetSetupInfo( {sHead = Tool.sHead, sTcPos = Tool.sTcPos})
Tool.sUUID = EgtTdbGetCurrToolParam( MCH_TP.UUID)
Tool.sUserNotes = EgtTdbGetCurrToolParam( MCH_TP.USERNOTES)
Tool.dMaxDepth = EgtTdbGetCurrToolMaxDepth() or Tool.dMaxMaterial
@@ -199,7 +196,7 @@ end
-- *** Inserimento delle lavorazioni nelle travi ***
-------------------------------------------------------------------------------------------------------------
local function CollectFeatures( vProc, Part)
local function CollectFeatures( vProc, Part, nIndexPart)
-- recupero le feature
local LayerId = {}
LayerId[1] = WinLib.GetAddGroup( Part.id)
@@ -215,13 +212,12 @@ local function CollectFeatures( vProc, Part)
if sType and nDo == 1 then
local Proc = {}
Proc.idPart = Part.id
Proc.nIndexPart = nIndexPart
Proc.id = ProcId
Proc.nFlg = 1
Proc.sType = sType
Proc.b3Box = EgtGetBBoxGlob( ProcId, GDB_BB.STANDARD)
Proc.nPhase = EgtGetInfo( ProcId, 'PHASE', 'i') or nil
-- informazioni facce
Proc.AffectedFaces = WinLib.GetAffectedFaces( Proc, Part)
-- se esiste la geometria
if Proc.b3Box and not Proc.b3Box:isEmpty() then
@@ -246,7 +242,8 @@ local function CollectFeatures( vProc, Part)
if ID.IsProfiling( Proc) then
Proc = FeatureData.GetProfilingData( Proc)
end
-- informazioni facce
Proc.AffectedFaces = WinLib.GetAffectedFaces( Proc, Part)
-- inserisco feature in lista
table.insert( vProc, Proc)
else
@@ -274,64 +271,117 @@ local function GetFeatureInfoAndDependency( vProc, Part)
local ProcB = vProc[j]
-- TODO dipendenze da controllare :
-- * gruppo di forature con aggregato 2/3 uscite
-- * Se 'Left' e 'Out' hanno stesso profilo, vanno concatenati (anche 'Right' se consentito dalle dimensioni)
-- * Se 'Left' e 'Out' hanno stesso profilo, vanno concatenati (anche 'Right' se consentito dalla macchina)
end
end
end
return vProc
end
-------------------------------------------------------------------------------------------------------------
-- ottimizza le lavorazioni, considerando di ridurre i cambi utensile
local function SortByChangeToolOpt( MACHININGS)
local vProcToSortToolOpt = {}
vProcToSortToolOpt = MACHININGS
for i = 1, #vProcToSortToolOpt do
for j = i + 1, #vProcToSortToolOpt do
-- se sono su stessa fase
if vProcToSortToolOpt[i].AuxiliaryData.nPhase == vProcToSortToolOpt[j].AuxiliaryData.nPhase then
-- se stesso utensile
if vProcToSortToolOpt[i].Machining.nToolIndex == vProcToSortToolOpt[j].Machining.nToolIndex then
if i + 1 == j then
-- il confronto riparte dall'ultimo spostato
i = j
else
-- sposto lavorazione confrontata dopo la principale
WinLib.ChangeElementPositionInTable( vProcToSortToolOpt, j, i+1)
-- il confronto riparte dall'ultimo spostato
i = j
end
end
end
end
end
return vProcToSortToolOpt
end
-------------------------------------------------------------------------------------------------------------
-- Ordina le feature in base a fase di lavorazione
-- L'ordine è indicativamente:
-- 1) Tagli di testa
-- 2) Fori
-- 3) Scassi serratura/maniglia
-- 4) Profili testa
-- 4) Profili testa / Minizinken
-- 5) Profili longitudinali
-- 6) Incontri/scontri
-- 6) Incontri/scontri (encounter/clash)
-- 7) Listello ferma-vetro
-- TODO Ordinamento da fare
local function OrderMachining( MACHININGS)
local vProcToSort = MACHININGS
-- funzione di confronto. TRUE = B1 prima di B2. FALSE = B2 prima di B1
local function CompareFeatures( B1, B2)
-- se secondo disabilitato, va lasciato dopo
if B1.Proc.nFlg ~= 0 and B2.Proc.nFlg == 0 then
return true
elseif B1.AuxiliaryData.nPhase < B2.AuxiliaryData.nPhase then
return true
elseif B1.AuxiliaryData.nPhase > B2.AuxiliaryData.nPhase then
return false
elseif B1.Machining.Geometry == B2.Machining.Geometry then
return B1.AuxiliaryData.nIndexMachining < B2.AuxiliaryData.nIndexMachining
elseif B1.AuxiliaryData.bIsProfiling and B2.AuxiliaryData.bIsDrilling and B2.AuxiliaryData.bExecAfterProfile then
return true
elseif B1.AuxiliaryData.bIsDrilling and B1.AuxiliaryData.bExecAfterProfile and B2.AuxiliaryData.bIsProfiling then
return false
elseif B1.AuxiliaryData.bIsDrilling and B2.AuxiliaryData.bIsProfiling then
return true
elseif B2.AuxiliaryData.bIsDrilling and B1.AuxiliaryData.bIsProfiling then
return false
elseif B1.AuxiliaryData.bIsProfiling and B2.AuxiliaryData.bIsProfiling then
if B1.Proc.b3Box:getCenter():getX() - B2.Proc.b3Box:getCenter():getX() < 10 * GEO.EPS_SMALL then
return EgtIf( B1.AuxiliaryData.nPhase == 1, true, false) -- se arrivati a questo controllo, la fase di lavorazione di entrambe è la stessa, quindi mi basta controllarne una
else
return EgtIf( B1.AuxiliaryData.nPhase == 1, false, true) -- se arrivati a questo controllo, la fase di lavorazione di entrambe è la stessa, quindi mi basta controllarne una
end
elseif B1.AuxiliaryData.bIsDrilling and B2.AuxiliaryData.bIsDrilling then
if B1.Proc.b3Box:getMin():getX() < B2.Proc.b3Box:getMin():getX() then
return true
else
return false
end
else
return false
end
end
-- local vProcToSort = vProc
-- -- funzione di confronto. TRUE = B1 prima di B2. FALSE = B2 prima di B1
-- local function CompareFeatures( B1, B2)
-- -- se secondo disabilitato, va lasciato dopo
-- if B1.nFlg ~= 0 and B2.nFlg == 0 then
-- return true
-- elseif B1.nPhase and B2.nPhase and B1.nPhase < B2.nPhase then
-- return true
-- elseif B1.nPhase and B2.nPhase and B2.nPhase < B1.nPhase then
-- return true
-- -- altrimenti si inverte
-- else
-- return false
-- end
-- end
-- test della funzione di ordinamento
if EgtGetDebugLevel() >= 3 then
EgtOutLog( ' CompareFeatures Test ')
local bCompTest = true
for i = 1, #vProcToSort do
for j = i + 1, #vProcToSort do
local bComp1 = CompareFeatures( vProcToSort[i], vProcToSort[j])
local bComp2 = CompareFeatures( vProcToSort[j], vProcToSort[i])
if bComp1 == bComp2 then
bCompTest = false
EgtOutLog( string.format( ' ProcId : %d vs %d --> ERROR', vProcToSort[i].Proc.id, vProcToSort[j].Proc.id))
end
end
end
if bCompTest then
EgtOutLog( ' ALL OK')
end
end
-- -- test della funzione di ordinamento
-- if EgtGetDebugLevel() >= 3 then
-- EgtOutLog( ' CompareFeatures Test ')
-- local bCompTest = true
-- for i = 1, #vProcToSort do
-- for j = i + 1, #vProcToSort do
-- local bComp1 = CompareFeatures( vProcToSort[i], vProcToSort[j])
-- local bComp2 = CompareFeatures( vProcToSort[j], vProcToSort[i])
-- if bComp1 == bComp2 then
-- bCompTest = false
-- EgtOutLog( string.format( ' ProcId : %d vs %d --> ERROR', vProcToSort[i].id, vProcToSort[j].id))
-- end
-- end
-- end
-- if bCompTest then
-- EgtOutLog( ' ALL OK')
-- end
-- end
-- eseguo un primo ordinamento
table.sort( vProcToSort, CompareFeatures)
-- -- eseguo ordinamento
-- table.sort( vProcToSort, CompareFeatures)
-- ordino per ottimizzare cambio utensile
MACHININGS = SortByChangeToolOpt( MACHININGS)
return true
end
@@ -342,7 +392,7 @@ local function AddMachinings( vProc, PARTS)
local bMachiningOk = true
for nFeatureIndex = 1, #vProc do
local Proc = vProc[nFeatureIndex]
local Part = PARTS[vProc[nFeatureIndex].nIndexPiece]
local Part = PARTS[vProc[nFeatureIndex].nIndexPart]
if ID.IsDrilling( Proc) then
bMachiningOk = Drilling.Make( Proc, Part)
end
@@ -380,6 +430,14 @@ local function PrintFeatures( vProc, PARTS)
end
end
-------------------------------------------------------------------------------------------------------------
local function UpdateRawPosition( PARTS)
for i = 1, #PARTS do
PARTS[i].b3FinishedPart = EgtGetBBoxGlob( PARTS[i].id or GDB_ID.NULL, GDB_BB.STANDARD)
PARTS[i].b3RawPart = EgtGetBBoxGlob( PARTS[i].idRaw or GDB_ID.NULL, GDB_BB.STANDARD)
end
end
-------------------------------------------------------------------------------------------------------------
local function CheckAndMovePawPart( nIdRawToMove, vtMove)
EgtMoveRawPart( nIdRawToMove, vtMove)
@@ -393,11 +451,15 @@ function WinExec.ProcessFeatures( PARTS)
local vProc = {}
MACHININGS = {}
-- aggiorno posizione grezzi dopo disposizione
EgtSetCurrPhase( 1)
UpdateRawPosition( PARTS)
-- si recuperano tutte le feature di tutti i pezzi in una lista unica
for nPart = 1, #PARTS do
-- recupero le feature di lavorazione della trave
vProc = CollectFeatures( vProc, PARTS[nPart])
vProc = CollectFeatures( vProc, PARTS[nPart], nPart)
-- recupero informazioni ausiliarie feature e dipendenze tra feature dello stesso pezzo
vProc = GetFeatureInfoAndDependency( vProc, PARTS[nPart])
end
@@ -415,16 +477,13 @@ function WinExec.ProcessFeatures( PARTS)
-- ordina le lavorazioni
OrderMachining( MACHININGS)
-- scrivo lavorazioni prima fase
EgtSetCurrPhase( 1)
for i = 1, #MACHININGS do
if MACHININGS[i].AuxInfo.nPhase == 1 then
if MACHININGS[i].AuxiliaryData.nPhase == 1 then
-- aggiunge effettivamente la lavorazione e restituisce gli ingombri
local bIsApplyOk, sErr, b3MachEncumbrance = MachiningLib.AddOperation( MACHININGS[i]) -- TODO ingombro lavorazione mi restituisce dati sbagliati. C'è un riferimento?
-- se feature di testa, sposto testa in base a ingombro lavorazione
if MACHININGS[i].Proc.bHeadProfile and b3MachEncumbrance then
local nIndexPart = ID.GetPieceIndexPart( PARTS, MACHININGS[i].Proc.idPart)
PARTS[nIndexPart].DispOffsets.Phase1.dOffsetX = b3MachEncumbrance:getMax():getX() - PARTS[nIndexPart].b3FinishedPart:getMin():getX() + 5
PARTS[MACHININGS[i].Proc.nIndexPart].DispOffsets.Phase1.dOffsetX = b3MachEncumbrance:getMax():getX() - PARTS[MACHININGS[i].Proc.nIndexPart].b3FinishedPart:getMin():getX() + 5
end
end
end
@@ -434,9 +493,8 @@ function WinExec.ProcessFeatures( PARTS)
-- sposto pezzo per permettere pinzaggio migliore e non aver colisione in testa
for i = 1, #PARTS do
-- TODO Sbaglia a calcolare ingombro!!
--local vtMove = Vector3d( - PARTS[nIndexPart].DispOffsets.Phase1.dOffsetX, - PARTS[nIndexPart].DispOffsets.Phase1.dOffsetY, PARTS[nIndexPart].DispOffsets.Phase1.dOffsetZ)
local vtMove = Vector3d( -60, 0, 0)
-- TODO controllare calcolo ingombro
local vtMove = Vector3d( - PARTS[i].DispOffsets.Phase1.dOffsetX, 0, 0)
if vtMove ~= V_NULL() then
CheckAndMovePawPart( PARTS[i].idRaw, vtMove)
end
@@ -444,22 +502,21 @@ function WinExec.ProcessFeatures( PARTS)
-- scrivo lavorazioni seconda fase
EgtSetCurrPhase( 2)
UpdateRawPosition( PARTS)
for i = 1, #MACHININGS do
if MACHININGS[i].AuxInfo.nPhase == 2 then
if MACHININGS[i].AuxiliaryData.nPhase == 2 then
-- aggiunge effettivamente la lavorazione
local bIsApplyOk, sErr, b3MachEncumbrance = MachiningLib.AddOperation( MACHININGS[i]) -- TODO ingombro lavorazione mi restituisce dati sbagliati. C'è un riferimento?
-- se feature di testa, sposto testa in base a ingombro lavorazione
if MACHININGS[i].Proc.bHeadProfile and b3MachEncumbrance then
local nIndexPart = ID.GetPieceIndexPart( PARTS, MACHININGS[i].Proc.idPart)
PARTS[nIndexPart].DispOffsets.Phase1.dOffsetX = PARTS[nIndexPart].b3FinishedPart:getMax():getX() - b3MachEncumbrance:getMin():getX() + 5
PARTS[MACHININGS[i].Proc.nIndexPart].DispOffsets.Phase2.dOffsetX = PARTS[MACHININGS[i].Proc.nIndexPart].b3FinishedPart:getMax():getX() - b3MachEncumbrance:getMin():getX() + 5
end
end
end
-- sposto pezzo per permettere pinzaggio migliore e non aver colisione in testa
for i = 1, #PARTS do
-- TODO Sbaglia a calcolare ingombro!!
-- local vtMove = Vector3d( PARTS[nIndexPart].DispOffsets.Phase2.dOffsetX, PARTS[nIndexPart].DispOffsets.Phase2.dOffsetY, PARTS[nIndexPart].DispOffsets.Phase2.dOffsetZ)
local vtMove = Vector3d( 60, 0, 0)
-- TODO controllare calcolo ingombro
local vtMove = Vector3d( PARTS[i].DispOffsets.Phase2.dOffsetX, 0, 0)
if vtMove ~= V_NULL() then
CheckAndMovePawPart( PARTS[i].idRaw, vtMove)
end
+74 -17
View File
@@ -15,29 +15,86 @@ EgtOutLog( ' WinLib started', 1)
function WinLib.GetAffectedFaces( Proc, Part)
local vtFacesAffected = { bTop = false, bBottom = false, bFront = false, bBack = false, bLeft = false, bRight = false}
if Proc.b3Box and not Proc.b3Box:isEmpty() then
if Proc.b3Box:getMax():getZ() > Part.b3Solid:getMax():getZ() - 500 * GEO.EPS_SMALL then
vtFacesAffected.bTop = true
end
if Proc.b3Box:getMin():getZ() < Part.b3Solid:getMin():getZ() + 500 * GEO.EPS_SMALL then
vtFacesAffected.bBottom = true
end
if Proc.b3Box:getMin():getY() < Part.b3Solid:getMin():getY() + 500 * GEO.EPS_SMALL then
vtFacesAffected.bFront = true
end
if Proc.b3Box:getMax():getY() > Part.b3Solid:getMax():getY() - 500 * GEO.EPS_SMALL then
vtFacesAffected.bBack = true
end
if Proc.b3Box:getMin():getX() < Part.b3Solid:getMin():getX() + 500 * GEO.EPS_SMALL then
vtFacesAffected.bLeft = true
end
if Proc.b3Box:getMax():getX() > Part.b3Solid:getMax():getX() - 500 * GEO.EPS_SMALL then
vtFacesAffected.bRight = true
-- caso speciale foro
if Proc.sType == 'Hole' and Proc.ReferenceSide then
if Proc.ReferenceSide == Part.SideNames.sLeft then
vtFacesAffected.bLeft = true
elseif Proc.ReferenceSide == Part.SideNames.sRight then
vtFacesAffected.bRight = true
elseif Proc.ReferenceSide == Part.SideNames.sFront then
vtFacesAffected.bFront = true
elseif Proc.ReferenceSide == Part.SideNames.sBack then
vtFacesAffected.bBack = true
end
-- caso speciale profilo
elseif Proc.sType == 'Profiling' then
if not Part.SideNames then
Part.SideNames = {}
end
if Proc.b3Box:getMax():getX() < Part.b3FinishedPart:getCenter():getX() then
vtFacesAffected.bLeft = true
Part.SideNames.sLeft = Proc.sEntityName
elseif Proc.b3Box:getMin():getX() > Part.b3FinishedPart:getCenter():getX() then
vtFacesAffected.bRight = true
Part.SideNames.sRight = Proc.sEntityName
elseif Proc.b3Box:getMax():getY() < Part.b3FinishedPart:getCenter():getY() then
vtFacesAffected.bFront = true
Part.SideNames.sFront = Proc.sEntityName
elseif Proc.b3Box:getMin():getY() > Part.b3FinishedPart:getCenter():getY() then
vtFacesAffected.bBack = true
Part.SideNames.sBack = Proc.sEntityName
end
-- caso standard
else
if Proc.b3Box:getMax():getZ() > Part.b3FinishedPart:getMax():getZ() - 500 * GEO.EPS_SMALL then
vtFacesAffected.bTop = true
end
if Proc.b3Box:getMin():getZ() < Part.b3FinishedPart:getMin():getZ() + 500 * GEO.EPS_SMALL then
vtFacesAffected.bBottom = true
end
if Proc.b3Box:getMin():getY() < Part.b3FinishedPart:getMin():getY() + 500 * GEO.EPS_SMALL then
vtFacesAffected.bFront = true
end
if Proc.b3Box:getMax():getY() > Part.b3FinishedPart:getMax():getY() - 500 * GEO.EPS_SMALL then
vtFacesAffected.bBack = true
end
if Proc.b3Box:getMin():getX() < Part.b3FinishedPart:getMin():getX() + 500 * GEO.EPS_SMALL then
vtFacesAffected.bLeft = true
end
if Proc.b3Box:getMax():getX() > Part.b3FinishedPart:getMax():getX() - 500 * GEO.EPS_SMALL then
vtFacesAffected.bRight = true
end
end
end
return vtFacesAffected
end
-------------------------------------------------------------------------------------------------------------
function WinLib.SwapElements( Table, Pos1, Pos2)
Table[Pos1], Table[Pos2] = Table[Pos2], Table[Pos1]
return Table
end
-------------------------------------------------------------------------------------------------------------
function WinLib.ChangeElementPositionInTable( Table, nCurrentPosition, nTargetPosition)
-- se indici uguali esco subito
if nTargetPosition == nCurrentPosition then
return Table
end
local Item = Table[nCurrentPosition]
if nTargetPosition > nCurrentPosition then
nTargetPosition = nTargetPosition - 1
end
table.remove( Table, nCurrentPosition)
table.insert( Table, nTargetPosition, Item)
return Table
end
-------------------------------------------------------------------------------------------------------------
function WinLib.GetAddGroup( PartId)
-- recupero il nome del gruppo di lavoro corrente
+5 -11
View File
@@ -7,7 +7,7 @@
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( true)
EgtEnableDebug( false)
-- TODO da cancellare quando verrà passato automaticamente da programma
local WIN = {}
@@ -107,14 +107,6 @@ local function GetDataConfig()
return true
end
-------------------------------------------------------------------------------------------------------------
local function UpdateRawPosition( PARTS)
for i = 1, #PARTS do
PARTS[i].b3FinishedPart = EgtGetBBoxGlob( PARTS[i].id or GDB_ID.NULL, GDB_BB.STANDARD)
PARTS[i].b3RawPart = EgtGetBBoxGlob( PARTS[i].idRaw or GDB_ID.NULL, GDB_BB.STANDARD)
end
end
-------------------------------------------------------------------------------------------------------------
local function GetDispOffsetFromNotes( nPieceIndex)
local bAllOffsetsAreOk = false
@@ -288,11 +280,13 @@ local function MyProcessPieces()
-- si dispongono i pezzi sulla tavola
WinData.ExecDisposition( PARTS)
UpdateRawPosition( PARTS)
-- Impostazione dell'attrezzaggio di default
-- TODO se lascio il campo vuoto non mi carica il default!!!!!!!
local bOk = EgtImportSetup( 'CIAO')
local bOk = EgtImportSetup()
if not bOk then
EgtImportSetup( 'Default')
end
return true
end
+63
View File
@@ -9,12 +9,75 @@ require( 'EgtBase')
-- Carico i dati globali
local WinData = require( 'WinData')
local MachiningLib = require( 'MachiningLib')
EgtOutLog( ' Drilling started', 1)
EgtMdbSave()
-------------------------------------------------------------------------------------------------------------
-- funzione che decide se eseguire le forature dopo le profilature. Solo forature di testa inclinate. Altrimenti sempre prima.
local function IsDrillToMachineAfterProfile( Proc)
local bExecAfterProfile = false
if ( Proc.AffectedFaces.Left or Proc.AffectedFaces.Right) and abs( Proc.vtDir:getX()) > 0.15 then
bExecAfterProfile = true
end
return bExecAfterProfile
end
-------------------------------------------------------------------------------------------------------------
function Drilling.Make( Proc, Part)
local ToolInfo = {}
local Machining = {}
local AuxiliaryData = {}
Machining.LeadIn = {}
Machining.LeadOut = {}
Machining.Steps = {}
local ToolSearchParameters = {}
-- cerco utensile punta a forare
ToolSearchParameters.dDiameter = Proc.dDiameter
ToolSearchParameters.dLength = Proc.dLength
ToolInfo = MachiningLib.FindDrill( Proc, ToolSearchParameters)
-- se trovato utensile
if ToolInfo.nToolIndex then
Machining.nType = MCH_OY.DRILLING
Machining.nToolIndex = ToolInfo.nToolIndex
Machining.sDepth = 'th'
Machining.Steps.dStep = TOOLS[ToolInfo.nToolIndex].dStep
Machining.Geometry = Proc.id
AuxiliaryData.bExecAfterProfile = IsDrillToMachineAfterProfile( Proc)
AuxiliaryData.bIsDrilling = true
AuxiliaryData.nIndexMachining = 1
AuxiliaryData.nPhase = MachiningLib.GetPhaseMach( Proc)
Machining.dStartSafetyLength = MachiningLib.GetDrillAdditionalSafeDistanceToRaw( Proc, Part, Machining)
MachiningLib.AddNewMachining( Proc, Machining, AuxiliaryData)
else
-- provo a cercare una fresa che faccia una svuotatura
ToolSearchParameters.dMaxToolDiameter = Proc.dDiameter
ToolInfo = MachiningLib.FindDrill( Proc, ToolSearchParameters)
-- se trovato utensile
if ToolInfo.nToolIndex then
Machining.nType = MCH_OY.POCKETING
Machining.nSubType = MCH_POCK_SUB.SPIRALOUT
Machining.LeadIn.nType = MCH_POCK_LI.ZIGZAG
Machining.Steps.dStep = TOOLS[ToolInfo.nToolIndex].dStep
Machining.Steps.dSideStep = TOOLS[ToolInfo.nToolIndex].dSideStep
Machining.nToolIndex = ToolInfo.nToolIndex
Machining.LeadIn.dTangentDistance = TOOLS[ToolInfo.nToolIndex].dDiameter/2
Machining.LeadIn.dElevation = TOOLS[ToolInfo.nToolIndex].dDiameter/2
Machining.sDepth = 0
Machining.Geometry = Proc.id
AuxiliaryData.bIsPocketingDrill = true
AuxiliaryData.nIndexMachining = 1
AuxiliaryData.nPhase = MachiningLib.GetPhaseMach( Proc)
MachiningLib.AddNewMachining( Proc, Machining, AuxiliaryData)
else
return false
end
end
return true
end
+9 -7
View File
@@ -22,7 +22,7 @@ function Profiling.Make( Proc, Part)
if Proc.nToolsToUse then
for i = 1, Proc.nToolsToUse do
local Machining = {}
local AuxInfo = {}
local AuxiliaryData = {}
Machining.LeadIn = {}
Machining.LeadOut = {}
Machining.Steps = {}
@@ -33,20 +33,22 @@ function Profiling.Make( Proc, Part)
-- se trovato utensile
if ToolInfo.nToolIndex then
Machining.nType = MCH_MY.MILLING
Machining.nWorkSide = MCH_MILL_WS.RIGHT
Machining.nWorkside = MCH_MILL_WS.RIGHT
Machining.nToolIndex = ToolInfo.nToolIndex
Machining.sDepth = 0
Machining.dRadialOffset = Proc.Tools[i].dRadialOffset
Machining.dLongitudinalOffset = Proc.Tools[i].dLongitudinalOffset
Machining.LeadIn.nType = MCH_MILL_LI.TANGENT
Machining.LeadIn.dTangentDistance = TOOLS[ToolInfo.nToolIndex].dDiameter
Machining.LeadIn.dPerpDistance = TOOLS[ToolInfo.nToolIndex].dDiameter
Machining.LeadIn.dTangentDistance = (TOOLS[ToolInfo.nToolIndex].dTotDiameter / 2) + 30
Machining.LeadIn.dPerpDistance = (TOOLS[ToolInfo.nToolIndex].dTotDiameter / 2) + 30
Machining.LeadOut.nType = MCH_MILL_LO.TANGENT
Machining.LeadOut.dTangentDistance = TOOLS[ToolInfo.nToolIndex].dDiameter
Machining.LeadOut.dTangentDistance = (TOOLS[ToolInfo.nToolIndex].dTotDiameter / 2) + 30
Machining.LeadOut.dPerpDistance = 0
Machining.Geometry = Proc.id
AuxInfo.nPhase = MachiningLib.GetPhaseMach( Proc)
MachiningLib.AddNewMachining( Proc, Machining, AuxInfo)
AuxiliaryData.bIsProfiling = true
AuxiliaryData.nIndexMachining = i
AuxiliaryData.nPhase = MachiningLib.GetPhaseMach( Proc)
MachiningLib.AddNewMachining( Proc, Machining, AuxiliaryData)
else
return false, 'Tool not found'
end
Binary file not shown.