diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index 03811b7..406cf31 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -647,11 +647,13 @@ if bToProcess then PARTS[i].NotClampableLength = { STD = { dHead = 0, dTail = 0}, SIDE = { dHead = 0, dTail = 0}, DOWN = { dHead = 0, dTail = 0}} PARTS[i].sBTLInfo = EgtGetInfo( PARTS[i].id, 'PROJ', 's') or nil PARTS[i].idTempGroup = idTempGroup + PARTS[i].RestrictedLength = ( BeamData.GetRestrictedLength and BeamData.GetRestrictedLength( PARTS[i].dRawWidth, PARTS[i].dRawHeight, PARTS[i].dRawLength)) + or BeamData.LEN_VERY_SHORT_PART + or 400 PARTS[i].sAISetupConfig = EgtGetInfo( PARTS[i].id, 'AISETUP', 's') or ( GENERAL_PARAMETERS.BTL[PARTS[i].sBTLInfo] and GENERAL_PARAMETERS.BTL[PARTS[i].sBTLInfo].sAISetupConfig) or -- i parametri BTL potrebbero non esistere GENERAL_PARAMETERS.PROJECT.sAISetupConfig or nil - -- si carica configurazione lavorazioni TIMER:startElapsed('Json') BeamExec.GetStrategiesFromJSONinBD( PARTS[i].sAISetupConfig) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 0e25610..53744b6 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -398,42 +398,42 @@ end ------------------------------------------------------------------------------------------------------------- -- *** Funzioni posizionamento pezzi all'interno della barra*** ------------------------------------------------------------------------------------------------------------- -function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS, bCreateMachGroup, bIsFlipRot ) +function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS, bCreateMachGroup, bIsFlipRot) -- 1. Inizializzazione e Default - local idTempGroup = BeamLib.GetTempGroup( ) + local idTempGroup = BeamLib.GetTempGroup() local dMinLengthToCreateRaw = 10 - BeamData.OVM_BLADE_HBEAM = ( BeamData.OVM_BLADE_HBEAM or 11 ) - BeamData.OVM_CHAIN_HBEAM = ( BeamData.OVM_CHAIN_HBEAM or 8 ) + BeamData.OVM_BLADE_HBEAM = ( BeamData.OVM_BLADE_HBEAM or 11) + BeamData.OVM_CHAIN_HBEAM = ( BeamData.OVM_CHAIN_HBEAM or 8) - dOvmMid = ( dOvmMid or 5.4 ) - dOvmHead = ( dOvmHead or 0 ) - BeamExec.CalcMinUnloadableRaw( dRawW, dRawH ) + dOvmMid = ( dOvmMid or 5.4) + dOvmHead = ( dOvmHead or 0) + BeamExec.CalcMinUnloadableRaw( dRawW, dRawH) -- 2. Gestione Gruppo di Lavoro - if ( bCreateMachGroup == nil ) then bCreateMachGroup = true end - if ( bCreateMachGroup ) then - local sMgName = EgtGetMachGroupNewName( 'Mach_1' ) - local idNewMg = EgtAddMachGroup( sMgName ) - if ( not idNewMg ) then + if ( bCreateMachGroup == nil) then bCreateMachGroup = true end + if ( bCreateMachGroup) then + local sMgName = EgtGetMachGroupNewName( 'Mach_1') + local idNewMg = EgtAddMachGroup( sMgName) + if ( not idNewMg) then return false, 'Errore creazione gruppo di lavoro' end end -- 3. Configurazione Tavola Macchina - EgtSetTable( 'Tab' ) - local nMGrpId = EgtGetCurrMachGroup( ) - if ( not EgtGetInfo( nMGrpId, 'BARLEN', 'd' ) ) then - EgtSetInfo( nMGrpId, 'BARLEN', dRawL ) + EgtSetTable( 'Tab') + local nMGrpId = EgtGetCurrMachGroup() + if ( not EgtGetInfo( nMGrpId, 'BARLEN', 'd')) then + EgtSetInfo( nMGrpId, 'BARLEN', dRawL) end - local b3Tab = EgtGetTableArea( ) - local dPosY = EgtIf( BeamData.CENTER_BEAM, ( b3Tab:getDimY( ) + dRawW * EgtIf( BeamData.RIGHT_LOAD, -1, 1 ) ) / 2, EgtIf( BeamData.RIGHT_LOAD, 0, b3Tab:getDimY( ) ) ) + local b3Tab = EgtGetTableArea() + local dPosY = EgtIf( BeamData.CENTER_BEAM, ( b3Tab:getDimY() + dRawW * EgtIf( BeamData.RIGHT_LOAD, -1, 1)) / 2, EgtIf( BeamData.RIGHT_LOAD, 0, b3Tab:getDimY())) - BeamData.ptOriXR = Point3d( b3Tab:getDimX( ), dPosY, 0 ) - BeamData.dPosXR = EgtIf( BeamData.RIGHT_LOAD, MCH_CR.BR, MCH_CR.TR ) + BeamData.ptOriXR = Point3d( b3Tab:getDimX(), dPosY, 0) + BeamData.dPosXR = EgtIf( BeamData.RIGHT_LOAD, MCH_CR.BR, MCH_CR.TR) - EgtImportSetup( ) + EgtImportSetup() -- 4. Ciclo di Inserimento Pezzi local nCnt = 0 @@ -443,20 +443,20 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS, b for i = 1, #PARTS do local CurrentPart = PARTS[i] - local b3BoxExact = EgtGetBBoxGlob( CurrentPart.id or GDB_ID.NULL, GDB_BB.EXACT ) + local b3BoxExact = EgtGetBBoxGlob( CurrentPart.id or GDB_ID.NULL, GDB_BB.EXACT) - if ( b3BoxExact:isEmpty( ) or CurrentPart.b3PartOriginal:isEmpty( ) ) then break end + if ( b3BoxExact:isEmpty() or CurrentPart.b3PartOriginal:isEmpty()) then break end - local dPartLen = CurrentPart.b3PartOriginal:getDimX( ) - local dPartWidth = CurrentPart.b3PartOriginal:getDimY( ) - local dPartHeight = CurrentPart.b3PartOriginal:getDimZ( ) + local dPartLen = CurrentPart.b3PartOriginal:getDimX() + local dPartWidth = CurrentPart.b3PartOriginal:getDimY() + local dPartHeight = CurrentPart.b3PartOriginal:getDimZ() -- Se il pezzo corrente non ha coordinata, si calcola da OvmMid if ( not CurrentPart.dPosX) then if ( i == 1) then CurrentPart.dPosX = dOvmHead else - CurrentPart.dPosX = PARTS[i - 1].dPosX + PARTS[i - 1].b3PartOriginal:getDimX( ) + dOvmMid + CurrentPart.dPosX = PARTS[i - 1].dPosX + PARTS[i - 1].b3PartOriginal:getDimX() + dOvmMid end end @@ -469,8 +469,8 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS, b local dEndOffset = dOvmMid -- se ultimo pezzo bisogna allungare il grezzo del restante solo se non viene creato un grezzo indipendente - if ( i == #PARTS ) then - local dPotentialRemaining = max( 0, dRawL - ( CurrentPart.dPosX + dPartLen )) + if ( i == #PARTS) then + local dPotentialRemaining = max( 0, dRawL - ( CurrentPart.dPosX + dPartLen)) if ( dPotentialRemaining > dMinLengthToCreateRaw - GEO.EPS_SMALL) then dEndOffset = 0 -- Coda a zero, il resto diventerà un idRawRest indipendente else @@ -479,9 +479,9 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS, b end -- Gap reale tra i pezzi (può essere negativo in caso di compenetrazione nesting obliqui) - if ( i < #PARTS ) then + if ( i < #PARTS) then local dTotalGap = PARTS[i + 1].dPosX - CurrentPart.dPosX - dPartLen - if ( dTotalGap > dOvmMid ) then + if ( dTotalGap > dOvmMid) then dEndOffset = dOvmMid dNextStartOffset = dTotalGap - dOvmMid else @@ -495,102 +495,105 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS, b local dDelta = dEndOffset local dStartPos = CurrentPart.dPosX - dStartOffset - local bIsSectionOk = ( ( abs( dPartWidth - dRawW ) < 100 * GEO.EPS_SMALL and abs( dPartHeight - dRawH ) < 100 * GEO.EPS_SMALL ) or - ( abs( dPartHeight - dRawW ) < 100 * GEO.EPS_SMALL and abs( dPartWidth - dRawH ) < 100 * GEO.EPS_SMALL ) ) + local bIsSectionOk = ( ( abs( dPartWidth - dRawW) < 100 * GEO.EPS_SMALL and abs( dPartHeight - dRawH) < 100 * GEO.EPS_SMALL) or + ( abs( dPartHeight - dRawW) < 100 * GEO.EPS_SMALL and abs( dPartWidth - dRawH) < 100 * GEO.EPS_SMALL)) - if ( bIsSectionOk and ( dStartPos + dCurrentRawLen <= dRawL + GEO.EPS_SMALL ) ) then + if ( bIsSectionOk and ( dStartPos + dCurrentRawLen <= dRawL + GEO.EPS_SMALL)) then -- 5. Creazione e Posizionamento del Contenitore RawPart - CurrentPart.idRaw = EgtAddRawPart( Point3d( 0, 0, 0 ), dCurrentRawLen, dRawW, dRawH, BeamData.RAWCOL ) - EgtMoveToCornerRawPart( CurrentPart.idRaw, BeamData.ptOriXR, BeamData.dPosXR ) - EgtMoveRawPart( CurrentPart.idRaw, Vector3d( -dStartPos, 0, 0 ) ) + CurrentPart.idRaw = EgtAddRawPart( Point3d( 0, 0, 0), dCurrentRawLen, dRawW, dRawH, BeamData.RAWCOL) + EgtMoveToCornerRawPart( CurrentPart.idRaw, BeamData.ptOriXR, BeamData.dPosXR) + EgtMoveRawPart( CurrentPart.idRaw, Vector3d( -dStartPos, 0, 0)) -- 6. Configurazione Geometrie Pezzo nCnt = nCnt + 1 - EgtSetInfo( CurrentPart.idRaw, 'ORD', nCnt ) + EgtSetInfo( CurrentPart.idRaw, 'ORD', nCnt) - if ( not BeamLib.CreateOrEmptyAddGroup( CurrentPart.id ) ) then - return false, 'Error creating Additional Group in Part ' .. tostring( CurrentPart.id ) + if ( not BeamLib.CreateOrEmptyAddGroup( CurrentPart.id)) then + return false, 'Error creating Additional Group in Part ' .. tostring( CurrentPart.id) end - BeamLib.AddPartStartFace( CurrentPart.id, CurrentPart.b3PartOriginal ) - BeamLib.AddPartEndFace( CurrentPart.id, CurrentPart.b3PartOriginal ) + BeamLib.AddPartStartFace( CurrentPart.id, CurrentPart.b3PartOriginal) + BeamLib.AddPartEndFace( CurrentPart.id, CurrentPart.b3PartOriginal) -- Inserimento con dDelta (lascia lo spazio vuoto a sinistra e spinge il pezzo a destra) - EgtDeselectPartObjs( CurrentPart.id ) - local ptPos = b3BoxExact:getMin( ) - CurrentPart.b3PartOriginal:getMin( ) + Vector3d( dDelta, ( dRawW - dPartWidth ) / 2, ( dRawH - dPartHeight ) / 2 ) - EgtAddPartToRawPart( CurrentPart.id, ptPos, CurrentPart.idRaw ) + EgtDeselectPartObjs( CurrentPart.id) + local ptPos = b3BoxExact:getMin() - CurrentPart.b3PartOriginal:getMin() + Vector3d( dDelta, ( dRawW - dPartWidth) / 2, ( dRawH - dPartHeight) / 2) + EgtAddPartToRawPart( CurrentPart.id, ptPos, CurrentPart.idRaw) -- Rotazione sezione se necessaria - if ( abs( dPartWidth - dRawW ) > 100 * GEO.EPS_SMALL ) then - EgtRotatePartInRawPart( CurrentPart.id, X_AX( ), 90 ) - local vtEccOri = CurrentPart.b3PartOriginal:getCenter( ) - b3BoxExact:getCenter( ) - local vtEccRot = Vector3d( vtEccOri ) - vtEccRot:rotate( X_AX( ), 90 ) - EgtMovePartInRawPart( CurrentPart.id, ( vtEccOri - vtEccRot ) ) + if ( abs( dPartWidth - dRawW) > 100 * GEO.EPS_SMALL) then + EgtRotatePartInRawPart( CurrentPart.id, X_AX(), 90) + local vtEccOri = CurrentPart.b3PartOriginal:getCenter() - b3BoxExact:getCenter() + local vtEccRot = Vector3d( vtEccOri) + vtEccRot:rotate( X_AX(), 90) + EgtMovePartInRawPart( CurrentPart.id, ( vtEccOri - vtEccRot)) end -- 7. Popolamento Metadati della Tabella CurrentPart - CurrentPart.bIsLastPart = ( i == #PARTS ) + CurrentPart.bIsLastPart = ( i == #PARTS) CurrentPart.dDistanceToNextPiece = dEndOffset - CurrentPart.b3Raw = EgtGetRawPartBBox( CurrentPart.idRaw ) - CurrentPart.dLength = CurrentPart.b3Raw:getDimX( ) - CurrentPart.dWidth = CurrentPart.b3Raw:getDimY( ) - CurrentPart.dHeight = CurrentPart.b3Raw:getDimZ( ) - CurrentPart.bSquareSection = abs( CurrentPart.dWidth - CurrentPart.dHeight ) < 100 * GEO.EPS_SMALL + CurrentPart.b3Raw = EgtGetRawPartBBox( CurrentPart.idRaw) + CurrentPart.dLength = CurrentPart.b3Raw:getDimX() + CurrentPart.dWidth = CurrentPart.b3Raw:getDimY() + CurrentPart.dHeight = CurrentPart.b3Raw:getDimZ() + CurrentPart.bSquareSection = abs( CurrentPart.dWidth - CurrentPart.dHeight) < 100 * GEO.EPS_SMALL - CurrentPart.idBoxTm = EgtGetFirstInGroup( EgtGetFirstNameInGroup( CurrentPart.id, 'Box' ) or GDB_ID.NULL ) - CurrentPart.b3Part = EgtGetBBoxGlob( CurrentPart.idBoxTm, GDB_BB.STANDARD ) + CurrentPart.idBoxTm = EgtGetFirstInGroup( EgtGetFirstNameInGroup( CurrentPart.id, 'Box') or GDB_ID.NULL) + CurrentPart.b3Part = EgtGetBBoxGlob( CurrentPart.idBoxTm, GDB_BB.STANDARD) CurrentPart.nIndexInParts = i - CurrentPart.SplittingPoints = BeamLib.GetPartSplittingPoints( CurrentPart ) + CurrentPart.SplittingPoints = BeamLib.GetPartSplittingPoints( CurrentPart) CurrentPart.NotClampableLength = { STD = { dHead = 0, dTail = 0 }, SIDE = { dHead = 0, dTail = 0 }, DOWN = { dHead = 0, dTail = 0 } } CurrentPart.dHeadOverMaterial = dStartOffset - CurrentPart.sBTLInfo = EgtGetInfo( CurrentPart.id, 'PROJ', 's' ) or nil + CurrentPart.sBTLInfo = EgtGetInfo( CurrentPart.id, 'PROJ', 's') or nil CurrentPart.idTempGroup = idTempGroup + CurrentPart.RestrictedLength = ( BeamData.GetRestrictedLength and BeamData.GetRestrictedLength( dPartWidth, dPartHeight, dPartLen)) + or BeamData.LEN_VERY_SHORT_PART + or 400 -- Notifiche al Post-Processor basate sulla nuova scomposizione - if ( dStartOffset > 0.09 ) then EgtSetInfo( CurrentPart.idRaw, 'HOVM', dStartOffset ) end - if ( dEndOffset > 0.09 ) then EgtSetInfo( CurrentPart.idRaw, 'TOVM', dEndOffset ) end - if ( idPrevRaw ) then EgtSetInfo( idPrevRaw, 'BDST', dStartOffset ) end + if ( dStartOffset > 0.09) then EgtSetInfo( CurrentPart.idRaw, 'HOVM', dStartOffset) end + if ( dEndOffset > 0.09) then EgtSetInfo( CurrentPart.idRaw, 'TOVM', dEndOffset) end + if ( idPrevRaw) then EgtSetInfo( idPrevRaw, 'BDST', dStartOffset) end -- Caricamento Strategie JSON - CurrentPart.sAISetupConfig = EgtGetInfo( CurrentPart.id, 'AISETUP', 's' ) or - ( GENERAL_PARAMETERS.BTL[CurrentPart.sBTLInfo] and GENERAL_PARAMETERS.BTL[CurrentPart.sBTLInfo].sAISetupConfig ) or + CurrentPart.sAISetupConfig = EgtGetInfo( CurrentPart.id, 'AISETUP', 's') or + ( GENERAL_PARAMETERS.BTL[CurrentPart.sBTLInfo] and GENERAL_PARAMETERS.BTL[CurrentPart.sBTLInfo].sAISetupConfig) or GENERAL_PARAMETERS.PROJECT.sAISetupConfig or nil - TIMER:startElapsed( 'Json' ) - BeamExec.GetStrategiesFromJSONinBD( CurrentPart.sAISetupConfig ) - CurrentPart.GeneralParameters = BeamLib.GetPieceGeneralParameters( CurrentPart, GENERAL_PARAMETERS_JSON ) - TIMER:stopElapsed( 'Json' ) + TIMER:startElapsed( 'Json') + BeamExec.GetStrategiesFromJSONinBD( CurrentPart.sAISetupConfig) + CurrentPart.GeneralParameters = BeamLib.GetPieceGeneralParameters( CurrentPart, GENERAL_PARAMETERS_JSON) + TIMER:stopElapsed( 'Json') - CurrentPart.CombinationList = BeamExec.GetAvailableCombinations( CurrentPart, bIsFlipRot ) + CurrentPart.CombinationList = BeamExec.GetAvailableCombinations( CurrentPart, bIsFlipRot) -- Avanzamento calcolato sulla coordinata reale di fine RawPart (estremità sinistra sulla barra) - dMaxX = max( dMaxX, dStartPos + dCurrentRawLen ) + dMaxX = max( dMaxX, dStartPos + dCurrentRawLen) CurrentPart.dRestLength = dRawL - dMaxX idPrevRaw = CurrentPart.idRaw else - local sOut = 'Error: part L(' .. EgtNumToString( dPartLen, 1 ) .. ') too big for remaining bar space' + local sOut = 'Error: part L(' .. EgtNumToString( dPartLen, 1) .. ') too big for remaining bar space' return false, sOut end end -- 8. Chiusura Barra e Gestione Avanzo (Rest Material) - if ( idPrevRaw ) then EgtSetInfo( idPrevRaw, 'BDST', 10000 ) end + if ( idPrevRaw) then EgtSetInfo( idPrevRaw, 'BDST', 10000) end local dRemaining = dRawL - dMaxX if ( dRemaining > dMinLengthToCreateRaw - GEO.EPS_SMALL) then - local idRawRest = EgtAddRawPart( Point3d( 0, 0, 0 ), dRemaining, dRawW, dRawH, BeamData.RAWCOL ) - EgtMoveToCornerRawPart( idRawRest, BeamData.ptOriXR, BeamData.dPosXR ) - EgtMoveRawPart( idRawRest, Vector3d( -dMaxX, 0, 0 ) ) + local idRawRest = EgtAddRawPart( Point3d( 0, 0, 0), dRemaining, dRawW, dRawH, BeamData.RAWCOL) + EgtMoveToCornerRawPart( idRawRest, BeamData.ptOriXR, BeamData.dPosXR) + EgtMoveRawPart( idRawRest, Vector3d( -dMaxX, 0, 0)) nCnt = nCnt + 1 - EgtSetInfo( idRawRest, 'ORD', nCnt ) + EgtSetInfo( idRawRest, 'ORD', nCnt) - if ( EgtGetRawPartBBox( idRawRest ):getDimX( ) < BeamData.dMinRaw ) then + if ( EgtGetRawPartBBox( idRawRest):getDimX() < BeamData.dMinRaw) then PARTS[#PARTS].dDistanceToNextPiece = 10000 end else - if ( #PARTS > 0 ) then PARTS[#PARTS].dDistanceToNextPiece = 10000 end + if ( #PARTS > 0) then PARTS[#PARTS].dDistanceToNextPiece = 10000 end end return true @@ -776,11 +779,11 @@ local function AreDrillingsMirrored( Proc, ProcMirror, Part) -- geometria ausiliaria foro principale AuxId = EgtGetInfo( Proc.id, 'AUXID', 'i') if AuxId then AuxId = AuxId + Proc.id end - if not AuxId or EgtGetType( AuxId ) ~= GDB_TY.CRV_ARC then return false end + if not AuxId or EgtGetType( AuxId) ~= GDB_TY.CRV_ARC then return false end -- geometria ausiliaria foro specchiato local AuxIdMirror = EgtGetInfo( ProcMirror.id, 'AUXID', 'i') if AuxIdMirror then AuxIdMirror = AuxIdMirror + ProcMirror.id end - if not AuxIdMirror or EgtGetType( AuxIdMirror ) ~= GDB_TY.CRV_ARC then return false end + if not AuxIdMirror or EgtGetType( AuxIdMirror) ~= GDB_TY.CRV_ARC then return false end -- dati del foro principale local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) local ptBC = EgtGP( AuxId, GDB_RT.GLOB) @@ -2658,7 +2661,7 @@ function BeamExec.ProcessAlternatives( PARTS) if PARTS[nPart].HeadcutInfo then local sOffsetX = table.concat( PARTS[nPart].HeadcutInfo[AlternativesNest2D[i]].OffsetX, ',') local sVtN = ( tostring( PARTS[nPart].HeadcutInfo[AlternativesNest2D[i]].vtN)):gsub("^%(", ""):gsub("%)$", "") - table.insert( BEAM.INFONGEPART, 'ALT' .. AlternativesNest2D[i].. '_H' .. '=' .. sOffsetX .. ';' .. sVtN ) + table.insert( BEAM.INFONGEPART, 'ALT' .. AlternativesNest2D[i].. '_H' .. '=' .. sOffsetX .. ';' .. sVtN) end if PARTS[nPart].TailcutInfo then local sOffsetX = table.concat( PARTS[nPart].TailcutInfo[AlternativesNest2D[i]].OffsetX, ',')