DataWall :
- modifiche per cliente belga.
This commit is contained in:
@@ -1423,7 +1423,7 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d
|
||||
local bInvertMach
|
||||
local nModifyLeadInOut = 0
|
||||
local nFace2ndFace
|
||||
local dMaxDistToOut = 1800 -- dMillDiamTh/2
|
||||
local dMaxDistToOut = EgtIf( bMachFromDn, 1800, 300)
|
||||
-- se orientato lungo la Y
|
||||
if abs( vtN:getX()) > 0.9 then
|
||||
dExtraLongExtPlus = abs( Proc.Box:getMax():getY() - b3Raw:getMax():getY())
|
||||
@@ -1537,9 +1537,8 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d
|
||||
end
|
||||
end
|
||||
end
|
||||
local nNumStep = 0
|
||||
-- se ho abilitato la lavorazione di fresatura per garantire passaggio gambo utensile inserisco la lavorazione
|
||||
if bEnablePreMill or bAsEnablePreMill then
|
||||
if bEnablePreMill then
|
||||
-- calcolo di quanto deve essere largo e lungo il canale di fresatura
|
||||
local dDimGorge = ( 0.5 * ( dMillDiam + dMillDiamTh)) - dElevToPiece + 2
|
||||
-- se il materiale extra è inferiore della gola completa, ricalcolo la dimensione della gola
|
||||
@@ -1567,7 +1566,7 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d
|
||||
end
|
||||
end
|
||||
-- calcolo quanti passi devo fare in larghezza per scaricare l'area di impegno utensile
|
||||
nNumStep = ceil( ( dDimGorge - dMillDiamFirst) / ( dMillDiamFirst * 0.8)) + 1
|
||||
local nNumStep = ceil( ( dDimGorge - dMillDiamFirst) / ( dMillDiamFirst * 0.8)) + 1
|
||||
local dC = 0
|
||||
if ( nNumStep - 1) > 0 then
|
||||
dC = ( dDimGorge - dMillDiamFirst) / ( nNumStep - 1)
|
||||
@@ -1648,7 +1647,7 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d
|
||||
local dStep = EgtGetMachiningParam( MCH_MP.STEP)
|
||||
if dStep < GEO.EPS_SMALL then dStep = 0.75 * dMaxMat end
|
||||
local nStep = ceil( ( dThick - dMaxMat) / dStep)
|
||||
dStep = ( dThick - dMaxMat) / max( nStep, 1)
|
||||
dStep = max( ( dThick - dMaxMat) / max( nStep, 1), 0)
|
||||
local dMaxElev = max( ( nStep + 1) * dStep - GEO.EPS_SMALL, 0)
|
||||
if nSinglePass and nSinglePass > 0 then
|
||||
dStep = 0
|
||||
@@ -1665,18 +1664,21 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d
|
||||
-- se ho inserito il pretaglio modifico
|
||||
if bEnablePreMill or bAsEnablePreMill then
|
||||
if nModifyLeadInOut > 0 then
|
||||
-- Invece del numero di passi in sgrossatura confronto il raggio fresa con l'elevazione dalla normale
|
||||
-- per vedere se devo modificare l'uscita
|
||||
-- if nNumStep > 1 then
|
||||
-- Confronto il raggio fresa con l'elevazione dalla normale per vedere se devo modificare l'uscita
|
||||
if dElev > ( 0.5 * dMillDiam) then
|
||||
-- setto il tipo di passo a una via
|
||||
EgtSetMachiningParam( MCH_MP.STEPTYPE, 1)
|
||||
-- modifico il tipo di uscita
|
||||
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, 5)
|
||||
EgtSetMachiningParam( MCH_MP.LIPERP, 0)
|
||||
-- modifico dati supplementari uscita
|
||||
EgtSetMachiningParam( MCH_MP.LOPERP, 0.5)
|
||||
EgtSetMachiningParam( MCH_MP.LOTANG, -( dLongGorge + dExtraLongIni + dExtraLongEnd))
|
||||
if nModifyLeadInOut == 1 then
|
||||
-- setto il tipo di passo a una via
|
||||
EgtSetMachiningParam( MCH_MP.STEPTYPE, MCH_MILL_ST.ONEWAY)
|
||||
-- modifico il tipo di uscita
|
||||
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.PERP_TG)
|
||||
EgtSetMachiningParam( MCH_MP.LIPERP, 0)
|
||||
-- modifico dati supplementari uscita
|
||||
EgtSetMachiningParam( MCH_MP.LOPERP, 0.5)
|
||||
EgtSetMachiningParam( MCH_MP.LOTANG, -( dLongGorge + dExtraLongIni + dExtraLongEnd))
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.LIPERP, dElev)
|
||||
EgtSetMachiningParam( MCH_MP.LOPERP, dElev)
|
||||
end
|
||||
end
|
||||
-- setto allungamenti iniziali e finali
|
||||
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dExtraLongIni)
|
||||
@@ -1690,9 +1692,7 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d
|
||||
-- setto allungamenti iniziali e finali
|
||||
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dExtraLongIni)
|
||||
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dExtraLongEnd)
|
||||
-- Invece del numero di passi in sgrossatura confronto il raggio fresa con l'elevazione dalla normale
|
||||
-- per vedere se devo modificare l'uscita
|
||||
-- if nNumStep > 1 then
|
||||
-- Confronto il raggio fresa con l'elevazione dalla normale per vedere se devo modificare l'uscita
|
||||
if dElev > ( 0.5 * dMillDiam) then
|
||||
-- setto allungamenti perpendicolari
|
||||
EgtSetMachiningParam( MCH_MP.LIPERP, 0)
|
||||
@@ -1705,9 +1705,7 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d
|
||||
end
|
||||
else
|
||||
if nModifyLeadInOut > 0 then
|
||||
-- Invece del numero di passi in sgrossatura confronto il raggio fresa con l'elevazione dalla normale
|
||||
-- per vedere se devo modificare l'uscita
|
||||
-- if nNumStep > 1 then
|
||||
-- Confronto il raggio fresa con l'elevazione dalla normale per vedere se devo modificare l'uscita
|
||||
if dElev > ( 0.5 * dMillDiam) then
|
||||
-- setto il tipo di passo a una via
|
||||
EgtSetMachiningParam( MCH_MP.STEPTYPE, 1)
|
||||
@@ -1735,7 +1733,7 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d
|
||||
-- verifico se devo lavorare anche la seconda faccia basandomi sul valore dell'angolo interno
|
||||
if dAng and dAng > -90 + 10 * GEO.EPS_SMALL then
|
||||
local nOtherFacet = abs(nFacet - 1)
|
||||
-- inserisco la lavorazione di contornatura
|
||||
-- inserisco la lavorazione di contornatura
|
||||
local sName = 'Mill_Oth_Fac_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
|
||||
local nMchFId = EgtAddMachining( sName, sMilling)
|
||||
if not nMchFId then
|
||||
@@ -1768,9 +1766,7 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d
|
||||
-- se ho inserito il pretaglio modifico
|
||||
if bEnablePreMill or bAsEnablePreMill then
|
||||
if nModifyLeadInOut > 0 then
|
||||
-- Invece del numero di passi in sgrossatura confronto il raggio fresa con l'elevazione dalla normale
|
||||
-- per vedere se devo modificare l'uscita
|
||||
-- if nNumStep > 1 then
|
||||
-- Confronto il raggio fresa con l'elevazione dalla normale per vedere se devo modificare l'uscita
|
||||
if dElev > ( 0.5 * dMillDiam) then
|
||||
-- setto il tipo di passo a una via
|
||||
EgtSetMachiningParam( MCH_MP.STEPTYPE, 1)
|
||||
@@ -1812,9 +1808,7 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d
|
||||
end
|
||||
else
|
||||
if nModifyLeadInOut > 0 then
|
||||
-- Invece del numero di passi in sgrossatura confronto il raggio fresa con l'elevazione dalla normale
|
||||
-- per vedere se devo modificare l'uscita
|
||||
-- if nNumStep > 1 then
|
||||
-- Confronto il raggio fresa con l'elevazione dalla normale per vedere se devo modificare l'uscita
|
||||
if dElev > ( 0.5 * dMillDiam) then
|
||||
-- setto il tipo di passo a una via
|
||||
EgtSetMachiningParam( MCH_MP.STEPTYPE, 1)
|
||||
@@ -2073,7 +2067,6 @@ local function MakeTwoFaces( Proc, nRawId, b3Raw)
|
||||
if bEnableMillOnSide and dMaxDepthOnSide > 0 then
|
||||
dMaxDist = dMaxDepthOnSide
|
||||
end
|
||||
dMaxDist = 1000
|
||||
-- se vicino al bordo del grezzo e non troppo larga, provo con fresatura di fianco
|
||||
local ptMid = ( ptP1 + ptP2) / 2
|
||||
local bMakeFirstGroove
|
||||
@@ -2158,7 +2151,7 @@ local function MakeTwoFaces( Proc, nRawId, b3Raw)
|
||||
bEnableMillOnSide = false
|
||||
end
|
||||
-- per il fianco in alto non ci sono problemi di inserimento massimo laterale, setto la variabile pari al raggio utensile - 1mm
|
||||
dMaxDepthOnSide = (0.5 * dMillDiam) - 1
|
||||
dMaxDepthOnSide = ( 0.5 * dMillDiam) - 1
|
||||
local dMaxDist = 300
|
||||
if bEnableMillOnSide and dMaxDepthOnSide > 0 then
|
||||
dMaxDist = dMaxDepthOnSide
|
||||
@@ -2178,7 +2171,8 @@ local function MakeTwoFaces( Proc, nRawId, b3Raw)
|
||||
end
|
||||
elseif bEnableMillOnSide and dMaxDepthOnSide > 0 then
|
||||
bLikeAsMakeFirstGroove = true
|
||||
return MakeSideGrooveByMill( Proc, nFacetVert, nRawId, b3Raw, EgtIf( bEnableMillOnSide and dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, bLikeAsMakeFirstGroove)
|
||||
local bOk, sErr = MakeSideGrooveByMill( Proc, nFacetVert, nRawId, b3Raw, EgtIf( bEnableMillOnSide and dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, bLikeAsMakeFirstGroove)
|
||||
if bOk then return true end
|
||||
end
|
||||
-- se non inclinate o capacità di taglio non sufficiente o non molto grandi (80mm), provo con contornatura o svuotatura
|
||||
if not sCutting or dSawMaxDepth < dDimY[1] + WD.CUT_SIC or dSawMaxDepth < dDimY[2] + WD.CUT_SIC or dDimY[1] < 80 or dDimY[2] < 80 then
|
||||
|
||||
@@ -0,0 +1,325 @@
|
||||
-- NestFlipAndRotate.lua by Egaltech s.r.l. 2021/11/25
|
||||
-- Flip e rotazione ottimali per il nesting in base all'analisi delle features
|
||||
|
||||
-- Intestazioni
|
||||
require( 'EgtBase')
|
||||
_ENV = EgtProtectGlobal()
|
||||
EgtEnableDebug( false)
|
||||
|
||||
-- NFAR.PARTID =
|
||||
|
||||
|
||||
local sLog = 'Flip And Rotate Part ' .. tostring( NFAR.PARTID)
|
||||
EgtOutLog( sLog)
|
||||
|
||||
-- Imposto direttorio libreria specializzata per Travi
|
||||
local sBaseDir = EgtGetSourceDir()
|
||||
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
|
||||
|
||||
-- Verifico che la macchina corrente sia abilitata per la lavorazione delle Pareti
|
||||
local sMachDir = EgtGetCurrMachineDir()
|
||||
if not EgtExistsFile( sMachDir .. '\\Wall\\WallData.lua') then
|
||||
NFAR.ERR = 12
|
||||
NFAR.MSG = 'Error not configured for walls machine : ' .. sMachine
|
||||
WriteErrToLogFile( NFAR.ERR, NFAR.MSG)
|
||||
PostErrView( NFAR.ERR, NFAR.MSG)
|
||||
return
|
||||
end
|
||||
|
||||
-- Elimino direttori altre macchine e imposto direttorio macchina corrente per ricerca librerie
|
||||
EgtRemoveBaseMachineDirFromPackagePath()
|
||||
EgtAddToPackagePath( sMachDir .. '\\Wall\\?.lua')
|
||||
|
||||
-- Carico le librerie
|
||||
_G.package.loaded.WallExec = nil
|
||||
local WE = require( 'WallExec')
|
||||
_G.package.loaded.WProcessLapJoint = nil
|
||||
local LapJoint = require( 'WProcessLapJoint')
|
||||
_G.package.loaded.WProcessDrill = nil
|
||||
local Drill = require( 'WProcessDrill')
|
||||
_G.package.loaded.WProcessCut = nil
|
||||
local Cut = require( 'WProcessCut')
|
||||
_G.package.loaded.WProcessDoubleCut = nil
|
||||
local DoubleCut = require( 'WProcessDoubleCut')
|
||||
_G.package.loaded.WProcessSawCut = nil
|
||||
local SawCut = require( 'WProcessSawCut')
|
||||
_G.package.loaded.WProcessFreeContour = nil
|
||||
local FreeContour = require( 'WProcessFreeContour')
|
||||
_G.package.loaded.WProcessMortise = nil
|
||||
local Mortise = require( 'WProcessMortise')
|
||||
_G.package.loaded.WProcessDtMortise = nil
|
||||
local DtMortise = require( 'WProcessDtMortise')
|
||||
_G.package.loaded.WProcessMark = nil
|
||||
local Mark = require( 'WProcessMark')
|
||||
_G.package.loaded.WProcessText = nil
|
||||
local Text = require( 'WProcessText')
|
||||
|
||||
-- Carico i dati globali
|
||||
local WD = require( 'WallData')
|
||||
|
||||
local function ClassifyFlip( vPartProc, b3Part)
|
||||
|
||||
local FlipFeatureStates = {}
|
||||
for nInd = 1, #vPartProc do
|
||||
if LapJoint.Identify( vPartProc[nInd]) then
|
||||
-- setto parametro Q
|
||||
if vPartProc[nInd].Prc == 30 then
|
||||
EgtSetInfo( vPartProc[nInd].Id, "Q08", 1)
|
||||
EgtSetInfo( vPartProc[nInd].Id, "Q08A", 1)
|
||||
else
|
||||
EgtSetInfo( vPartProc[nInd].Id, "Q03", 1)
|
||||
EgtSetInfo( vPartProc[nInd].Id, "Q03A", 1)
|
||||
end
|
||||
|
||||
local nFlip0, nFlip1 = LapJoint.FlipClassify(vPartProc[nInd])
|
||||
if nFlip0 and nFlip1 and nFlip0 ~= nFlip1 then
|
||||
table.insert( FlipFeatureStates, { Flip0 = nFlip0, Flip1 = nFlip1})
|
||||
end
|
||||
elseif Drill.Identify( vPartProc[nInd]) then
|
||||
local nFlip0, nFlip1 = Drill.FlipClassify(vPartProc[nInd], b3Part)
|
||||
if nFlip0 and nFlip1 and nFlip0 ~= nFlip1 then
|
||||
table.insert( FlipFeatureStates, { Flip0 = nFlip0, Flip1 = nFlip1})
|
||||
end
|
||||
elseif Cut.Identify( vPartProc[nInd]) then
|
||||
local nFlip0, nFlip1 = Cut.FlipClassify(vPartProc[nInd], b3Part)
|
||||
if nFlip0 and nFlip1 and nFlip0 ~= nFlip1 then
|
||||
table.insert( FlipFeatureStates, { Flip0 = nFlip0, Flip1 = nFlip1})
|
||||
end
|
||||
elseif DoubleCut.Identify( vPartProc[nInd]) then
|
||||
-- setto parametro Q
|
||||
if vPartProc[nInd].Prc == 12 then
|
||||
EgtSetInfo( vPartProc[nInd].Id, "Q02", 1)
|
||||
EgtSetInfo( vPartProc[nInd].Id, "Q02A", 1)
|
||||
end
|
||||
local nFlip0, nFlip1 = DoubleCut.FlipClassify(vPartProc[nInd], b3Part)
|
||||
if nFlip0 and nFlip1 and nFlip0 ~= nFlip1 then
|
||||
table.insert( FlipFeatureStates, { Flip0 = nFlip0, Flip1 = nFlip1})
|
||||
end
|
||||
elseif SawCut.Identify( vPartProc[nInd]) then
|
||||
local nFlip0, nFlip1 = SawCut.FlipClassify(vPartProc[nInd], b3Part)
|
||||
if nFlip0 and nFlip1 and nFlip0 ~= nFlip1 then
|
||||
table.insert( FlipFeatureStates, { Flip0 = nFlip0, Flip1 = nFlip1})
|
||||
end
|
||||
elseif FreeContour.Identify( vPartProc[nInd]) then
|
||||
local nFlip0, nFlip1 = FreeContour.FlipClassify(vPartProc[nInd], b3Part)
|
||||
if nFlip0 and nFlip1 and nFlip0 ~= nFlip1 then
|
||||
table.insert( FlipFeatureStates, { Flip0 = nFlip0, Flip1 = nFlip1})
|
||||
end
|
||||
elseif Mortise.Identify( vPartProc[nInd]) then
|
||||
local nFlip0, nFlip1 = Mortise.FlipClassify(vPartProc[nInd], b3Part)
|
||||
if nFlip0 and nFlip1 and nFlip0 ~= nFlip1 then
|
||||
table.insert( FlipFeatureStates, { Flip0 = nFlip0, Flip1 = nFlip1})
|
||||
end
|
||||
elseif DtMortise.Identify( vPartProc[nInd]) then
|
||||
local nFlip0, nFlip1 = DtMortise.FlipClassify(vPartProc[nInd], b3Part)
|
||||
if nFlip0 and nFlip1 and nFlip0 ~= nFlip1 then
|
||||
table.insert( FlipFeatureStates, { Flip0 = nFlip0, Flip1 = nFlip1})
|
||||
end
|
||||
elseif Mark.Identify( vPartProc[nInd]) then
|
||||
local nFlip0, nFlip1 = Mark.FlipClassify(vPartProc[nInd], b3Part)
|
||||
if nFlip0 and nFlip1 and nFlip0 ~= nFlip1 then
|
||||
table.insert( FlipFeatureStates, { Flip0 = nFlip0, Flip1 = nFlip1})
|
||||
end
|
||||
elseif Text.Identify( vPartProc[nInd]) then
|
||||
local nFlip0, nFlip1 = Text.FlipClassify(vPartProc[nInd], b3Part)
|
||||
if nFlip0 and nFlip1 and nFlip0 ~= nFlip1 then
|
||||
table.insert( FlipFeatureStates, { Flip0 = nFlip0, Flip1 = nFlip1})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return FlipFeatureStates
|
||||
end
|
||||
|
||||
|
||||
local function ClassifyRotation( vPartProc)
|
||||
|
||||
local RotateFeatureStates = {}
|
||||
for nInd = 1, #vPartProc do
|
||||
if Drill.Identify( vPartProc[nInd]) then
|
||||
local nRot0, nRot90, nRot180, nRot270 = Drill.RotateClassify(vPartProc[nInd], ValidRotations)
|
||||
if nRot0 and nRot0 >= 0 then
|
||||
table.insert( RotateFeatureStates, { Rot0 = nRot0, Rot90 = nRot90, Rot180 = nRot180, Rot270 = nRot270})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return RotateFeatureStates
|
||||
end
|
||||
|
||||
|
||||
---
|
||||
|
||||
local vPartProc = WE.CollectFeatures( NFAR.PARTID)
|
||||
local b3Part = EgtGetBBoxGlob( NFAR.PARTID, GDB_BB.STANDARD)
|
||||
|
||||
-- FLIP
|
||||
|
||||
local FlipFeatureStates = ClassifyFlip( vPartProc, b3Part)
|
||||
local bFlip
|
||||
-- analizzo stati flip delle feature
|
||||
local nFlip0Min = 100
|
||||
local nFlip0Cnt = 0
|
||||
local nFlip1Min = 100
|
||||
local nFlip1Cnt = 0
|
||||
-- calcolo punteggio minimo e sua molteplicita' per entrambi i lati
|
||||
for nInd = 1, #FlipFeatureStates do
|
||||
if FlipFeatureStates[nInd].Flip0 < nFlip0Min then
|
||||
nFlip0Min = FlipFeatureStates[nInd].Flip0
|
||||
nFlip0Cnt = 1
|
||||
elseif FlipFeatureStates[nInd].Flip0 == nFlip0Min then
|
||||
nFlip0Cnt = nFlip0Cnt + 1
|
||||
end
|
||||
if FlipFeatureStates[nInd].Flip1 < nFlip1Min then
|
||||
nFlip1Min = FlipFeatureStates[nInd].Flip1
|
||||
nFlip1Cnt = 1
|
||||
elseif FlipFeatureStates[nInd].Flip1 == nFlip1Min then
|
||||
nFlip1Cnt = nFlip1Cnt + 1
|
||||
end
|
||||
end
|
||||
-- calcolo lato con punteggio minore o molteplicita' piu' alta
|
||||
if nFlip0Min == nFlip1Min then
|
||||
if nFlip0Cnt > nFlip1Cnt then
|
||||
bFlip = true
|
||||
elseif nFlip0Cnt < nFlip1Cnt then
|
||||
bFlip = false
|
||||
end
|
||||
elseif nFlip0Min < nFlip1Min then
|
||||
bFlip = true
|
||||
else
|
||||
bFlip = false
|
||||
end
|
||||
|
||||
if bFlip ~= nil then
|
||||
-- se una posizione è più conveniente dell'altra setto info nel pezzo
|
||||
EgtSetInfo( NFAR.PARTID, "NestAllowFlip", false)
|
||||
EgtSetInfo( NFAR.PARTID, "NestFlip", bFlip)
|
||||
else
|
||||
EgtSetInfo( NFAR.PARTID, "NestAllowFlip", true)
|
||||
end
|
||||
|
||||
if bFlip then
|
||||
-- flip pezzo
|
||||
EgtRotate( NFAR.PARTID, b3Part:getCenter(), X_AX(), 180, GDB_RT.GLOB)
|
||||
-- modifico le info del pezzo
|
||||
local nPartFlip = EgtGetInfo( NFAR.PARTID, "INVERTED", 'i') or 0
|
||||
local nTotFlip = EgtIf( nPartFlip == 180, 0, 180)
|
||||
EgtSetInfo( NFAR.PARTID, "INVERTED", nTotFlip)
|
||||
EgtSetInfo( NFAR.PARTID, "FLIPROTMODIFIED", 1)
|
||||
end
|
||||
|
||||
-- ROTATION
|
||||
local RotateFeatureStates = ClassifyRotation( vPartProc)
|
||||
|
||||
-- analizzo stati rotazione delle feature
|
||||
local nRot0Min = 100
|
||||
local nRot0Cnt = 0
|
||||
local nRot90Min = 100
|
||||
local nRot90Cnt = 0
|
||||
local nRot180Min = 100
|
||||
local nRot180Cnt = 0
|
||||
local nRot270Min = 100
|
||||
local nRot270Cnt = 0
|
||||
-- calcolo punteggio minimo e sua molteplicita' per tutte le rotazioni
|
||||
for nInd = 1, #RotateFeatureStates do
|
||||
if RotateFeatureStates[nInd].Rot0 < nRot0Min then
|
||||
nRot0Min = RotateFeatureStates[nInd].Rot0
|
||||
nRot0Cnt = 1
|
||||
elseif RotateFeatureStates[nInd].Rot0 == nRot0Min then
|
||||
nRot0Cnt = nRot0Cnt + 1
|
||||
end
|
||||
if RotateFeatureStates[nInd].Rot90 < nRot90Min then
|
||||
nRot90Min = RotateFeatureStates[nInd].Rot90
|
||||
nRot90Cnt = 1
|
||||
elseif RotateFeatureStates[nInd].Rot90 == nRot90Min then
|
||||
nRot90Cnt = nRot90Cnt + 1
|
||||
end
|
||||
if RotateFeatureStates[nInd].Rot180 < nRot180Min then
|
||||
nRot180Min = RotateFeatureStates[nInd].Rot180
|
||||
nRot180Cnt = 1
|
||||
elseif RotateFeatureStates[nInd].Rot180 == nRot180Min then
|
||||
nRot180Cnt = nRot180Cnt + 1
|
||||
end
|
||||
if RotateFeatureStates[nInd].Rot270 < nRot270Min then
|
||||
nRot270Min = RotateFeatureStates[nInd].Rot270
|
||||
nRot270Cnt = 1
|
||||
elseif RotateFeatureStates[nInd].Rot270 == nRot270Min then
|
||||
nRot270Cnt = nRot270Cnt + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- se c'e' qualche stato di rotazione
|
||||
local MinList = { { Rot = 0, Score = nRot0Min, ScoreCnt = nRot0Cnt},
|
||||
{ Rot = 90, Score = nRot90Min, ScoreCnt = nRot90Cnt},
|
||||
{ Rot = 180, Score = nRot180Min, ScoreCnt = nRot180Cnt},
|
||||
{ Rot = 270, Score = nRot270Min, ScoreCnt = nRot270Cnt}}
|
||||
if #RotateFeatureStates > 0 then
|
||||
-- calcolo lato con punteggio minore o molteplicita' piu' alta
|
||||
local nRotMax = 0
|
||||
local nScoreMax = 0
|
||||
local nScoreCnt = 0
|
||||
for nInd = 1, #MinList do
|
||||
if MinList[nInd].Score > nScoreMax then
|
||||
nRotMax = MinList[nInd].Rot
|
||||
nScoreMax = MinList[nInd].Score
|
||||
nScoreCnt = MinList[nInd].ScoreCnt
|
||||
elseif MinList[nInd].Score == nScoreMax then
|
||||
if MinList[nInd].ScoreCnt > nScoreCnt then
|
||||
nRotMax = MinList[nInd].Rot
|
||||
nScoreMax = MinList[nInd].Score
|
||||
nScoreCnt = MinList[nInd].ScoreCnt
|
||||
end
|
||||
end
|
||||
end
|
||||
nRotate = nRotMax
|
||||
else
|
||||
nRotate = 0
|
||||
end
|
||||
|
||||
|
||||
local bRotNest = false
|
||||
local nStepRotNest = 0
|
||||
-- se calcolate limitazioni su rotazioni
|
||||
if MinList and #MinList > 0 then
|
||||
-- verifico condizioni da permettere al nesting
|
||||
if MinList[1].Score >= 50 and MinList[2].Score >= 50 and MinList[3].Score >= 50 and MinList[4].Score >= 50 then
|
||||
bRotNest = true
|
||||
nStepRotNest = 90
|
||||
elseif (nRotate == 0 and MinList[3].Score >= 50) or ( nRotate == 90 and MinList[4].Score >= 50) then
|
||||
bRotNest = true
|
||||
nStepRotNest = 180
|
||||
end
|
||||
else
|
||||
-- altrimenti permetto tutto
|
||||
bRotNest = true
|
||||
nStepRotNest = 90
|
||||
end
|
||||
|
||||
-- eseguo rotazione
|
||||
EgtRotate( NFAR.PARTID, b3Part:getCenter(), Z_AX(), nRotate, GDB_RT.GLOB)
|
||||
|
||||
-- verifico se rotazione è valida
|
||||
b3Part = EgtGetBBoxGlob( NFAR.PARTID, GDB_BB.STANDARD)
|
||||
local bValidRotation = b3Part:getDimX() < WD.MAX_LENGTH and b3Part:getDimY() < WD.MAX_WIDTH
|
||||
if not bValidRotation then
|
||||
EgtRotate( NFAR.PARTID, b3Part:getCenter(), Z_AX(), 90, GDB_RT.GLOB)
|
||||
nRotate = nRotate + 90
|
||||
nStepRotNest = 180
|
||||
end
|
||||
|
||||
-- setto info
|
||||
if nRotate > 0 then
|
||||
local nPartRot = EgtGetInfo( NFAR.PARTID, "ROTATED", 'i') or 0
|
||||
local nTotRot = nPartRot + nRotate
|
||||
nTotRot = EgtIf( nTotRot < 360, nTotRot, nTotRot - 360)
|
||||
EgtSetInfo( NFAR.PARTID, "ROTATED", nTotRot)
|
||||
EgtSetInfo( NFAR.PARTID, "FLIPROTMODIFIED", 1)
|
||||
end
|
||||
|
||||
|
||||
-- setto info nel pezzo
|
||||
EgtSetInfo( NFAR.PARTID, "NestStepRot", nStepRotNest)
|
||||
EgtSetInfo( NFAR.PARTID, "NestRot", nRotate)
|
||||
EgtSetInfo( NFAR.PARTID, "NestAllowRot", bRotNest)
|
||||
|
||||
NFAR.ERR = 0
|
||||
Reference in New Issue
Block a user