diff --git a/NestFlipAndRotate.lua b/NestFlipAndRotate.lua index 45be4a1..47c94bc 100644 --- a/NestFlipAndRotate.lua +++ b/NestFlipAndRotate.lua @@ -157,9 +157,9 @@ local bManualRot = EgtGetInfo( NFAR.PARTID, "MANUALROT", 'b') -- FLIP local FlipFeatureStates, bLapJoints = ClassifyFlip( vPartProc, b3Part) +local bFlip if not bManualFlip then - local bFlip -- analizzo stati flip delle feature local nFlip0Min = 100 local nFlip0Cnt = 0 @@ -440,7 +440,7 @@ if not bManualRot then -- setto info nel pezzo if nRotate > 0 then local nPartRot = EgtGetInfo( NFAR.PARTID, "ROTATED", 'i') or 0 - local nTotRot = nPartRot - nRotate + local nTotRot = nPartRot - EgtIf( bFlip, -nRotate, nRotate) nTotRot = EgtIf( nTotRot < 0, nTotRot + 360, nTotRot) EgtSetInfo( NFAR.PARTID, "ROTATED", nTotRot) EgtSetInfo( NFAR.PARTID, "FLIPROTMODIFIED", 1) diff --git a/NestProcess.lua b/NestProcess.lua index ba4d064..2e12443 100644 --- a/NestProcess.lua +++ b/NestProcess.lua @@ -1128,9 +1128,10 @@ local function ClassifyAngles( nPartId, RawPart, sRefOrig, bLockedRot, dMinSheet if nRotate >= 360 then nRotate = nRotate - 360 end - if nRotate > 0 then + if nRotate > 0 then + local bPartFlip = ( ( EgtGetInfo( nPartId, "INVERTED", 'i') or 0) == 180) local nPartRot = EgtGetInfo( nPartId, "ROTATED", 'i') or 0 - local nTotRot = nPartRot - nRotate + local nTotRot = nPartRot - EgtIf( bPartFlip, -nRotate, nRotate) nTotRot = EgtIf( nTotRot < 0, nTotRot + 360, nTotRot) EgtSetInfo( nPartId, "ROTATED", nTotRot) EgtSetInfo( nPartId, "MODIFIEDFORNEST", 1) @@ -1325,8 +1326,9 @@ local function ComputeRestrictedZones( RawParts) bOnOppositeSide = true -- aggiorno le info di rotazione if res.nRotate > 0 then + local bPartFlip = ( ( EgtGetInfo( AngleClassification[nInd].PartId, "INVERTED", 'i') or 0) == 180) local nPartRot = EgtGetInfo( AngleClassification[nInd].PartId, "ROTATED", 'i') or 0 - local nTotRot = nPartRot - res.nRotate + local nTotRot = nPartRot - EgtIf( bPartFlip, -res.nRotate, res.nRotate) nTotRot = EgtIf( nTotRot < 0, nTotRot + 360, nTotRot) EgtSetInfo( AngleClassification[nInd].PartId, "ROTATED", nTotRot) EgtSetInfo( AngleClassification[nInd].PartId, "MODIFIEDFORNEST", 1) @@ -1507,7 +1509,6 @@ local function AddParts(RawParts, vPartsDoneManually) bRotNest = false elseif EgtExistsInfo( nPartId, "NestRot") then nStepRotNest = EgtGetInfo( nPartId, "NestStepRot", 'i') - nRotate = EgtGetInfo( nPartId, "NestRot", 'i') bRotNest = EgtGetInfo( nPartId, "NestAllowRot", 'b') -- verifico se rotazione è valida (pezzo è contenuto nel grezzo) local bValidRotationInRaw = b3Part:getDimX() < RawParts[1].Len - 2 * NEST.KERF + GEO.EPS_SMALL and b3Part:getDimY() < dRawMaxWidth - 2 * NEST.KERF + GEO.EPS_SMALL @@ -1884,15 +1885,21 @@ if bNestingOk then EgtSetInfo( nPartDuploId, "POSX", ptPos:getX() + dXCorr) EgtSetInfo( nPartDuploId, "POSY", ptPos:getY() + dYCorr) - local nPartRot = EgtGetInfo( nId, "ROTATED", 'i') or 0 - local nTotRot = dAngRot - nPartRot - nTotRot = EgtIf( nTotRot < 0, nTotRot + 360, nTotRot) - EgtSetInfo( nPartDuploId, "ROT", nTotRot) - - local nPartFlip = EgtGetInfo( nId, "INVERTED", 'i') + local nPartFlip = EgtGetInfo( nId, "INVERTED", 'i') or 0 nPartFlip = EgtIf( nPartFlip == 180, 1, 0) local nTotFlip = EgtIf( nPartFlip ~= nFlag, 180, 0) EgtSetInfo( nPartDuploId, "FLIP", nTotFlip) + + local bPartFlip = ( ( EgtGetInfo( nId, "INVERTED", 'i') or 0) == 180) + local nPartRot = EgtGetInfo( nId, "ROTATED", 'i') or 0 + local nTotRot = nPartRot - EgtIf( bPartFlip, -dAngRot, dAngRot) + if nTotRot < 0 then + nTotRot = nTotRot + 360 + elseif nTotRot >= 360 then + nTotRot = nTotRot - 360 + end + EgtSetInfo( nPartDuploId, "ROT", nTotRot) + end end end