- 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
+183 -102
View File
@@ -4,7 +4,7 @@
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
EgtEnableDebug( true)
-------------------------------------------------------------------------------------------------------------------------
-- FUNZIONI BASE PER GENERARE I COMPO SOLID INIZIO
@@ -14,31 +14,40 @@ local TOOL = {}
_G.TOOL = TOOL
TOOL.nId = GDB_ID.NULL
TOOL.nLay = GDB_ID.NULL
TOOL.nEdgeId = GDB_ID.NULL
TOOL.tbInfo = {}
TOOL.nParent = GDB_ID.NULL
TOOL.nPrev = GDB_ID.NULL
TOOL.nNext = GDB_ID.NULL
TOOL.dPairAng = nil
TOOL.nJunctionType = nil
TOOL.bOnLoop = nil
TOOL.dAngBR = nil
TOOL.dSideAngR = nil
TOOL.dAngBL = nil
TOOL.dSideAngL = nil
TOOL.dLen = nil
TOOL.dH = nil
TOOL.dXOffset = nil
TOOL.dBeta1 = nil
TOOL.dBeta2 = nil
TOOL.sName = ""
TOOL.bPrev = nil
TOOL.bNext = nil
TOOL.nId = nil -- id del part della paretina che si sta costruendo
TOOL.nOutLayParent = nil -- layer contenente il loop da cui si sta creando la paretina (appartenente al parent)
TOOL.nOutLay = nil -- layer dell'outloop del nuovo part in creazione
TOOL.nEdgeId = nil -- indice dell'edge che si sta usando per creare la paretina
TOOL.nEdge = nil -- numero ordinale (1-based, per poterlo usare direttamente per trovare il lato "A1") per l'edge nel layer del loop
TOOL.tbInfo = {} -- tabella contenente tutte le informazioni del part corrente
TOOL.nParent = nil -- id del parent
TOOL.nPrevId = nil -- id della paretina precedente alla corrente
TOOL.nNextId = nil -- id della paretina successiva alla corrente
TOOL.nPrev = nil -- numero ordinale della paretina precedente alla corrente
TOOL.nNext = nil -- numero ordinale della paretina successiva alla corrente
TOOL.dPairAng = nil -- angolo di accoppiamento
TOOL.nJunctionType = nil -- tipo di giunzione tra paretine: 1 trim start, 2 trim end, 3 giunzione angolata
TOOL.bOnLoop = nil -- flag che indica se la faccia buona è adiacente al lato del parent generatore della paretina corrente
TOOL.dAngBR = nil -- angolo BottomRight della faccia buona della paretina corrente
TOOL.dSideAngR = nil -- SideAng del lato Right(A2) (il primo lato è il bottom e si procede CCW)
TOOL.dAngBL = nil -- angolo BottomLeft della faccia buona della paretina corrente
TOOL.dSideAngL = nil -- SideAng del lato Left(A4) (il primo lato è il bottom e si procede CCW)
TOOL.dLen = nil -- lunghezza del lato del parent generatore della paretina corrente
TOOL.dH = nil -- altezza della faccia buona della paretina corrente
TOOL.dTh = nil -- spessore del part corrente
TOOL.dThParent = nil -- spessore del parent
TOOL.dXOffset = nil -- offset del riferimento
-- TOOL.dBeta1 = nil
-- TOOL.dBeta2 = nil
TOOL.sName = nil -- nome del part corrente, incluso il codice univoco(es: sUNICode.."PartA1")
TOOL.bPrev = nil -- booleano che indica se modificare anche la paretina successiva, in conseguenza delle modifica a quella corrente
TOOL.bNext = nil -- booleano che indica se modificare anche la paretina precedente, in conseguenza delle modifica a quella corrente
TOOL.tbIdLoop = {} -- tabella con gli id del loop su cui sta venendo costruita la paretina
-- creo il codice univoco per l'identificazione dei part
TOOL.sUNICode = os.date( '%y%m%d%H%M%S', os.time()).."_"
local sUNICode = TOOL.sUNICode
function TOOL.SaveMePlease()
EgtSaveFile('D:\\Temp\\marmo\\Vein3D\\FOO.nge')
@@ -51,7 +60,7 @@ local function FindEdges(nLay, tbInfo)
local nId = EgtGetFirstInGroup(nLay)
local c = 1
while nId do
if tbInfo.nEdgeId ~= GDB_ID.NULL and tbInfo.nEdgeId then
if tbInfo and tbInfo.nEdgeId ~= GDB_ID.NULL and tbInfo.nEdgeId then
if nId == tbInfo.nEdgeId then tbInfo.nEdge = c end
end
table.insert(tbId, nId)
@@ -62,29 +71,36 @@ local function FindEdges(nLay, tbInfo)
end
local function FillInfoTable()
TOOL.tbInfo.nId = TOOL.nId
TOOL.tbInfo.nEdgeId = TOOL.nEdgeId
TOOL.tbInfo.nParent = TOOL.nParent
TOOL.tbInfo.nPrev = TOOL.nPrev
TOOL.tbInfo.nNext = TOOL.nNext
TOOL.tbInfo.nJunctionType = TOOL.nJunctionType
TOOL.tbInfo.bOnLoop = TOOL.bOnLoop
TOOL.tbInfo.dAngBR = TOOL.dAngBR
TOOL.tbInfo.dSideAngR = TOOL.dSideAngR
TOOL.tbInfo.dAngBL = TOOL.dAngBL
TOOL.tbInfo.dSideAngL = TOOL.dSideAngL
TOOL.tbInfo.dLen = TOOL.dLen
TOOL.tbInfo.dTh = TOOL.dTh
TOOL.tbInfo.dH = TOOL.dH
TOOL.tbInfo.dBeta1 = TOOL.dBeta1
TOOL.tbInfo.dBeta2 = TOOL.dBeta2
if TOOL.nId then TOOL.tbInfo.nId = TOOL.nId end
if TOOL.nEdgeId then TOOL.tbInfo.nEdgeId = TOOL.nEdgeId end
if TOOL.nOutLayParent then TOOL.tbInfo.nOutLayParent = TOOL.nOutLayParent end
if (not TOOL.tbInfo.nOutLayParent or TOOL.tbInfo.nOutLayParent == GDB_ID.NULL) and TOOL.nEdgeId and TOOL.nEdgeId ~= GDB_ID.NULL then EgtGetParent( TOOL.nEdgeId) end
if TOOL.nParent then TOOL.tbInfo.nParent = TOOL.nParent end
if (not TOOL.tbInfo.nParent or TOOL.tbInfo.nParent == GDB_ID.NULL) and TOOL.nEdgeId and TOOL.nEdgeId ~= GDB_ID.NULL then EgtGetParent(EgtGetParent( TOOL.nEdgeId)) end
if TOOL.nPrevId then TOOL.tbInfo.nPrevId = TOOL.nPrevId end
if TOOL.nNextId then TOOL.tbInfo.nNextId = TOOL.nNextId end
if TOOL.nJunctionType then TOOL.tbInfo.nJunctionType = TOOL.nJunctionType end
if TOOL.bOnLoop then TOOL.tbInfo.bOnLoop = TOOL.bOnLoop end
if TOOL.dAngBR then TOOL.tbInfo.dAngBR = TOOL.dAngBR end
if TOOL.dSideAngR then TOOL.tbInfo.dSideAngR = TOOL.dSideAngR end
if TOOL.dAngBL then TOOL.tbInfo.dAngBL = TOOL.dAngBL end
if TOOL.dSideAngL then TOOL.tbInfo.dSideAngL = TOOL.dSideAngL end
if TOOL.dLen then TOOL.tbInfo.dLen = TOOL.dLen end
if TOOL.dTh then TOOL.tbInfo.dTh = TOOL.dTh end
if TOOL.dH then TOOL.tbInfo.dH = TOOL.dH end
if TOOL.dPairAng then TOOL.tbInfo.dPairAng = TOOL.dPairAng end
if TOOL.bOnLoop then TOOL.tbInfo.bOnLoop = TOOL.bOnLoop end
-- if TOOL.dBeta1 then TOOL.tbInfo.dBeta1 = TOOL.dBeta1 end
-- if TOOL.dBeta2 then TOOL.tbInfo.dBeta2 = TOOL.dBeta2 end
if TOOL.sName then TOOL.tbInfo.sName = TOOL.sName end
end
local function FillInfoTableFromPart(nPartId)
TOOL.tbInfo.nId =nPartId
TOOL.tbInfo.nPrev = EgtGetInfo(nPartId,"Prev", "i")
TOOL.tbInfo.nNext = EgtGetInfo(nPartId,"Next", "i")
if not nPartId or nPartId == GDB_ID.NULL then return end
TOOL.tbInfo.nId = nPartId
if TOOL.nOutLayParent and TOOL.nOutLayParent ~= GDB_ID.NULL then TOOL.tbInfo.nOutLayParent = TOOL.nOutLayParent end
TOOL.tbInfo.nPrevId = EgtGetInfo(nPartId,"Prev", "i")
TOOL.tbInfo.nNextId = EgtGetInfo(nPartId,"Next", "i")
TOOL.tbInfo.nJunctionType = EgtGetInfo(nPartId,"JunctionType", "i")
TOOL.tbInfo.bOnLoop = EgtGetInfo(nPartId,"OnLoop", "b")
TOOL.tbInfo.dAngBR = EgtGetInfo(nPartId,"AngBR", "d")
@@ -93,28 +109,28 @@ local function FillInfoTableFromPart(nPartId)
TOOL.tbInfo.dSideAngL = EgtGetInfo(nPartId,"SideAngL", "d")
TOOL.tbInfo.dLen = EgtGetInfo(nPartId,"Len", "d")
TOOL.tbInfo.dH = EgtGetInfo(nPartId,"H", "d")
TOOL.tbInfo.dBeta1 = EgtGetInfo(nPartId,"Beta1", "d")
TOOL.tbInfo.dBeta2 = EgtGetInfo(nPartId,"Beta2", "d")
-- TOOL.tbInfo.dBeta1 = EgtGetInfo(nPartId,"Beta1", "d")
-- TOOL.tbInfo.dBeta2 = EgtGetInfo(nPartId,"Beta2", "d")
end
function TOOL.WriteDataToChildPart(tbInfo)
if not tbInfo or not tbInfo.nPart then do return end end
if tbInfo.nParent then EgtSetInfo(nParent,"A"..tostring(nEdge), tbInfo.nPart) end
if tbInfo.nParent then EgtSetInfo(nPart, 'Parent', tbInfo.nParent) end
if tbInfo.nEdge then EgtSetInfo(nPart, 'ParentEdge', tbInfo.nEdge) end
if tbInfo.dLen then EgtSetInfo(nPart, 'Len', tbInfo.dLen) end
if tbInfo.dAngDx then EgtSetInfo(nPart, 'AngDx', tbInfo.dAngDx) end
if tbInfo.dAgnSx then EgtSetInfo(nPart, 'AngSx', tbInfo.dAngSx) end
if tbInfo.dH then EgtSetInfo(nPart, 'H', tbInfo.dH) end
if tbInfo.dTh then EgtSetInfo(nPart, 'Th', tbInfo.dTh) end
if tbInfo.dBeta1 then EgtSetInfo(nPart, 'Beta1', tbInfo.dBeta1) end
if tbInfo.dBeta2 then EgtSetInfo(nPart, 'Beta2', tbInfo.dBeta2) end
if tbInfo.nJunctionType then EgtSetInfo(nPart, 'Beta2', tbInfo.dBeta2) end
if not tbInfo or not tbInfo.nId then do return end end
if tbInfo.nParent then EgtSetInfo(tbInfo.nParent,"A"..tostring(tbInfo.nEdge), tbInfo.nId) end
if tbInfo.nParent then EgtSetInfo(tbInfo.nId, 'Parent', tbInfo.nParent) end
if tbInfo.nEdge then EgtSetInfo(tbInfo.nId, 'ParentEdge', tbInfo.nEdge) end
if tbInfo.dLen then EgtSetInfo(tbInfo.nId, 'Len', tbInfo.dLen) end
if tbInfo.dAngDx then EgtSetInfo(tbInfo.nId, 'AngDx', tbInfo.dAngDx) end
if tbInfo.dAgnSx then EgtSetInfo(tbInfo.nId, 'AngSx', tbInfo.dAngSx) end
if tbInfo.dH then EgtSetInfo(tbInfo.nId, 'H', tbInfo.dH) end
if tbInfo.dTh then EgtSetInfo(tbInfo.nId, 'Th', tbInfo.dTh) end
-- if tbInfo.dBeta1 then EgtSetInfo(tbInfo.nId, 'Beta1', tbInfo.dBeta1) end
-- if tbInfo.dBeta2 then EgtSetInfo(tbInfo.nId, 'Beta2', tbInfo.dBeta2) end
if tbInfo.nJunctionType then EgtSetInfo(tbInfo.nId, 'JunctionType', tbInfo.nJunctionType) end
end
-- CREAZIONE dei Layer di un singolo Part
-- I nomi dei layer sono: OutLoop, Region, Ref, Labels, Aux
function TOOL.CreatePartLayer(PartName, sUNICode)
function TOOL.CreatePartLayer(PartName)
-- Pezzo e Layer
local Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- pezzo
EgtSetName( Pz, sUNICode..PartName)
@@ -292,20 +308,25 @@ local HorizontalOffset = 0
-- dTh : spessore pezzo
-- dOffset : per messa in piano dei pezzi (0 se non si usa)
-- bInLoop : tipo di contorno
function TOOL.CreatePart(nLayLoop, tbPart)
function TOOL.CreatePart(nLayLoop, tbPart, bIsPlanar)
if bIsPlanar == nil then bIsPlanar = false end
-- se mancano le variabili di input le recupero dalla tabella generale
if not nLayLoop then nLayLoop = TOOL.nLay end
if not nLayLoop then
if TOOL.nLay then nLayLoop = TOOL.nLay end
if TOOL.tbInfo.nOutLay then nLayLoop = TOOL.tbInfo.nOutLay end
end
if not tbPart then tbPart = TOOL.tbInfo end
-- recupero l'Id del part
local tbIdEntCrv = FindEdges(nLayLoop)
local IdPart = EgtGetParent( nLayLoop)
local tbLayer = TOOL.FindLayers(IdPart)
local sPartName = EgtGetName(IdPart)
local tbPartName = EgtSplitString(sPartName,"_")
local sName = tbPartName[2]
-- local sPartName = EgtGetName(IdPart)
-- local tbPartName = EgtSplitString(sPartName,"_")
-- local sName = tbPartName[2]
-- costruisco il contorno chiuso
local IdLoop = EgtCurveCompoByChain( IdCurrLayer, tbIdEntCrv, EgtSP(tbIdEntCrv[1],GDB_RT.GLOB), false, GDB_RT.GLOB)
local IdLoop = EgtCurveCompoByChain( nLayLoop, tbIdEntCrv, EgtSP(tbIdEntCrv[1],GDB_RT.GLOB), false, GDB_RT.GLOB)
-- Nel Layer Region definisco la regione piana
local IdReg = EgtSurfFlatRegion(tbLayer['Region'],IdLoop)
-- elimino il contorno chiuso
@@ -319,10 +340,13 @@ function TOOL.CreatePart(nLayLoop, tbPart)
-- inserisco le etichette del pezzo nel centro della superofocie
local ptTop = EgtCP( IdReg, GDB_RT.GLOB)
local ptBottom = Point3d( ptTop:getX(), -ptTop:getY(), tbPart.dTh)
EgtTextAdv(tbLayer['Labels'], ptTop,0,sName, '', 10, '', 15,1.5,0,GDB_TI.MC)
if CMP.DrawSolid then
local tbNamePart = EgtSplitString(tbPart.sName, "_")
-- al nome del part tolgo il codice univoco
local sNamePart = tbNamePart[2]
EgtTextAdv(tbLayer['Labels'], ptTop,0,sNamePart, '', 10, '', 15,1.5,0,GDB_TI.MC)
if not bIsPlanar then
EgtSetGridFrame(Frame3d(ORIG(),GDB_FR.BOTTOM))
EgtTextAdv(tbLayer['Labels'], ptBottom,0,sName, '', 10, '', 15,1.5,0,GDB_TI.MC, GDB_RT.GRID)
EgtTextAdv(tbLayer['Labels'], ptBottom,0,sNamePart, '', 10, '', 15,1.5,0,GDB_TI.MC, GDB_RT.GRID)
EgtSetGridFrame(Frame3d(ORIG(),GDB_FR.TOP))
end
-- dispongo il pezzo in piano
@@ -347,13 +371,11 @@ end
--
-- Crea una copia dello spigolo e lo salva nel layer Ref
-- Nome del part (da tbName[1]),
-- Nome del Layer (OutLoop o InLoop),
-- Nome dello spigolo,
-- Nome della copia riferimento
-- Info per spostamento Ref in funzione di una variabile
function TOOL.CreateReference( sUNICode, sNamePart, sNameLayer,sNameEdge, sNameRef, dVar, sDir)
local IdPart = EgtGetFirstNameInGroup(GDB_ID.ROOT, sUNICode..sNamePart)
function TOOL.CreateReference( IdPart, sNameLayer,sNameEdge, sNameRef, dVar, sDir)
local tbLayer = TOOL.FindLayers( IdPart)
--accoppiamento di left su bottom
local IdEnt = EgtGetFirstNameInGroup(tbLayer[sNameLayer], sNameEdge)
@@ -380,7 +402,7 @@ end
-- Nome della copia punto
-- Tipo di punto: 0/nil START, 1 END, 2 MID
function TOOL.CreatePointReference( sNamePart, sNameLayer,sNameEdge, sNameRef, nTypePt)
local IdPart = EgtGetFirstNameInGroup(GDB_ID.ROOT, sUNICode..sNamePart)
local IdPart = EgtGetFirstNameInGroup(GDB_ID.ROOT, sNamePart)
local tbLayer = TOOL.FindLayers( IdPart)
--accoppiamento di left su bottom
local IdEnt = EgtGetFirstNameInGroup(tbLayer[sNameLayer], sNameEdge)
@@ -410,10 +432,10 @@ end
-- Angolo relativo tra i due pezzi: porta la normale della regione del pezzo corrente a coincidere
-- con la normale della regione del pezzo destinatario; il segno è riferito al verso del riferimento del part destinatario
-- Modalità di accoppiamento tra gli spigoli (0: start-start, 1:start-end, 2: end-start, 3: end-end, 4: mid-mid)
function TOOL.SetPairInfo( sUNICode, sMyNamePart, sNameMyRef, sToNamePart, sNameToRef, nPairSpin, dPairAng, nPairMode)
local nPart = EgtGetFirstNameInGroup(GDB_ID.ROOT, sUNICode..sMyNamePart)
function TOOL.SetPairInfo( sMyNamePart, sNameMyRef, sToNamePart, sNameToRef, nPairSpin, dPairAng, nPairMode)
local nPart = EgtGetFirstNameInGroup(GDB_ID.ROOT, sMyNamePart)
EgtSetInfo(nPart, "PairMyRef", sNameMyRef)
EgtSetInfo(nPart, "PairToRef", sUNICode..sToNamePart.."_"..sNameToRef)
EgtSetInfo(nPart, "PairToRef", sToNamePart.."_"..sNameToRef)
EgtSetInfo(nPart, "PairSpin", nPairSpin)
EgtSetInfo(nPart, "PairAng", dPairAng)
if nPairMode then EgtSetInfo(nPart, "PairMode", nPairMode) end
@@ -430,11 +452,11 @@ end
local function DrawLinearDimension( sNamePart1, sNameRef1, sNamePart2, sNameRef2, sNameDimension, GridFrame, ptOffset)
EgtSetGridFrame(GridFrame)
local nDimLay = EgtGetFirstNameInGroup(GDB_ID.ROOT, 'Dimensions')
local nBottomLay = EgtGetFirstNameInGroup(GDB_ID.ROOT, sUNICode..sNamePart1)
local nBottomLay = EgtGetFirstNameInGroup(GDB_ID.ROOT, sNamePart1)
local nRefBottom = EgtGetFirstNameInGroup(nBottomLay, 'Ref')
local nRef = EgtGetFirstNameInGroup(nRefBottom, sNameRef1)
local pt1 = EgtSP( nRef, GDB_RT.GRID)
local nTopLay = EgtGetFirstNameInGroup(GDB_ID.ROOT, sUNICode..sNamePart2)
local nTopLay = EgtGetFirstNameInGroup(GDB_ID.ROOT, sNamePart2)
local nRefTop = EgtGetFirstNameInGroup(nTopLay, 'Ref')
nRef = EgtGetFirstNameInGroup(nRefTop, sNameRef2)
local pt2 = EgtSP( nRef, GDB_RT.GRID)
@@ -639,14 +661,13 @@ 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.dLen end
if not dH then dH = TOOL.dH end
if not dBeta1 then dBeta1 = TOOL.dBeta1 end
if not dBeta2 then dBeta2 = TOOL.dBeta2 end
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.nOutLay end
-- creo i lati del pezzo
if dBeta1 == nil then dBeta1 = 90 end
if dBeta2 == nil then dBeta2 = 90 end
local dProj1 = dH * tan( dBeta1 - 90)
local dProj2 = dH * tan( dBeta2 - 90)
@@ -684,22 +705,22 @@ end
--function TOOL.CreateParetina(i, tbIdLoopTC, tbInfo, dPairAngCorr)
function TOOL.CreateParetina(nEdgeId, tbInfo, dPairAngCorr)
-- se non ho ricevuto input li recupero dalla tabella generale
if not nEdgeId then nEdgeId = TOOL.nEdgeId end
local tbIdLoopTC = {}
if not tbInfo then
FillInfoTable()
tbInfo = TOOL.tbInfo
tbIdLoopTC = TOOL.tbIdLoop
end
local nLay = EgtGetParent(nEdgeId)
local tbIdLoopTC = FindEdges(nLay, tbInfo) -- tabella che contiene gli id degli Edge del loop
-- local nId = EgtGetFirstInGroup(nLay)
if not tbInfo.nEdge and nEdgeId then
tbIdLoopTC = FindEdges(EgtGetParent(nEdgeId), tbInfo)
end
if #tbIdLoopTC == 0 then return end
local i = tbInfo.nEdge -- posizione del lato nel layer del loop
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
if not tbInfo.nPrevId then tbInfo.nPrevId = GDB_ID.NULL end
local dPairAngPrev = (EgtGetInfo(tbInfo.nPrev, 'PairAng', 'd') or 0) + dPairAngCorr
if not tbInfo.nNextId then tbInfo.nNextId = GDB_ID.NULL end
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)
@@ -739,6 +760,7 @@ function TOOL.CreateParetina(nEdgeId, tbInfo, dPairAngCorr)
local dSideAng = PrevAng < 0 and (90 + PrevAng) or 90-PrevAng
if tbInfo.bOnLoop then dSideAng = dSideAng * (-1) end
tbInfo.dSideAngR = dSideAng
tbInfo.dAngBR = 90
-- visto che il pezzo precedente non è dallo stesso lato allora corrego l'estensione del pezzo corrente (in funzione del suo spessore)
if not tbInfo.bOnLoop then
local dOffset = dTh * tan( 90 - PrevAng)
@@ -772,6 +794,7 @@ function TOOL.CreateParetina(nEdgeId, tbInfo, dPairAngCorr)
local dSideAng = NextAng < 0 and (90 + NextAng) or 90-NextAng
if tbInfo.bOnLoop then dSideAng = dSideAng * (-1) end
tbInfo.dSideAngL = dSideAng
tbInfo.dAngBL = 90
-- visto che il pezzo successivo non è dallo stesso lato allora correggo l'estensione del pezzo corrente (in funzione del suo spessore)
if not tbInfo.bOnLoop then
local dOffset = dTh * tan( 90 - NextAng)
@@ -797,12 +820,31 @@ end
-- end
local function UpdateNeighInfo()
if not TOOL.nLay or TOOL.nLay == GDB_ID.NULL then TOOL.nLay = EgtGetParent(TOOL.nEdgeId) end
-- al precedente setto il curr come Next
local sNamePrev = "A"..tostring(nPrev)
local nPrevId = EgtGetInfo(TOOL.tbInfo.nParent, sNamePrev, "i")
if nPrevId then EgtSetInfo(nPrevId, "Next", TOOL.tbInfo.nId) end
-- al successivo setto il curr come Prev
local sNameNext = "A"..tostring(nNext)
local nNextId = EgtGetInfo(TOOL.tbInfo.nParent, sNameNext, "i")
if nNextId then EgtSetInfo(nNextId, "Prev", TOOL.tbInfo.nId) end
end
function TOOL.CreateParetinaFull(bPrev, bNext)
if bPrev == nil then bPrev = TOOL.bPrev end
if bNext == nil then bNext = TOOL.bNext end
-- recupero tutte le info che mi servono (che vengono messe in TOOL.tbInfo)
FillInfoTable()
-- se non ho ricevuto input li recupero dalla tabella generale
if not TOOL.nEdgeId or TOOL.nEdgeId == GDB_ID.NULL then return end
TOOL.nLay = EgtGetParent(TOOL.nEdgeId)
TOOL.tbInfo.nEdgeId = TOOL.nEdgeId
TOOL.tbIdLoop = FindEdges(TOOL.nLay, TOOL.tbInfo) -- tabella che contiene gli id degli Edge del loop
if #TOOL.tbInfo == 0 then
-- recupero tutte le info che mi servono (che vengono messe in TOOL.tbInfo)
FillInfoTable()
end
-- controllo se nelle info del parent se era già stato creato il part associato a quel lato
local sEdgeName = EgtGetName(TOOL.tbInfo.nEdgeId)
@@ -814,35 +856,74 @@ function TOOL.CreateParetinaFull(bPrev, bNext)
-- se il part non esiste, lo creo
local sPrefix = EgtGetName(EgtGetParent(TOOL.tbInfo.nEdgeId)) == "OutLoop" and "Part" or "InPart"
local sPartname = sPrefix..sEdgeName
TOOL.CreatePartLayer(sPartname, TOOL.sUNICode)
TOOL.tbInfo.nId = TOOL.CreatePartLayer(sPartname)
UpdateNeighInfo()
else
-- se esisteva già ripulisco i layer della regione e del loop ed elimino il solido
ClearPart(nChildPart)
TOOL.tbInfo.nId = nChildPart
end
TOOL.tbInfo.sName = EgtGetName(TOOL.tbInfo.nId)
local tbLayers = TOOL.FindLayers(TOOL.tbInfo.nId)
TOOL.tbInfo.nOutLay = tbLayers["OutLoop"]
-- verifico se esistono dei vicini da modificare dopo la creazione di questo pezzo
local nEdges = EgtGetGroupObjs(TOOL.nLay)
local nPrev = TOOL.tbInfo.nEdge > 1 and TOOL.tbInfo.nEdge - 1 or nEdges -- numero ordinale della paretina precedente alla corrente
TOOL.tbInfo.nPrevId = EgtGetInfo(TOOL.tbInfo.nParent, "A"..tostring(nPrev), "i") -- id del part della paretina precedente alla corrente
local nNext = TOOL.tbInfo.nEdge == nEdges and 1 or TOOL.tbInfo.nEdge + 1
TOOL.tbInfo.nNextId = EgtGetInfo(TOOL.tbInfo.nParent, "A"..tostring(nNext), "i")
TOOL.CreateParetina()
TOOL.CreateAdjustedPart()
TOOL.CreatePart()
-- setto i sideAng
if TOOL.tbInfo.dSideAngL then TOOL.SetSideAng(tbLayers['OutLoop'], 'A2', TOOL.tbInfo.dSideAngL) end
if TOOL.tbInfo.dSideAngR then TOOL.SetSideAng(tbLayers['OutLoop'], 'A4', TOOL.tbInfo.dSideAngR) end
-- creo i riferimenti e salvo i parametri del part
local sNamePartDest = EgtGetName(TOOL.tbInfo.nParent)
local sEdgeDest = EgtGetName(TOOL.tbInfo.nEdgeId)
local sRefDest = "R"..string.sub(sEdgeDest, 2)
local sLayEdgeDest = EgtGetName(EgtGetParent(TOOL.tbInfo.nEdgeId))
if TOOL.tbInfo.bOnLoop then
-- waterfall
TOOL.tbInfo.dSideAngT = TOOL.dPairAng + 90
TOOL.tbInfo.dYOffset = TOOL.tbInfo.dTh * tan(TOOL.tbInfo.dSideAngT)
TOOL.tbInfo.sDestRefOff = '0,0,-x'
TOOL.tbInfo.sRefOff = '0,'..tostring(TOOL.tbInfo.dYOffset)..',0'
else
-- splashtop
TOOL.tbInfo.dSideAngT = TOOL.dPairAng - 90
TOOL.tbInfo.dYOffset = TOOL.tbInfo.dTh * tan(TOOL.tbInfo.dSideAngT)
TOOL.tbInfo.sDestRefOff = '0,0,0'
TOOL.tbInfo.sRefOff = tostring(TOOL.tbInfo.dXOffset)..','..tostring(TOOL.tbInfo.dYOffset)..',-x'
end
TOOL.tbInfo.dThParent = EgtGetInfo(TOOL.tbInfo.nParent, "Th", "d")
TOOL.CreateReference( TOOL.tbInfo.nParent, sLayEdgeDest, sEdgeDest, sRefDest, TOOL.tbInfo.dThParent, TOOL.tbInfo.sDestRefOff)
TOOL.CreateReference( TOOL.tbInfo.nId, 'OutLoop', 'A1', 'R1', TOOL.tbInfo.dTh, TOOL.tbInfo.sRefOff)
TOOL.SetPairInfo( TOOL.tbInfo.sName, 'R1', sNamePartDest, sRefDest, -1, TOOL.tbInfo.dPairAng, 4)
-- devo modificare anche la paretina precedente e la successiva
-- modifico anche la paretina precedente(se esiste)
local nNext = tbInfo.nNext
local nCurr = tbInfo.nId
FillInfoTableFromPart(tbInfo.nPrev)
if bPrev then TOOL.CreateParetinaFull(false, false) end
local nNextId = TOOL.tbInfo.nNextId
local nCurr = TOOL.tbInfo.nId
FillInfoTableFromPart(TOOL.tbInfo.nPrevId)
if bPrev and TOOL.tbInfo.nPrevId and TOOL.tbInfo.nPrevId ~= GDB_ID.NULL then TOOL.CreateParetinaFull(false, false) end
-- modifico anche la paretina successiva(se esiste)
FillInfoTableFromPart(nNext)
if bNext then TOOL.CreateParetinaFull(false, false) end
FillInfoTableFromPart(nNextId)
if bNext and TOOL.tbInfo.nNextId and TOOL.tbInfo.nNextId ~= GDB_ID.NULL then TOOL.CreateParetinaFull(false, false) end
-- creo il solido e lo accoppio
if not SLD then
if SLD then
SLD.CurrId = nCurr
SLD.Main()
end
if not ASS then
if ASS then
ASS.nVeinCtx = EgtGetContext()
ASS.nPartId = nCurr
ASS.PairSingle()
end
TOOL.SaveMePlease()
-- pulisco la tabella con i dati
TOOL.tbInfo = {}
end
+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()