DataBeam :
- correzioni varie.
This commit is contained in:
+204
-106
@@ -1,4 +1,4 @@
|
||||
-- ProcessLapJoint.lua by Egaltech s.r.l. 2020/06/19
|
||||
-- ProcessLapJoint.lua by Egaltech s.r.l. 2020/07/23
|
||||
-- Gestione calcolo mezzo-legno per Travi
|
||||
-- 2019/10/08 Agg. gestione OpenPocket.
|
||||
|
||||
@@ -295,14 +295,14 @@ local function GetTunnelDimension( Proc, nPartId)
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- mi assicuro che la Z del punto utilizzato per creare la superfic sia alla Z media del bounding box locale
|
||||
-- mi assicuro che la Z del punto utilizzato per creare la superficie sia alla Z media del bounding box locale
|
||||
local ptN2 = Point3d(ptN1)
|
||||
ptN2:toLoc(frFc)
|
||||
ptN2 = Point3d( ptN2:getX(), ptN2:getY(), ( bBoxLoc:getMin():getZ() + bBoxLoc:getMax():getZ())/2)
|
||||
ptN2:toGlob(frFc)
|
||||
-- creeo superfice intermedia
|
||||
-- creo superficie intermedia
|
||||
local nSurfInt = EgtSurfTmPlaneInBBox( nAddGrpId, ptN2, vtOrtho, b3Solid, GDB_ID.ROOT)
|
||||
-- ritaglio la superfici con le facce della fessura
|
||||
-- ritaglio la superficie con le facce della fessura
|
||||
for i = 1, nFacCnt do
|
||||
local ptN, vtN = EgtSurfTmFacetCenter( Proc.Id, i - 1, GDB_ID.ROOT)
|
||||
EgtCutSurfTmPlane( nSurfInt, ptN, -vtN, false, GDB_ID.ROOT)
|
||||
@@ -1722,14 +1722,17 @@ local function MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw)
|
||||
end
|
||||
-- recupero i dati dell'utensile
|
||||
local dSawDiam = 400
|
||||
local dSawThick = 0
|
||||
if EgtMdbSetCurrMachining( sCutting) then
|
||||
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
||||
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
|
||||
dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam
|
||||
dSawThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dSawThick
|
||||
end
|
||||
end
|
||||
-- eseguo il taglio
|
||||
return BL.MakeOneFaceBySaw( Proc.Id, nFacet, sCutting, dSawDiam, vtN, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw)
|
||||
local bMadeASbyBld, sWarn, nIdMach = BL.MakeOneFaceBySaw( Proc.Id, nFacet, sCutting, dSawDiam, vtN, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw)
|
||||
return bMadeASbyBld, sWarn, nIdMach, dSawThick
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
@@ -2420,6 +2423,113 @@ local function CheckDiamToolByFaces( Proc, nFacInd, dH, dV, bIsU, bIsL, dElev)
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function MakeChamfer( Proc, b3FacesUsed, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham)
|
||||
|
||||
-- recupero la lavorazione
|
||||
local sMilling = ML.FindMilling( 'Mark')
|
||||
if not sMilling then
|
||||
local sErr = 'Error : chamfer not found in library'
|
||||
EgtOutLog( sErr)
|
||||
return -1, sErr
|
||||
end
|
||||
-- ottengo le curve di contorno libero
|
||||
local nAuxId1, nAuxId2, nNumIdAux
|
||||
if b3FacesUsed then
|
||||
-- nAuxId1, _ = EgtExtractSurfTmLoops( nSurfInt, nAddGrpId)
|
||||
-- EgtModifyCurveExtrusion( nAuxId1, vtOrtho, GDB_RT.GLOB)
|
||||
-- SetOpenSide( nAuxId1, vtOrtho, b3Solid, nAddGrpId, true)
|
||||
-- nNumIdAux = 2
|
||||
|
||||
-- estraggo i percorsi
|
||||
nAuxId1, nNumIdAux = EgtExtractSurfTmLoops( Proc.Id, nAddGrpId)
|
||||
-- se percorso creato estraggo solo i percorsi delle facce interessate, non di testa
|
||||
if nAuxId1 then
|
||||
nAuxId1, nNumIdAux, nAuxId2 = ExtractExternalPaths( nAuxId1, nNumIdAux, vtOrtho, b3Solid, nAddGrpId)
|
||||
end
|
||||
else
|
||||
nAuxId1, nNumIdAux = EgtExtractSurfTmLoops( Proc.Id, nAddGrpId)
|
||||
if not nNumIdAux then nNumIdAux = 0 end
|
||||
end
|
||||
|
||||
local dExtra = 2
|
||||
for i = 1, nNumIdAux do
|
||||
local AuxId
|
||||
local vtExtr
|
||||
if b3FacesUsed then
|
||||
if i == 1 then
|
||||
AuxId = nAuxId1
|
||||
else
|
||||
-- faccio la copia del percorso
|
||||
-- AuxId = EgtCopyGlob( nAuxId1, nAddGrpId)
|
||||
AuxId = nAuxId2
|
||||
end
|
||||
if AuxId then
|
||||
vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
|
||||
end
|
||||
else
|
||||
AuxId = nAuxId1 + i - 1
|
||||
vtExtr, _, _ = EgtCurveArea( AuxId)
|
||||
end
|
||||
if vtExtr then
|
||||
if not b3FacesUsed then
|
||||
local fFrCurve = EgtGetGlobFrame( AuxId)
|
||||
vtExtr:toGlob( fFrCurve)
|
||||
end
|
||||
-- if b3FacesUsed and i == nNumIdAux then
|
||||
-- vtExtr = -vtExtr
|
||||
-- end
|
||||
-- Se normale entro certi limiti
|
||||
-- if vtExtr:getZ() > -0.707 and ( abs(vtOrtho:getX()) > 0.99 or abs(vtOrtho:getY()) > 0.99 or abs(vtOrtho:getZ()) > 0.99) then
|
||||
if vtExtr:getZ() > -0.707 and ( abs(vtExtr:getX()) > 0.99 or abs(vtExtr:getY()) > 0.99 or abs(vtExtr:getZ()) > 0.99) then
|
||||
-- inserisco la lavorazione
|
||||
local sNameCh = 'Cham_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( i)
|
||||
local nMchId = EgtAddMachining( sNameCh, sMilling)
|
||||
if not nMchId then
|
||||
local sErr = 'Error adding machining ' .. sNameCh .. '-' .. sMilling
|
||||
EgtOutLog( sErr)
|
||||
return -1, sErr
|
||||
end
|
||||
-- modifico estrusione percorso
|
||||
EgtModifyCurveExtrusion( AuxId, vtExtr, GDB_RT.GLOB)
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ AuxId, -1}})
|
||||
-- imposto posizione braccio porta testa
|
||||
if vtExtr:getY() < GEO.EPS_SMALL then
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
|
||||
end
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
||||
-- assegno affondamento e offset radiale
|
||||
-- EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra - EgtIf( b3FacesUsed, (dDepth / 2), 0))
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra)
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, dExtra)
|
||||
-- se opero su 3 facce e sono al secondo e ultimo percorso inverto la lavorazione
|
||||
-- if b3FacesUsed and i == nNumIdAux then
|
||||
-- EgtSetMachiningParam( MCH_MP.INVERT, true)
|
||||
-- end
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchId, false)
|
||||
return -1, sErr
|
||||
end
|
||||
-- se non perpendicolare emetto un warning
|
||||
-- else
|
||||
-- sWarn = 'Warning : chamfer skipped because not perpendicular to face or from bottom'
|
||||
-- EgtOutLog( sWarn)
|
||||
end
|
||||
--emetto un warning
|
||||
-- else
|
||||
-- sWarn = 'Warning : chamfer skipped because not perpendicular to face'
|
||||
-- EgtOutLog( sWarn)
|
||||
end
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMchFindMaster, b3FacesUsed, b3Solid, bOrthoFacesMaster)
|
||||
|
||||
@@ -2453,105 +2563,8 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha
|
||||
-- verifico la direzione
|
||||
-- se devo inserire il chamfer
|
||||
if nChamfer > 0 then
|
||||
-- recupero la lavorazione
|
||||
local sMilling = ML.FindMilling( 'Mark')
|
||||
if not sMilling then
|
||||
local sErr = 'Error : chamfer not found in library'
|
||||
EgtOutLog( sErr)
|
||||
return -1, sErr
|
||||
end
|
||||
-- ottengo le curve di contorno libero
|
||||
local nAuxId1, nAuxId2, nNumIdAux
|
||||
if b3FacesUsed then
|
||||
-- nAuxId1, _ = EgtExtractSurfTmLoops( nSurfInt, nAddGrpId)
|
||||
-- EgtModifyCurveExtrusion( nAuxId1, vtOrtho, GDB_RT.GLOB)
|
||||
-- SetOpenSide( nAuxId1, vtOrtho, b3Solid, nAddGrpId, true)
|
||||
-- nNumIdAux = 2
|
||||
|
||||
-- estraggo i percorsi
|
||||
nAuxId1, nNumIdAux = EgtExtractSurfTmLoops( Proc.Id, nAddGrpId)
|
||||
-- se percorso creato estraggo solo i percorsi delle facce interessate, non di testa
|
||||
if nAuxId1 then
|
||||
nAuxId1, nNumIdAux, nAuxId2 = ExtractExternalPaths( nAuxId1, nNumIdAux, vtOrtho, b3Solid, nAddGrpId)
|
||||
end
|
||||
else
|
||||
nAuxId1, nNumIdAux = EgtExtractSurfTmLoops( Proc.Id, nAddGrpId)
|
||||
if not nNumIdAux then nNumIdAux = 0 end
|
||||
end
|
||||
local dExtra = 2
|
||||
for i = 1, nNumIdAux do
|
||||
local AuxId
|
||||
local vtExtr
|
||||
if b3FacesUsed then
|
||||
if i == 1 then
|
||||
AuxId = nAuxId1
|
||||
else
|
||||
-- faccio la copia del percorso
|
||||
-- AuxId = EgtCopyGlob( nAuxId1, nAddGrpId)
|
||||
AuxId = nAuxId2
|
||||
end
|
||||
if AuxId then
|
||||
vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
|
||||
end
|
||||
else
|
||||
AuxId = nAuxId1 + i - 1
|
||||
vtExtr, _, _ = EgtCurveArea( AuxId)
|
||||
end
|
||||
if vtExtr then
|
||||
if not b3FacesUsed then
|
||||
local fFrCurve = EgtGetGlobFrame( AuxId)
|
||||
vtExtr:toGlob( fFrCurve)
|
||||
end
|
||||
-- if b3FacesUsed and i == nNumIdAux then
|
||||
-- vtExtr = -vtExtr
|
||||
-- end
|
||||
-- Se normale entro certi limiti
|
||||
-- if vtExtr:getZ() > -0.707 and ( abs(vtOrtho:getX()) > 0.99 or abs(vtOrtho:getY()) > 0.99 or abs(vtOrtho:getZ()) > 0.99) then
|
||||
if vtExtr:getZ() > -0.707 and ( abs(vtExtr:getX()) > 0.99 or abs(vtExtr:getY()) > 0.99 or abs(vtExtr:getZ()) > 0.99) then
|
||||
-- inserisco la lavorazione
|
||||
local sNameCh = 'Cham_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( i)
|
||||
local nMchId = EgtAddMachining( sNameCh, sMilling)
|
||||
if not nMchId then
|
||||
local sErr = 'Error adding machining ' .. sNameCh .. '-' .. sMilling
|
||||
EgtOutLog( sErr)
|
||||
return -1, sErr
|
||||
end
|
||||
-- modifico estrusione percorso
|
||||
EgtModifyCurveExtrusion( AuxId, vtExtr, GDB_RT.GLOB)
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ AuxId, -1}})
|
||||
-- imposto posizione braccio porta testa
|
||||
if vtExtr:getY() < GEO.EPS_SMALL then
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
|
||||
end
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
||||
-- assegno affondamento e offset radiale
|
||||
-- EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra - EgtIf( b3FacesUsed, (dDepth / 2), 0))
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra)
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, dExtra)
|
||||
-- se opero su 3 facce e sono al secondo e ultimo percorso inverto la lavorazione
|
||||
-- if b3FacesUsed and i == nNumIdAux then
|
||||
-- EgtSetMachiningParam( MCH_MP.INVERT, true)
|
||||
-- end
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchId, false)
|
||||
return -1, sErr
|
||||
end
|
||||
-- se non perpendicolare emetto un warning
|
||||
-- else
|
||||
-- sWarn = 'Warning : chamfer skipped because not perpendicular to face or from bottom'
|
||||
-- EgtOutLog( sWarn)
|
||||
end
|
||||
--emetto un warning
|
||||
-- else
|
||||
-- sWarn = 'Warning : chamfer skipped because not perpendicular to face'
|
||||
-- EgtOutLog( sWarn)
|
||||
end
|
||||
end
|
||||
local nOk, sErr = MakeChamfer( Proc, b3FacesUsed, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham)
|
||||
if nOk < 0 then return -1, sErr end
|
||||
end
|
||||
-- se smusso non è esclusivo
|
||||
if nChamfer < 2 then
|
||||
@@ -3120,6 +3133,14 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSinglePart)
|
||||
return bOk, sWarn
|
||||
end
|
||||
end
|
||||
else
|
||||
-- se devo inserire il chamfer
|
||||
if ( ( Proc.Fct == 3 and bIsU) or (Proc.Fct == 2 and bIsL)) and nChamfer > 0 then
|
||||
-- ottengo le dimensioni dello pseudotunnel
|
||||
local _, _, _, vtOrtho, _, nSurfInt = GetTunnelDimension( Proc, nPartId)
|
||||
local nOk, sErr = MakeChamfer( Proc, true, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham)
|
||||
if nOk < 0 then return -1, sErr end
|
||||
end
|
||||
end
|
||||
-- se richiesti antischeggia con lama su U trasversale e smusso non esclusivo
|
||||
-- rimane da gestire: se da eseguire con fresa o se richiesto lama ma impossibile utilizzarla, si utilizza fresa
|
||||
@@ -3127,11 +3148,63 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSinglePart)
|
||||
if nChamfer < 2 and EgtGetInfo( Proc.Id, sAntisplintMode, 'i') == 1 and ( bIsU or bIsL) and
|
||||
( Proc.Box:getDimY() > b3Raw:getDimY() - 1 or Proc.Box:getDimZ() > b3Raw:getDimZ() - 1) then
|
||||
local nNumFac = EgtIf( bIsU, 2, 1)
|
||||
local nPrefSide = 1 -- di preferenza il motore è meglio tenerlo sinistra
|
||||
-- se a U cerco di ottimizzare il lato di lavoro della lama
|
||||
if bIsU then
|
||||
if abs(vtN:getZ()) > 0.7 or abs(vtN:getY()) > 0.7 then
|
||||
-- se X è negativa allora devo tenere il motore a destra
|
||||
if vtN:getX() < -(10 * GEO.EPS_SMALL) then
|
||||
nPrefSide = 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- va eseguito sulle facce diverse dalla principale
|
||||
for nFacet = 0, nNumFac do
|
||||
if nFacet ~= nFacInd then
|
||||
bMadeASbyBld, sWarn = MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw)
|
||||
local bInvertMach
|
||||
if bIsU then
|
||||
if abs(vtN:getZ()) > 0.7 or abs(vtN:getY()) > 0.7 then
|
||||
-- prendo il vettore normale alla faccia
|
||||
local _, vtNFc = EgtSurfTmFacetCenter( Proc.Id, nFacet, GDB_ID.ROOT)
|
||||
-- valuto l'angolo tra le due facce
|
||||
local bAdj, _, _, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacInd, nFacet, GDB_ID.ROOT)
|
||||
-- se posizione ancora da definire perchè la superficie principale è parallela al piano XY o XZ
|
||||
if vtNFc:getX() > 0 and nPrefSide == 1 then
|
||||
-- se angolo interno e <= 90
|
||||
if dAng < -90 + 20 * GEO.EPS_ANG_SMALL then
|
||||
bInvertMach = true
|
||||
end
|
||||
elseif vtNFc:getX() < 0 and nPrefSide == 2 then
|
||||
-- se angolo interno e <= 90
|
||||
if dAng < -90 + 20 * GEO.EPS_ANG_SMALL then
|
||||
bInvertMach = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- debug
|
||||
-- bInvertMach = false
|
||||
local dSawThick = 0
|
||||
bMadeASbyBld, sWarn, nIdMach, dSawThick = MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw)
|
||||
if not bMadeASbyBld then return false, sWarn end
|
||||
if bInvertMach then
|
||||
local bInvert = EgtGetMachiningParam( MCH_MP.INVERT)
|
||||
-- local nWorkSide = EgtGetMachiningParam( MCH_MP.WORKSIDE)
|
||||
local bToolInvert = EgtGetMachiningParam( MCH_MP.TOOLINVERT)
|
||||
-- inverto i parametri
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, not bInvert)
|
||||
-- EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( nWorkSide == MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT))
|
||||
EgtSetMachiningParam( MCH_MP.TOOLINVERT, not bToolInvert)
|
||||
-- setto l'offset pari allo spessore lama
|
||||
EgtSetMachiningParam( MCH_MP.OFFSL, -dSawThick)
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nIdMach, false)
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -3255,7 +3328,7 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
-- in base al tipo di feature attribuisco il significato dei parametri Q
|
||||
AssignQValues( Proc)
|
||||
-- verifico forzatura lama
|
||||
local bForcedBlade = EgtGetInfo( Proc.Id, sUseRoughTool, 'i') ~= 1
|
||||
local bForcedBlade = EgtGetInfo( Proc.Id, sUseRoughTool, 'i') ~= 1 and EgtGetInfo( Proc.Id, sUseMill, 'i') ~= 1
|
||||
-- se lunghezza richiede spezzatura
|
||||
if Proc.Box:getDimX() > BD.LONGCUT_MAXLEN then
|
||||
-- una faccia
|
||||
@@ -3311,6 +3384,31 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
end
|
||||
-- altrimenti, con lama
|
||||
else
|
||||
-- verifico se devo fare prima gli amussi
|
||||
-- recupero gruppo per geometria addizionale
|
||||
local nAddGrpId = BL.GetAddGroup( nPartId)
|
||||
if not nAddGrpId then
|
||||
local sErr = 'Error : missing AddGroup'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- recupero l'ingombro della trave
|
||||
local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD)
|
||||
if not b3Solid then
|
||||
local sErr = 'Error : part box not found'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- verifico se due facce o L con una o due facce di terminazione
|
||||
local bIsL = ( Proc.Fct == 2 or TestElleShape3( Proc) or TestElleShape4( Proc) == 2)
|
||||
-- verifico se sono presenti i parametri Q per la profondità smusso e
|
||||
-- per eseguire in esclusiva solo lo smusso
|
||||
local nChamfer, dDepthCham, sErrCham = EvaluateQParam( Proc, false, sDepthChamferMill, sPreemptiveChamfer, sForceUseBlade)
|
||||
if (Proc.Fct == 2 and bIsL) and nChamfer > 0 then
|
||||
local _, _, _, vtOrtho, _, nSurfInt = GetTunnelDimension( Proc, nPartId)
|
||||
local nOk, sErr = MakeChamfer( Proc, true, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham)
|
||||
if nOk < 0 then return false, sErr end
|
||||
end
|
||||
return Fbs.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, 'HeadSide')
|
||||
end
|
||||
-- tre o più facce
|
||||
|
||||
Reference in New Issue
Block a user