- generalizzate le chiamate alle funzioni e resa possibile la chiamata muta(previo riempimento delle variabili corrispondenti nella tabella globale TOOL).

This commit is contained in:
Daniele Bariletti
2025-01-21 17:28:40 +01:00
parent 369754cdd6
commit 8a3c3eca30
2 changed files with 211 additions and 132 deletions
+28 -30
View File
@@ -159,11 +159,12 @@ end
--
-- sNamePartDest deve essere il pezzo al cui lato A1 si attacca il lato A4 del pezzo Bottom
local function CreateBottomPart( tbIdLoop, sNamePartDest, nParent)
local function CreateBottomPart( tbIdLoop, nParent)
-- creo il fondo del lavello
local tbPart = {}
local Pz_Bottom = TOOL.CreatePartLayer('Bottom', sUNICode)
tbPart.sName = 'Bottom'
tbPart.sName = sUNICode..'Bottom'
local Pz_Bottom = TOOL.CreatePartLayer(tbPart.sName)
tbPart.nId = Pz_Bottom
tbPart.nParent = nParent
tbPart.dTh = CMP.SB
tbPart.sDestRefOff = '0,0,-x'
@@ -177,14 +178,13 @@ local function CreateBottomPart( tbIdLoop, sNamePartDest, nParent)
-- creo il foro
local ptCenter = EgtGP( EgtGetFirstInGroup(tbLayerBottom['Region']), GDB_RT.GLOB)
TOOL.CreateCircularHole( Pz_Bottom, ptCenter, CMP.DiamBore)
--TOOL.CreatePart(tbLayerBottom,tbPart.sName,{HoleId},tbPart.dTh,true)
-- creo i riferimenti e salvo i parametri del part
TOOL.CreateReference( sUNICode, sNamePartDest, 'OutLoop', 'A1', 'R1', tbPart.dTh, tbPart.sDestRefOff)
TOOL.CreateReference(sUNICode, tbPart.sName, 'OutLoop', 'A4', 'R4', 0, tbPart.sRefOff)
TOOL.SetPairInfo(sUNICode, tbPart.sName, 'R4', sNamePartDest, 'R1', -1, tbPart.dPairAng, 4)
TOOL.CreateReference( nParent, 'OutLoop', 'A1', 'R1', tbPart.dTh, tbPart.sDestRefOff)
TOOL.CreateReference( tbPart.nId, 'OutLoop', 'A4', 'R4', 0, tbPart.sRefOff)
TOOL.SetPairInfo( tbPart.sName, 'R4', sNamePartDest, 'R1', -1, tbPart.dPairAng, 4)
end
local function CreateSplitBottomPart( tbIdLoop, nParent, dOffset)
local function CreateSplitBottomPart( tbIdLoop, tbParent, dOffset)
-- creo il fondo diviso in un numero di pezzi pari ai lati del loop passato
local nLay = EgtGetParent(tbIdLoop[1])
local nAuxLay = EgtGroup( nLay)
@@ -201,7 +201,7 @@ local function CreateSplitBottomPart( tbIdLoop, nParent, dOffset)
local tbPart = {}
local Pz_Bottom = TOOL.CreatePartLayer('BottomA'..tostring(i), sUNICode)
if i == 1 then nFirst = Pz_Bottom end
tbPart.sName = 'BottomA'..tostring(i)
tbPart.sName = EgtGetName(Pz_Bottom)
tbPart.nId = Pz_Bottom
tbPart.nEdge = i
tbPart.nEdgeId = tbLoopOff[i]
@@ -223,6 +223,7 @@ local function CreateSplitBottomPart( tbIdLoop, nParent, dOffset)
tbSplitBottom[nFirst].nPrev = nPrev
-- scorro i part e costruisco effettivamente i pezzi in funzione del precedente e del successivo
local c = 1
for nPart, tbPart in pairs(tbSplitBottom) do
local tbLayerBottom = TOOL.FindLayers(nPart)
local bInLoop = false
@@ -231,17 +232,17 @@ local function CreateSplitBottomPart( tbIdLoop, nParent, dOffset)
-- tbPart.dAngBL = 46
-- tbPart.dAngBR = 46
local tbPartLoop = TOOL.CreateAdjustedPart( tbLayerBottom['OutLoop'],tbPart.dLen, tbPart.dH, tbPart.dAngBL, tbPart.dAngBR)
TOOL.CreatePart(tbLayerBottom,tbPart.sName,tbPartLoop,tbPart.dTh,bInLoop)
TOOL.SetMachiningInfo(tbLayerBottom['OutLoop'], false)
TOOL.CreatePart(tbLayerBottom,tbPart)
-- tbPart.dSideAngL = 8
-- tbPart.dSideAngR = 8
if tbPart.dSideAngL then TOOL.SetSideAng(tbLayerBottom['OutLoop'], 'A2', tbPart.dSideAngL) end
if tbPart.dSideAngR then TOOL.SetSideAng(tbLayerBottom['OutLoop'], 'A4', tbPart.dSideAngR) end
-- creo i riferimenti e salvo i parametri del part
local sNamePartDest = 'InPartA'..tostring(tbPart.nEdge)
TOOL.CreateReference( sUNICode, sNamePartDest, 'OutLoop', 'A1', 'R1', tbPart.dTh, tbPart.sDestRefOff)
TOOL.CreateReference(sUNICode, tbPart.sName, 'OutLoop', 'A1', 'R1', 0, tbPart.sRefOff)
TOOL.SetPairInfo(sUNICode, tbPart.sName, 'R1', sNamePartDest, 'R1', -1, tbPart.dPairAng, 4)
local nPartDestId = tbParent[c]
c = c + 1
TOOL.CreateReference( nPartDestId, 'OutLoop', 'A1', 'R1', tbPart.dTh, tbPart.sDestRefOff)
TOOL.CreateReference( tbPart.nId, 'OutLoop', 'A1', 'R1', 0, tbPart.sRefOff)
TOOL.SetPairInfo( tbPart.sName, 'R1', sNamePartDest, 'R1', -1, tbPart.dPairAng, 4)
end
EgtErase(nAuxLay)
@@ -317,11 +318,10 @@ function CMP_Draw(bPreview)
tbInfo.nPrev = nPrev
local sNamePz = 'PartA'.. tostring(i)
tbInfo.sName = sUNICode..sNamePz
local Pz_A = TOOL.CreatePartLayer(sNamePz, sUNICode)
local Pz_A = TOOL.CreatePartLayer(sNamePz)
if nPrev ~= 0 then tbPartsInfo[nPrev].nNext = Pz_A end
if i == 1 then nFirst = Pz_A end
tbInfo.nId = Pz_A
tbInfo.sName = sNamePz
local nType = EgtGetInfo(tbInfo.nEdgeId, 'AF', 'i') or 0
local dPairAng = 0
if nType == 1 then
@@ -352,12 +352,11 @@ function CMP_Draw(bPreview)
tbInfo.nEdgeId = tbIdInLoopTC[i]
tbInfo.nPrev = nPrev
local sNamePz = 'InPartA'.. tostring(i)
--tbInfo.sName = sUNICode..sNamePz
local Pz_A = TOOL.CreatePartLayer(sNamePz, sUNICode)
tbInfo.sName = sUNICode..sNamePz
local Pz_A = TOOL.CreatePartLayer(sNamePz)
if nPrev ~= 0 then tbPartsInfo[nPrev].nNext = Pz_A end
if i == 1 then nFirst = Pz_A end
tbInfo.nId = Pz_A
tbInfo.sName = sNamePz
local nType = EgtGetInfo(tbInfo.nEdgeId, 'AF', 'i') or 0
local dPairAng = 0
if nType == 1 then
@@ -434,20 +433,18 @@ function CMP_Draw(bPreview)
-- creo tutte le paretine
for nPart, tbPart in pairs( tbPartsInfo) do
EgtOutLog(tostring(nPart))
-- local nNameChar = tbPart.bInLoop and 8 or 6 -- PartA1 per pezzi costruiti sull'outloop, InPartA1 per i pezzi costruiti su un InLoop
-- local nEdge = string.sub(tbPart.sName, nNameChar) -- di "PartA1" tengo solo "1"
local nEdge = tbPart.nEdge
local tbLayer = TOOL.FindLayers(nPart)
local tbIdLoop = TOOL.CreateAdjustedPart( tbLayer['OutLoop'],tbPart.dLen, tbPart.dH, tbPart.dAngBL, tbPart.dAngBR)
TOOL.CreatePart(tbLayer['OutLoop'],tbPart)
if not tbPart.bInLoop then
TOOL.CreateReference( sUNICode, 'TopChicken', 'OutLoop', 'A'..tostring(nEdge), 'R'..tostring(nEdge), dTh_TC, tbPart.sDestRefOff)
TOOL.CreateReference(sUNICode, tbPart.sName, 'OutLoop', 'A3', 'R3', tbPart.dTh, tbPart.sRefOff)
TOOL.SetPairInfo(sUNICode, tbPart.sName, 'R3', 'TopChicken', 'R'..tostring(nEdge), -1, tbPart.dPairAng, 2)
TOOL.CreateReference( tbPart.nParent, 'OutLoop', 'A'..tostring(nEdge), 'R'..tostring(nEdge), dTh_TC, tbPart.sDestRefOff)
TOOL.CreateReference( tbPart.nId, 'OutLoop', 'A3', 'R3', tbPart.dTh, tbPart.sRefOff)
TOOL.SetPairInfo( tbPart.sName, 'R3', 'TopChicken', 'R'..tostring(nEdge), -1, tbPart.dPairAng, 2)
else
TOOL.CreateReference( sUNICode, 'TopChicken', 'InLoop', 'A'..tostring(nEdge), 'R'..tostring(nEdge+#tbIdLoopTC), dTh_TC, tbPart.sDestRefOff)
TOOL.CreateReference(sUNICode, tbPart.sName, 'OutLoop', 'A3', 'R3', tbPart.dTh, tbPart.sRefOff)
TOOL.SetPairInfo(sUNICode, tbPart.sName, 'R3', 'TopChicken', 'R'..tostring(nEdge+#tbIdLoopTC), -1, tbPart.dPairAng, 2)
TOOL.CreateReference( tbPart.nParent, 'InLoop', 'A'..tostring(nEdge), 'R'..tostring(nEdge+#tbIdLoopTC), dTh_TC, tbPart.sDestRefOff)
TOOL.CreateReference( tbPart.nId, 'OutLoop', 'A3', 'R3', tbPart.dTh, tbPart.sRefOff)
TOOL.SetPairInfo( tbPart.sName, 'R3', 'TopChicken', 'R'..tostring(nEdge+#tbIdLoopTC), -1, tbPart.dPairAng, 2)
end
if tbPart.dSideAngL then TOOL.SetSideAng(tbLayer['OutLoop'], 'A2', tbPart.dSideAngL) end
if tbPart.dSideAngR then TOOL.SetSideAng(tbLayer['OutLoop'], 'A4', tbPart.dSideAngR) end
@@ -455,11 +452,12 @@ function CMP_Draw(bPreview)
end
-- -- creo il fondo
--CreateBottomPart( tbIdInLoopTC, 'InPartA4')
-- devo ricavare "id del InPartA4" dalle info del TC
--CreateBottomPart( tbIdInLoopTC, -- id del 'InPartA4')
CreateSplitBottomPart( tbIdInLoopTC, Pz_Top, CMP.SWater)
TOOL.CreateDimensionLayer()
SetReference()
--SetReference()
--TOOL.SaveMePlease()