diff --git a/LuaLibs/ProcessDtTenon.lua b/LuaLibs/ProcessDtTenon.lua index fe14138..8bc0068 100644 --- a/LuaLibs/ProcessDtTenon.lua +++ b/LuaLibs/ProcessDtTenon.lua @@ -352,8 +352,90 @@ function ProcessDtTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) BL.UpdateTCING( nRawId, dOffs) end end + + -- controllo se serve passaggio di finitura in caso il tenone non cominci dal bordo della trave (P14 > 0) + if abs( vtExtr * EgtSurfTmFacetNormVersor( Proc.Id, Proc.Fct-1, GDB_ID.ROOT)) < GEO.EPS_ANG_SMALL then + -- verifico se almeno uno dei punti iniziale e finale della curva giace in uno dei piani limite del pezzo, quindi se รจ un lato aperto + local bOpen = false + local ptIni = EgtSP( AuxId, GDB_RT.GLOB) + local ptFin = EgtEP( AuxId, GDB_RT.GLOB) + if ( abs( ptIni:getX() - b3Solid:getMax():getX()) < 100 * GEO.EPS_SMALL or abs( ptFin:getX() - b3Solid:getMax():getX()) < 100 * GEO.EPS_SMALL) or + ( abs( ptIni:getX() - b3Solid:getMin():getX()) < 100 * GEO.EPS_SMALL or abs( ptFin:getX() - b3Solid:getMin():getX()) < 100 * GEO.EPS_SMALL) or + ( abs( ptIni:getY() - b3Solid:getMax():getY()) < 100 * GEO.EPS_SMALL or abs( ptFin:getY() - b3Solid:getMax():getY()) < 100 * GEO.EPS_SMALL) or + ( abs( ptIni:getY() - b3Solid:getMin():getY()) < 100 * GEO.EPS_SMALL or abs( ptFin:getY() - b3Solid:getMin():getY()) < 100 * GEO.EPS_SMALL) or + ( abs( ptIni:getZ() - b3Solid:getMax():getZ()) < 100 * GEO.EPS_SMALL or abs( ptFin:getZ() - b3Solid:getMax():getZ()) < 100 * GEO.EPS_SMALL) or + ( abs( ptIni:getZ() - b3Solid:getMin():getZ()) < 100 * GEO.EPS_SMALL or abs( ptFin:getZ() - b3Solid:getMin():getZ()) < 100 * GEO.EPS_SMALL) then + bOpen = true + end + -- se entrambi i punti non sono sul limite pezzo + if not bOpen then + -- recupero la lavorazione + sMillType = 'Tenon' + sMilling = ML.FindMilling( sMillType .. EgtIf( bMillDown and not bMillUp, '_H2', ''), nil, nil, nil, nil, bMillUp, bMillDown) + if not sMilling then + local sErr = 'Error : milling to finish the tenon not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati dell'utensile + if EgtMdbSetCurrMachining( sMilling) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam + dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat + local dSpeed = EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) or 0 + bCW = ( dSpeed >= 0) + end + + -- inserisco la passata finale della lavorazione + local sNameF = 'TenF_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchFId = EgtAddMachining( sNameF, sMilling) + if not nMchFId then + local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ Proc.Id, Proc.Fct-1}}) + -- sistemo i parametri + EgtSetMachiningParam( MCH_MP.DEPTH_STR, 'TH') + -- sistemo il lato e la direzione di lavoro + EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( bCW, MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT)) + EgtSetMachiningParam( MCH_MP.INVERT, EgtIf( bCW, true, false)) + EgtSetMachiningParam( MCH_MP.LITANG, 0.7 * dTDiam) + EgtSetMachiningParam( MCH_MP.LIPERP, 20) + EgtSetMachiningParam( MCH_MP.LOTANG, 0.7 * dTDiam) + EgtSetMachiningParam( MCH_MP.LOPERP, 20) + + local nOrthoOpposite = BL.GetNearestParalOpposite( vtExtr, vtExtr) + -- imposto utilizzo faccia + EgtSetMachiningParam( MCH_MP.FACEUSE, nOrthoOpposite) + + -- imposto elevazione + local sUserNotes = EgtSetVal( 'MaxElev', EgtNumToString( dDtTenH, 1)) .. ';' + EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) + + -- imposto posizione braccio porta testa + local nSCC = MCH_SCC.NONE + if BD.TURN then + if abs( vtAx:getY()) > abs( vtAx:getZ()) then + nSCC = EgtIf( vtAx:getY() > 0, MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) + else + nSCC = EgtIf( vtAx:getZ() > 0, MCH_SCC.ADIR_ZP, MCH_SCC.ADIR_ZM) + end + elseif not BD.C_SIMM then + nSCC = MCH_SCC.ADIR_YM + if abs( vtExtr:getY()) > 0.088 then + nSCC = EgtIf( vtExtr:getX() < GEO.EPS_SMALL, MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) + end + end + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + end + end + end + return true -end +end --------------------------------------------------------------------- return ProcessDtTenon