- correzioni e aggiunte per lo splitBottom.

This commit is contained in:
Daniele Bariletti
2025-02-06 17:51:54 +01:00
parent 56ce2b317d
commit 73abd6aa1c
+84 -23
View File
@@ -4,7 +4,7 @@
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( true)
EgtEnableDebug( false)
-------------------------------------------------------------------------------------------------------------------------
-- FUNZIONI BASE PER GENERARE I COMPO SOLID INIZIO
@@ -159,6 +159,8 @@ function TOOL.WriteDataToChildPart(tbInfo)
if tbInfo.nIn then EgtSetInfo(tbInfo.nId, "nInLoop", tbInfo.nIn) end
if tbInfo.nPrevId then EgtSetInfo(tbInfo.nId, "Prev", EgtGetName(tbInfo.nPrevId)) end
if tbInfo.nNextId then EgtSetInfo(tbInfo.nId, "Next", EgtGetName(tbInfo.nNextId)) end
if tbInfo.dSideAngR then EgtSetInfo(tbInfo.nId, "SideAngR", tbInfo.dSideAngR) end
if tbInfo.dSideAngL then EgtSetInfo(tbInfo.nId, "SideAngL", tbInfo.dSideAngL) end
end
-- CREAZIONE dei Layer di un singolo Part
@@ -738,7 +740,7 @@ function ManageJunction(dAngBetween, dTh1, dTh2, nType, dLen1, dLen2, bOnLoop)
end
end
function TOOL.CreateAdjustedPart( nLayOutloop, dLen, dH, dBeta1, dBeta2)
function TOOL.CreateAdjustedPart( tbInfo, dLenCorr)
-- genero la regione piana del rettangolo deformato :
-- 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
@@ -752,15 +754,28 @@ function TOOL.CreateAdjustedPart( nLayOutloop, dLen, dH, dBeta1, dBeta2)
-- beta 1 e beta 2 possono essere < 90 e quindi potrei avere anche un trapezio ribaltato, oppure un quasi parallelogramma
-- recupero eventuali input mancanti dalla tabella generale
if not dLen then dLen = TOOL.tbInfo.dLen end
if not dH then dH = TOOL.tbInfo.dH end
if not dBeta1 then dBeta1 = TOOL.tbInfo.dAngBL end
if not dBeta2 then dBeta2 = TOOL.tbInfo.dAngBR end
if not nLayOutloop then nLayOutloop = TOOL.tbInfo.nLayLoop end
if not tbInfo then tbInfo = TOOL.tbInfo end
local dLen = tbInfo.dLen
local dH = tbInfo.dH
local dBeta1 = tbInfo.dAngBL
local dBeta2 = tbInfo.dAngBR
local nLayOutloop = tbInfo.nLayLoop
if not dLenCorr then
dLenCorr = 0
else
dLen = dLen + dLenCorr
tbInfo.dLen = dLen
end
-- creo i lati del pezzo
local dProj1 = dH * tan( dBeta1 - 90)
local dProj2 = dH * tan( dBeta2 - 90)
-- creo i lati del pezzo -- ____
local dProj1 = dH * tan( dBeta1 - 90) -- \ /
local dProj2 = dH * tan( dBeta2 - 90) -- \/
-- /\
-- controllo che non ci sia interferenza tra il lato A2 e A4: voglio evitare eventuali clessidre: /__\
-- se una delle due proiezioni, o la loro somma, è più lunga della base inferiore devo ridurre l'altezza del pezzo
if abs(dProj1) > dLen or abs(dProj2) > dLen or (abs(dProj1) + abs(dProj2)) > dLen then
end
local pt1 = ORIG()
local pt2 = Point3d(dLen,0,0)
@@ -775,6 +790,10 @@ function TOOL.CreateAdjustedPart( nLayOutloop, dLen, dH, dBeta1, dBeta2)
local nLine4 = EgtLine( nLayOutloop, pt4, pt1, GDB_RT.GLOB)
EgtSetName(nLine4, "A4")
TOOL.SetMachiningInfo(nLayOutloop)
-- setto le info dei side ang
if tbInfo.dSideAngL then TOOL.SetSideAng(tbInfo.nLayLoop, 'A2', tbInfo.dSideAngL) end
if tbInfo.dSideAngR then TOOL.SetSideAng(tbInfo.nLayLoop, 'A4', tbInfo.dSideAngR) end
return {nLine1, nLine2, nLine3, nLine4}
end
@@ -938,10 +957,11 @@ local function CreateSplitBottomPart(tbInfo, i, tbIdEdges, ptCenter, nPrev, nFir
tbInfo.sDestRefOff = '0,0,-x'
tbInfo.sRefOff = '0,0,0'
tbInfo.dPairAng = 90 - TOOL.dSlopeAng
tbInfo.nPairSpin = -1
tbInfo.nJunctionType = 3
tbInfo.bOnLoop = true
tbInfo.bInsideLoop = false -- questo mi richiederà di prendere il complementare del side ang che risulta dal calcDraftAng
local dThParent = EgtGetInfo(tb.Info.nParent, "Th", "d") or 0
local dThParent = EgtGetInfo(tbInfo.nParent, "Th", "d") or 0
tbInfo.dH = ((EgtPointCurveDist( ptCenter, tbInfo.nEdgeId, GDB_RT.GLOB) - TOOL.dDiamBore) + dThParent) / cos(TOOL.dSlopeAng)
else
-- se esisteva già ripulisco i layer della regione e del loop ed elimino il solido
@@ -954,14 +974,45 @@ local function CreateSplitBottomPart(tbInfo, i, tbIdEdges, ptCenter, nPrev, nFir
end
-- creo il fondo come paretina
local tbLayerBottom = TOOL.FindLayers(tbInfo.nId)
tbInfo.nLayLoop = tbLayerBottom['OutLoop']
-- da qui mi serve che tbInfo.nEdge indichi quale lato del loop ausiliario sta generando il part corrente(e non sia più riferito al lato del parent)
tbInfo.nEdge = i
TOOL.CreateParetina( tbInfo.nEdgeId, tbInfo, 90)
TOOL.CreateAdjustedPart( tbLayerBottom['OutLoop'],tbInfo.dLen, tbInfo.dH, tbInfo.dAngBL, tbInfo.dAngBR)
local dLenCorr = 0
local dThParent = EgtGetInfo(tbInfo.nParent, "Th", "d")
if not tbInfo.bInsideLoop then
--tbInfo.dSideAngL = - tbInfo.dSideAngL
--tbInfo.dSideAngR = - tbInfo.dSideAngR
local nParentJunctionType = EgtGetInfo(tbInfo.nParent, "JunctionType","i")
if nParentJunctionType == 3 then
local dSideAngR = EgtGetInfo(tbInfo.nParent, "SideAngR", "d")
local dSideAngL = EgtGetInfo(tbInfo.nParent, "SideAngL", "d")
dLenCorr = dThParent*( tan(dSideAngR) + tan(dSideAngL))
tbInfo.nPairMode = 4
elseif nParentJunctionType == 1 then
-- devo recuperare lo spessore del pezzo precedente
-- se le paretine parent sono inclinate dovrò aggiustare lo spessore
local nIdPrev = EgtGetFirstNameInGroup(GDB_ID.ROOT, EgtGetInfo(tbInfo.nParent, "Prev"))
local dThPrev = EgtGetInfo(nIdPrev, "Th", "d")
dLenCorr = dThPrev
tbInfo.sDestRefOff = tostring(dThPrev)..",0,-x"
tbInfo.nPairMode = 2
elseif nParentJunctionType == 2 then
-- devo recuperare lo spessore del pezzo successivo
-- se le paretine parent sono inclinate dovrò aggiustare lo spessore
local nIdNext = EgtGetFirstNameInGroup(GDB_ID.ROOT, EgtGetInfo(tbInfo.nParent, "Next"))
local dThNext = EgtGetInfo(nIdNext, "Th", "d")
dLenCorr = dThNext
tbInfo.sDestRefOff = tostring(-dThNext)..",0,-x"
tbInfo.nPairMode = 1
end
end
if i == 2 or i == 4 then
tbInfo.dH = 134.5859034533108
end
TOOL.CreateAdjustedPart( tbInfo, dLenCorr)
TOOL.CreatePart(tbLayerBottom['OutLoop'],tbInfo)
if tbInfo.dSideAngL then TOOL.SetSideAng(tbLayerBottom['OutLoop'], 'A2', tbInfo.dSideAngL) end
if tbInfo.dSideAngR then TOOL.SetSideAng(tbLayerBottom['OutLoop'], 'A4', tbInfo.dSideAngR) end
-- creo i riferimenti e salvo i parametri del part
local nIdToRef = TOOL.CreateReference( tbInfo.nParent, 'OutLoop', 'A3', nil, tbInfo.dTh, tbInfo.sDestRefOff, tbInfo.sName)
local nMyRef = TOOL.CreateReference( tbInfo.nId, 'OutLoop', 'A1', nil, 0, tbInfo.sRefOff)
@@ -969,25 +1020,35 @@ local function CreateSplitBottomPart(tbInfo, i, tbIdEdges, ptCenter, nPrev, nFir
TOOL.SetPairInfo( tbInfo, nMyRef, sNamePartDest, nIdToRef, -1)
-- creo il solido e lo accoppio
if SLD then
SLD.CurrId = TOOL.tbInfo.nId
SLD.CurrId = tbInfo.nId
SLD.Main()
end
-- debug
TOOL.SaveMePlease()
-- debug
if ASS then
ASS.nVeinCtx = EgtGetContext()
ASS.nPartId = TOOL.tbInfo.nId
ASS.nPartId = tbInfo.nId
ASS.PairSingle()
end
-- debug
TOOL.SaveMePlease()
-- debug
return Pz_Bottom
end
function TOOL.CreateSplitBottom( tbIdEdges, dOffset)
-- raccolgo e/o ricostruisco i dati in input
if not tbIdEdges then tbIdEdges = TOOL.tbIdEdges end -- tabella che contiene gli edge da cui voglio creare il fondello
-- riordino gli edge in modo che il primo lato sia il lato lungo del rettangolo
local dLen1 = EgtCurveLength(tbIdEdges[1])
local dLen2 = EgtCurveLength(tbIdEdges[2])
if dLen1 < dLen2 + 0.001 then
-- sposto il primo elemento in fondo alla tabella
table.insert(tbIdEdges, tbIdEdges[1])
table.remove(tbIdEdges, 1)
end
local tbParent = {}
for _, nEdgeId in pairs(tbIdEdges) do
table.insert(tbParent, EgtGetParent(EgtGetParent(nEdgeId)))
@@ -1038,7 +1099,7 @@ function TOOL.CreateSplitBottom( tbIdEdges, dOffset)
end
-- pulisco la tabella con i dati
TOOL.tbInfo = {}
tbInfo = {}
end
TOOL.SaveMePlease()