- disattivata l'impostazione per l'esecuzione nel CAM5 per il CreateSolid

- gestione dell'import di piani cucina con un loop interno
- gestione della creazione di un fondello con un pezzo unico o con un pezzo per lato
- correzioni al calcolo del draft angle, creazione del pezzo a partire da misure e angoli e calcolo delle misure del pezzo tenendo conto dei vicini.
This commit is contained in:
Daniele Bariletti
2024-12-20 10:00:02 +01:00
parent 6e6aa093cf
commit 28922eff89
3 changed files with 77 additions and 60 deletions
+46 -41
View File
@@ -64,20 +64,14 @@ end
--
-- ASSEGNO Info per conoscere le direzioni dei lati
function TOOL.SetMachiningInfo(Layer, bInLoop)
-- if not bInLoop then return end
if EgtIsLayer( Layer) then
local LayerName = EgtGetName( Layer)
-- verifico che sia di tipo In o Out, altrimenti ricerco nel Part il layer
if not LayerName == 'OutLoop' or not LayerName == 'InLoop' then
Layer = EgtGetFirstInGroup( Layer)
CMP.ERR = 2
CMP.MSG = CMP.MSG.." In SetMachiningInfo il Layer non è di tipo 'OutLoop' o 'InLoop'."
end
else
CMP.ERR = 3
CMP.MSG = CMP.MSG.." In SetMachiningInfo il Layer non è di tipo 'OutLoop' o 'InLoop'."
end
function TOOL.SetMachiningInfo(Layer)
local LayerName = EgtGetName( Layer)
-- verifico che sia di tipo In o Out, altrimenti ricerco nel Part il layer
if not LayerName == 'OutLoop' or not LayerName == 'InLoop' then
Layer = EgtGetFirstInGroup( Layer)
CMP.ERR = 2
CMP.MSG = CMP.MSG.." In SetMachiningInfo il Layer non è di tipo 'OutLoop' o 'InLoop'."
end
local nId = EgtGetFirstInGroup(Layer)
local nPrevId = EgtGetLastInGroup(Layer)
local nNextId = EgtGetNext(nId)
@@ -86,16 +80,16 @@ function TOOL.SetMachiningInfo(Layer, bInLoop)
if nEdges == 1 then
EgtSetInfo(nId, 'PrevAng', 0)
EgtSetInfo(nId, 'NextAng', 0)
return
return
end
for i = 1, nEdges do
-- recupero i dati
local vtCurrS = EgtSV(nId, GDB_RT.GLOB)
local vtPrevE = EgtEV(nPrevId, GDB_RT.GLOB)
local vtCurrE = EgtEV(nId, GDB_RT.GLOB)
local vtCurrE = EgtEV(nId, GDB_RT.GLOB)
local vtNextS = EgtSV(nNextId, GDB_RT.GLOB)
local vtAx = Z_AX()
if bInLoop then vtAx=-vtAx end
local vtAx = Z_AX()
--if bInLoop then vtAx=-vtAx end
local NextAng = GetRotation( vtCurrE, vtNextS, vtAx)
local PrevAng = GetRotation( vtPrevE, vtCurrS, vtAx)
-- scrivo le info
@@ -152,7 +146,7 @@ function TOOL.ExplodeAndNameEdges( IdLoop, bInLoop)
nEdge = EgtGetNext(nEdge)
end
-- Ricavo info direzioni
TOOL.SetMachiningInfo(nLay,bInLoop)
TOOL.SetMachiningInfo(nLay)
return tbIdLoop
end
--
@@ -184,12 +178,14 @@ function TOOL.CreatePart(tbLayer, sName, tbIdEntCrv, dTh, bInLoop)
-- Nel Layer Region definisco la regione piana
local IdReg = EgtSurfFlatRegion(tbLayer['Region'],IdLoop)
-- Se InLoop allora faccio la sottrazione con la regione OutRegion
--local bInvertCurve = false
if bInLoop then
local IdOutRegion = EgtGetPrev(IdReg)
local vtNorm1 = EgtSurfFrNormVersor(IdOutRegion)
local vtNorm2 = EgtSurfFrNormVersor(IdReg)
if AreOppositeVectorApprox( vtNorm1, vtNorm2) then
EgtInvertSurf(IdReg)
--bInvertCurve = true
end
if not EgtSurfFrSubtract( IdOutRegion,IdReg) then
CMP.ERR = 5
@@ -203,11 +199,14 @@ function TOOL.CreatePart(tbLayer, sName, tbIdEntCrv, dTh, bInLoop)
-- Se sono InLoop non devo settare
if bInLoop then
for i = 1, #tbIdEntCrv do
EgtInvertCurve(tbIdEntCrv[i])
end
--if bInvertCurve then
-- for i = 1, #tbIdEntCrv do
-- EgtInvertCurve(tbIdEntCrv[i])
-- end
--end
return
end
-- definisco spessore pezzo
if dTh then EgtSetInfo(IdPart, 'Th', dTh) end
-- INFO NECESSARIA
@@ -284,7 +283,7 @@ function TOOL.CreatePointReference( sNamePart, sNameLayer,sNameEdge, sNameRef, n
if not IdEnt then
CMP.ERR=6
CMP.MSG= CMP.MSG..' Non esiste il lato '..sNameEdge..' nel layer '..sNameLayer..' del part '..sNamePart
return
return
end
local pt = EgtSP(IdEnt, GDB_RT.GLOB)
if nTypePt == 1 then
@@ -424,21 +423,24 @@ end
function CalcDraftAngle( vtDir1, vtDir2, dPairAng1, dPairAng2, dAngBetween)
-- vengono restituiti il SideAng ( calcolato dall'angolo in 3d), i due nuovi angoli di forma per i due pezzi
-- dBeta1 è riferito al pezzo 1 e dBeta2 è riferito al pezzo 2
local dAngTilt1 = dPairAng1 - 90
local dAngTilt2 = dPairAng2 - 90
local vtN1 = Vector3d({0,100,0})
local vtN2 = Vector3d({0,100,0})
vtN1:rotate(X_AX(),dAngTilt1)
vtN2:rotate(X_AX(), dAngTilt2)
vtN2:rotate(Z_AX(), dAngBetween)
local dAngTilt1 = 180 - dPairAng1
local dAngTilt2 = 180 - dPairAng2
local vtN1 = Vector3d({0,0,100})
local vtN2 = Vector3d({0,0,100})
vtN1:rotate(vtDir1, dAngTilt1)
vtN2:rotate(vtDir2, dAngTilt2)
--vtN2:rotate(Z_AX(), dAngBetween)
local vtPerp = vtN1 ^ vtN2
local vtInters1 = vtN1 ^ vtPerp
local vtInters2 = vtPerp ^ vtN2
--local dAng3d = GetRotation(vtInters1, vtInters2, vtPerp)
local dAng3d = GetAngle(vtInters1, vtInters2)
local dBeta1 = GetAngle( vtDir1, vtPerp)
if (dPairAng2 > 90 and dBeta1 > 90) or (dPairAng2 < 90 and dBeta1 < 90) then dBeta1 = 180 - dBeta1 end
local dBeta2 = GetAngle( vtDir2, vtPerp)
local dSideAng = (180 - dAng3d) / 2
if (dPairAng1 > 90 and dBeta2 > 90) or (dPairAng1 < 90 and dBeta2 < 90) then dBeta2 = 180 - dBeta2 end
local dSideAng = 0
dSideAng = (180 - dAng3d) / 2
return dSideAng, dBeta1, dBeta2
end
@@ -519,7 +521,7 @@ function TOOL.CreateAdjustedPart( nLayOutloop, dLen, dH, dBeta1, dBeta2)
-- dLen è la lunghezza del lato su cui si va ad agganciare il pezzo che sto creando, quindi è un dato fisso
-- bisogna calcolare gli altri tre lati del quadrilatero
-- dProj1 dProj2
-- __|_____________________________|__
-- __|__ _______________________ __|__
-- \ / |
-- \ beta1 beta2 / |dH
-- \ /___________dLen__________\ / |
@@ -538,12 +540,12 @@ function TOOL.CreateAdjustedPart( nLayOutloop, dLen, dH, dBeta1, dBeta2)
local pt3 = Point3d(dLen + dProj2,dH,0)
local nLine2 = EgtLine( nLayOutloop, pt2, pt3)
EgtSetName(nLine2, "A2")
local pt4 = Point3d( dProj1,dH,0)
local pt4 = Point3d( -dProj1,dH,0)
local nLine3 = EgtLine( nLayOutloop, pt3, pt4)
EgtSetName(nLine3, "A3")
local nLine4 = EgtLine( nLayOutloop, pt4, pt1)
EgtSetName(nLine4, "A4")
TOOL.SetMachiningInfo(nLayOutloop, false)
TOOL.SetMachiningInfo(nLayOutloop)
return {nLine1, nLine2, nLine3, nLine4}
end
@@ -558,17 +560,18 @@ function TOOL.CreateCircularHole(nPart, ptCenter, dDiam)
local nInLoopLay = EgtGroup(nPart)
EgtSetName(nInLoopLay, 'InLoop')
local HoleId = EgtCircle( nInLoopLay, ptCenter, dDiam, GDB_RT.GLOB)
TOOL.SetMachiningInfo(nInLoopLay, true)
TOOL.SetMachiningInfo(nInLoopLay)
TOOL.CreatePart(TOOL.FindLayers(nPart),nil,{HoleId},nil,true)
end
function TOOL.CreateParetina(i, tbIdLoopTC, tbInfo)
function TOOL.CreateParetina(i, tbIdLoopTC, tbInfo, dPairAngCorr)
if dPairAngCorr == nil then dPairAngCorr = 0 end
local nPrev = i > 1 and i - 1 or #tbIdLoopTC
local nNext = i < #tbIdLoopTC and i + 1 or 1
local dPairAngPrev = EgtGetInfo(tbInfo.nPrev, 'PairAng', 'd') or 0
local dPairAngNext = EgtGetInfo(tbInfo.nNext, 'PairAng', 'd') or 0
local dPairAng = EgtGetInfo(tbInfo.nId, 'PairAng', 'd') or 0
local dPairAngPrev = (EgtGetInfo(tbInfo.nPrev, 'PairAng', 'd') or 0) + dPairAngCorr
local dPairAngNext = (EgtGetInfo(tbInfo.nNext, 'PairAng', 'd') or 0) + dPairAngCorr
local dPairAng = (EgtGetInfo(tbInfo.nId, 'PairAng', 'd') or 0) + dPairAngCorr
local vtDirCurr = EgtSV( tbIdLoopTC[i], GDB_RT.GLOB)
local vtDirNext = EgtSV( tbIdLoopTC[nNext], GDB_RT.GLOB)
local vtDirPrev = EgtEV( tbIdLoopTC[nPrev], GDB_RT.GLOB)
@@ -585,7 +588,8 @@ function TOOL.CreateParetina(i, tbIdLoopTC, tbInfo)
if bSameSide then
if tbInfo.nJunctionType == 3 then
local dSideAng_4, _, dBeta_DX = CalcDraftAngle( vtDirPrev, vtDirCurr, dPairAngPrev, dPairAng, PAng)
tbInfo.dAngBR = 180 - dBeta_DX
--tbInfo.dAngBR = 180 - dBeta_DX
tbInfo.dAngBR = dBeta_DX
if tbInfo.bOnLoop then dSideAng_4 = dSideAng_4 * (-1) end
if PAng < 0 then dSideAng_4 = dSideAng_4 * (-1) end
tbInfo.dSideAngR = dSideAng_4
@@ -618,7 +622,8 @@ function TOOL.CreateParetina(i, tbIdLoopTC, tbInfo)
if bSameSide then
if tbInfo.nJunctionType == 3 then
local dSideAng_2, dBeta_SX, __ = CalcDraftAngle( vtDirCurr, vtDirNext, dPairAng, dPairAngNext, NAng)
tbInfo.dAngBL = 180 - dBeta_SX
-- tbInfo.dAngBL = 180 - dBeta_SX
tbInfo.dAngBL = dBeta_SX
if tbInfo.bOnLoop then dSideAng_2 = dSideAng_2 * (-1) end
if NAng < 0 then dSideAng_2 = dSideAng_2 * (-1) end
tbInfo.dSideAngL = dSideAng_2