- cambiata la notazione per le info di accoppiamento.
- aggiunta la funzione per gestione UUID - corretta la funzione delle info di machining - piccole correzioni.
This commit is contained in:
@@ -735,7 +735,7 @@ function ASS.Unpair()
|
||||
ASS.nGroup = 0
|
||||
if not ASS.UpdatePairInfoSingle() then return false end
|
||||
-- se richiesto salvo la storia
|
||||
local nPartToPair = lPairList[0] ~= ASS.nPartId and -lPairList[0] or -lPairList[1]
|
||||
local nPartToPair = lPairList[1] ~= ASS.nPartId and -lPairList[1] or -lPairList[2]
|
||||
if ASS.bActiveHist then
|
||||
local tbEv = {Id = ASS.nPartId, vtDir = V_NULL(), ptAx = ORIG() , dAngOrId = nPartToPair, bWPaired = false, lPair = lPairList}
|
||||
if ASS.bSaveHist then AddEvent( tbEv) end
|
||||
@@ -859,9 +859,9 @@ local function PairPartFollowingInfo(nPart, tbTrasfTot)
|
||||
local nMyLineToPair = EgtGetFirstNameInGroup(nLayRef, sMyLineToPairName)
|
||||
if nMyLineToPair == nil or nMyLineToPair == GDB_ID.NULL then ASS.ERR = -3 return false end
|
||||
-- spezzo l'informazione per risalire al lato di destinazione dell'accoppiamento
|
||||
local vToInfo = EgtSplitString(sLineToPair, "_")
|
||||
local sLineToPairName = vToInfo[3]
|
||||
local sPartName = vToInfo[1].."_"..vToInfo[2]
|
||||
local vToInfo = EgtSplitString(sLineToPair, ",")
|
||||
local sLineToPairName = vToInfo[2]
|
||||
local sPartName = vToInfo[1]
|
||||
local nPartToPair = EgtGetFirstNameInGroup(GDB_ID.ROOT, sPartName)
|
||||
local nLay = EgtGetFirstNameInGroup(nPartToPair, sLayName)
|
||||
local nLineToPair = EgtGetFirstNameInGroup(nLay, sLineToPairName)
|
||||
|
||||
+72
-33
@@ -4,7 +4,7 @@
|
||||
-- Intestazioni
|
||||
require( 'EgtBase')
|
||||
_ENV = EgtProtectGlobal()
|
||||
EgtEnableDebug( false)
|
||||
EgtEnableDebug( true)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------
|
||||
-- FUNZIONI BASE PER GENERARE I COMPO SOLID INIZIO
|
||||
@@ -42,6 +42,7 @@ TOOL.dXOffset = nil -- offset del riferimento
|
||||
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.UUID = nil -- output per la generazione di un nuovo UUID
|
||||
|
||||
|
||||
-- info addizionali che potrebbero esserci nella tbInfo
|
||||
@@ -59,6 +60,10 @@ function TOOL.SaveMePlease()
|
||||
EgtSaveFile('D:\\Temp\\marmo\\Vein3D\\FOO.nge')
|
||||
end
|
||||
|
||||
function TOOL.GetNewUUID()
|
||||
TOOL.UUID = EgtGetUUID()
|
||||
end
|
||||
|
||||
local function FindEdges(nLay, tbInfo)
|
||||
-- crea una tabella con gli indici degli elementi nel Layer passato (nLay) e
|
||||
-- trova l'indice del lato tbInfo.nEdgeId, 1 based, restituito in tbInfo.nEdge
|
||||
@@ -87,6 +92,7 @@ local function FillInfoTable()
|
||||
if TOOL.nNextId then TOOL.tbInfo.nNextId = TOOL.nNextId end
|
||||
if TOOL.nJunctionType then TOOL.tbInfo.nJunctionType = TOOL.nJunctionType end
|
||||
if TOOL.bOnLoop ~= nil then TOOL.tbInfo.bOnLoop = TOOL.bOnLoop end
|
||||
if TOOL.bInsideLoop ~= nil then TOOL.tbInfo.bInsideLoop = TOOL.bInsideLoop 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
|
||||
@@ -107,6 +113,7 @@ local function FillInfoTableFromPart(nPartId)
|
||||
TOOL.tbInfo.nJunctionType = EgtGetInfo(nPartId,"JunctionType", "i")
|
||||
TOOL.tbInfo.dPairAng = EgtGetInfo(nPartId, "PairAng", "d")
|
||||
TOOL.tbInfo.bOnLoop = EgtGetInfo(nPartId,"OnLoop", "b")
|
||||
TOOL.tbInfo.bInsideLoop = EgtGetInfo(nPartId,"InsideLoop", "b")
|
||||
TOOL.tbInfo.dAngBR = EgtGetInfo(nPartId,"AngBR", "d")
|
||||
TOOL.tbInfo.dSideAngR = EgtGetInfo(nPartId,"SideAngR", "d")
|
||||
TOOL.tbInfo.dAngBL = EgtGetInfo(nPartId,"AngBL", "d")
|
||||
@@ -126,7 +133,7 @@ local function FillInfoTableFromPart(nPartId)
|
||||
local c = 1
|
||||
if TOOL.tbInfo.nIn ~=1 then
|
||||
while c ~= TOOL.tbInfo.nIn do
|
||||
nLay = EgtGetNextName(nLay)
|
||||
nLay = EgtGetNextName(nLay, "InLoop")
|
||||
c = c + 1
|
||||
end
|
||||
end
|
||||
@@ -144,6 +151,7 @@ function TOOL.WriteDataToChildPart(tbInfo)
|
||||
if tbInfo.dAngDx then EgtSetInfo(tbInfo.nId, 'AngDx', tbInfo.dAngDx) end
|
||||
if tbInfo.dAgnSx then EgtSetInfo(tbInfo.nId, 'AngSx', tbInfo.dAngSx) end
|
||||
if tbInfo.bOnLoop ~= nil then EgtSetInfo(tbInfo.nId, "OnLoop", tbInfo.bOnLoop) end
|
||||
if tbInfo.bInsideLoop ~= nil then EgtSetInfo(tbInfo.nId, "InsideLoop", tbInfo.bInsideLoop) 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.nJunctionType then EgtSetInfo(tbInfo.nId, 'JunctionType', tbInfo.nJunctionType) end
|
||||
@@ -152,7 +160,7 @@ function TOOL.WriteDataToChildPart(tbInfo)
|
||||
if tbInfo.nPrevId then EgtSetInfo(tbInfo.nId, "Prev", EgtGetName(tbInfo.nPrevId)) end
|
||||
if tbInfo.nNextId then EgtSetInfo(tbInfo.nId, "Next", EgtGetName(tbInfo.nNextId)) end
|
||||
end
|
||||
|
||||
|
||||
-- CREAZIONE dei Layer di un singolo Part
|
||||
-- I nomi dei layer sono: OutLoop, Region, Ref, Labels, Aux
|
||||
function TOOL.CreatePartLayer(PartName)
|
||||
@@ -218,13 +226,29 @@ function TOOL.SetMachiningInfo(Layer)
|
||||
EgtSetInfo(nId, 'NextAng', 0)
|
||||
return
|
||||
end
|
||||
|
||||
-- calcolo la normale del loop (per un inloop deve essere concorde con quella di un outloop)
|
||||
local bFlat = false
|
||||
local vtN = V_NULL()
|
||||
local dDist = 0
|
||||
local tbEdges = {}
|
||||
while nId do
|
||||
table.insert(tbEdges, nId)
|
||||
nId = EgtGetNext(nId)
|
||||
end
|
||||
local nLoop = EgtCurveCompoByChain(Layer, tbEdges, EgtSP(tbEdges[1], GDB_RT.GLOB), false, GDB_RT.GLOB)
|
||||
bFlat, vtN, dDist = EgtCurveIsFlat(nLoop)
|
||||
local vtAx = vtN
|
||||
EgtErase(nLoop)
|
||||
|
||||
-- riparto dal primo lato e inserisco le info di machining
|
||||
nId = EgtGetFirstInGroup(Layer)
|
||||
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 vtNextS = EgtSV(nNextId, GDB_RT.GLOB)
|
||||
local vtAx = Z_AX()
|
||||
--if bInLoop then vtAx=-vtAx end
|
||||
local NextAng = GetRotation( vtCurrE, vtNextS, vtAx)
|
||||
local PrevAng = GetRotation( vtPrevE, vtCurrS, vtAx)
|
||||
@@ -408,8 +432,8 @@ function TOOL.CreateReference( IdPart, sNameLayer,sNameEdge, nIn, dVar, sDir, sP
|
||||
-- se l'edge è in un Inloop e sono presenti più inloop nel Parent allora uso l'indice nIn per scorrere fino all'Inloop giusto
|
||||
if nIn and nIn ~= 1 then
|
||||
local nLay = EgtGetFirstNameInGroup(IdPart, sNameLayer)
|
||||
for i = 1, nIn do
|
||||
nLay = EgtGetNextName(nLay)
|
||||
for i = 1, nIn-1 do
|
||||
nLay = EgtGetNextName(nLay, sNameLayer)
|
||||
end
|
||||
IdEnt = EgtGetFirstNameInGroup(nLay, sNameEdge)
|
||||
end
|
||||
@@ -420,8 +444,8 @@ function TOOL.CreateReference( IdPart, sNameLayer,sNameEdge, nIn, dVar, sDir, sP
|
||||
end
|
||||
-- creo la copia dello spigolo come riferimento
|
||||
local IdRef = EgtCopy( IdEnt, tbLayer['Ref'])
|
||||
EgtSetInfo(IdRef, "OrigEdge", IdEnt)
|
||||
local nNumRef = EgtGetGroupObjs(tbLayer['Ref']) + 1
|
||||
EgtSetInfo(IdRef, "OrigEdge", EgtGetName(IdEnt))
|
||||
local nNumRef = EgtGetGroupObjs(tbLayer['Ref'])
|
||||
local sNameRef = "R"..tostring(nNumRef)
|
||||
-- verifico che non esista già un altro ref con questo nome
|
||||
local nIdRefDb= EgtGetFirstNameInGroup( tbLayer['Ref'], sNameRef)
|
||||
@@ -494,7 +518,7 @@ function TOOL.SetPairInfo( tbInfo, nIdMyRef, sToNamePart, nIdRefDest, nPairSpin)
|
||||
local sNameMyRef = EgtGetName(nIdMyRef)
|
||||
EgtSetInfo(nPart, "PairMyRef", sNameMyRef)
|
||||
local sNameRefDest = EgtGetName(nIdRefDest)
|
||||
EgtSetInfo(nPart, "PairToRef", sToNamePart.."_"..sNameRefDest)
|
||||
EgtSetInfo(nPart, "PairToRef", sToNamePart..","..sNameRefDest)
|
||||
EgtSetInfo(nPart, "PairSpin", nPairSpin)
|
||||
EgtSetInfo(nPart, "PairAng", tbInfo.dPairAng)
|
||||
EgtSetInfo(nPart, "PairMode", tbInfo.nPairMode)
|
||||
@@ -740,15 +764,15 @@ function TOOL.CreateAdjustedPart( nLayOutloop, dLen, dH, dBeta1, dBeta2)
|
||||
|
||||
local pt1 = ORIG()
|
||||
local pt2 = Point3d(dLen,0,0)
|
||||
local nLine1 = EgtLine( nLayOutloop, pt1, pt2)
|
||||
local nLine1 = EgtLine( nLayOutloop, pt1, pt2, GDB_RT.GLOB)
|
||||
EgtSetName(nLine1, "A1")
|
||||
local pt3 = Point3d(dLen + dProj2,dH,0)
|
||||
local nLine2 = EgtLine( nLayOutloop, pt2, pt3)
|
||||
local nLine2 = EgtLine( nLayOutloop, pt2, pt3, GDB_RT.GLOB)
|
||||
EgtSetName(nLine2, "A2")
|
||||
local pt4 = Point3d( -dProj1,dH,0)
|
||||
local nLine3 = EgtLine( nLayOutloop, pt3, pt4)
|
||||
local nLine3 = EgtLine( nLayOutloop, pt3, pt4, GDB_RT.GLOB)
|
||||
EgtSetName(nLine3, "A3")
|
||||
local nLine4 = EgtLine( nLayOutloop, pt4, pt1)
|
||||
local nLine4 = EgtLine( nLayOutloop, pt4, pt1, GDB_RT.GLOB)
|
||||
EgtSetName(nLine4, "A4")
|
||||
TOOL.SetMachiningInfo(nLayOutloop)
|
||||
return {nLine1, nLine2, nLine3, nLine4}
|
||||
@@ -772,23 +796,30 @@ end
|
||||
|
||||
function TOOL.CreateParetina(nEdgeId, tbInfo, dPairAngCorr)
|
||||
local tbIdLoopTC = {}
|
||||
-- se ho chiamato la funzione senza passare direttamente gli argomenti li recupero dalla tabella principale
|
||||
if not tbInfo then
|
||||
tbInfo = TOOL.tbInfo
|
||||
tbIdLoopTC = TOOL.tbIdLoop
|
||||
end
|
||||
if not tbInfo.nEdge and nEdgeId then
|
||||
-- se mancano la tabella degli edge e la posizione ordinale dell'edge, le ricostruisco
|
||||
if (not tbInfo.nEdge and nEdgeId) then
|
||||
tbIdLoopTC = FindEdges(EgtGetParent(nEdgeId), tbInfo)
|
||||
end
|
||||
-- se ho i dati, ma non ho ancora la tabella dei parent edge la recupero dalla tabella generale
|
||||
if #tbIdLoopTC == 0 and tbInfo then
|
||||
tbIdLoopTC = TOOL.tbIdLoop
|
||||
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.nPrevId, 'PairAng', 'd') or 0) + dPairAngCorr
|
||||
local dPairAng = (tbInfo.dPairAng or 0)
|
||||
local dPairAngPrev = (EgtGetInfo(tbInfo.nPrevId, 'PairAng', 'd') or dPairAng) + dPairAngCorr
|
||||
if not tbInfo.nNextId then tbInfo.nNextId = GDB_ID.NULL end
|
||||
local dPairAngNext = (EgtGetInfo(tbInfo.nNextId, 'PairAng', 'd') or 0) + dPairAngCorr
|
||||
local dPairAng = (tbInfo.dPairAng or 0) + dPairAngCorr
|
||||
local dPairAngNext = (EgtGetInfo(tbInfo.nNextId, 'PairAng', 'd') or dPairAng) + dPairAngCorr
|
||||
dPairAng = dPairAng + 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)
|
||||
@@ -888,7 +919,7 @@ end
|
||||
local function CreateSplitBottomPart(tbInfo, i, tbIdEdges, ptCenter, nPrev, nFirst)
|
||||
local Pz_Bottom = GDB_ID.NULL
|
||||
-- devo verificare se la paretina esiste già allora devo distruggerla e ricrearla, sennò la creo da zero
|
||||
local nChildPart = EgtGetFirstNarmeInGroup(GDB_ID.ROOT, EgtGetInfo(tbInfo.nParent, "A"..tbInfo.nEdge))
|
||||
local nChildPart = EgtGetFirstNameInGroup(GDB_ID.ROOT, EgtGetInfo(tbInfo.nParent, "A"..tbInfo.nEdge))
|
||||
if not nChildPart then
|
||||
Pz_Bottom = TOOL.CreatePartLayer('BottomA'..tostring(i))
|
||||
tbInfo.sName = EgtGetName(Pz_Bottom)
|
||||
@@ -903,16 +934,15 @@ local function CreateSplitBottomPart(tbInfo, i, tbIdEdges, ptCenter, nPrev, nFir
|
||||
-- setto le info per la creazione del pezzo di fondo
|
||||
if i == 1 then nFirst = Pz_Bottom end
|
||||
tbInfo.nId = Pz_Bottom
|
||||
tbInfo.nEdge = 3 -- so già che il pezzo che creo si attaccherà al lato A3 del loop della paretina del lavandino
|
||||
tbInfo.nEdgeId = tbIdEdges[i]
|
||||
tbInfo.nParent = tbParent[i]
|
||||
tbInfo.sDestRefOff = '0,0,-x'
|
||||
tbInfo.sRefOff = '0,0,0'
|
||||
tbInfo.dPairAng = 90 - TOOL.dSlopeAng
|
||||
tbInfo.nJunctionType = 3
|
||||
tbInfo.bOnLoop = true
|
||||
tbInfo.bInsideLoop = false -- questo mi richiederà di prendere il complementare del side ang che risulta dal calcDraftAng
|
||||
tbInfo.dH = (EgtPointCurveDist( ptCenter, tbInfo.nEdgeId, GDB_RT.GLOB) - TOOL.dDiamBore) / cos(TOOL.dSlopeAng)
|
||||
local dThParent = EgtGetInfo(tb.Info.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
|
||||
ClearPart(nChildPart)
|
||||
@@ -923,23 +953,29 @@ local function CreateSplitBottomPart(tbInfo, i, tbIdEdges, ptCenter, nPrev, nFir
|
||||
TOOL.tbInfo.nNextId = EgtGetFirstNameInGroup(GDB_ID.ROOT, EgtGetInfo(TOOL.tbInfo.nId, "Next")) or GDB_ID.NULL
|
||||
end
|
||||
-- creo il fondo come paretina
|
||||
TOOL.CreateParetina( tbPart.nEdgeId, tbPart, 90)
|
||||
TOOL.CreateAdjustedPart( tbLayerBottom['OutLoop'],tbPart.dLen, tbPart.dH, tbPart.dAngBL, tbPart.dAngBR)
|
||||
TOOL.CreatePart(tbLayerBottom,tbPart)
|
||||
|
||||
local tbLayerBottom = TOOL.FindLayers(tbInfo.nId)
|
||||
if tbPart.dSideAngL then TOOL.SetSideAng(tbLayerBottom['OutLoop'], 'A2', tbPart.dSideAngL) end
|
||||
if tbPart.dSideAngR then TOOL.SetSideAng(tbLayerBottom['OutLoop'], 'A4', tbPart.dSideAngR) end
|
||||
|
||||
TOOL.CreateParetina( tbInfo.nEdgeId, tbInfo, 90)
|
||||
TOOL.CreateAdjustedPart( tbLayerBottom['OutLoop'],tbInfo.dLen, tbInfo.dH, tbInfo.dAngBL, tbInfo.dAngBR)
|
||||
|
||||
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 nPartDestId = tbParent[i]
|
||||
local nIdToRef = TOOL.CreateReference( nPartDestId, 'OutLoop', 'A3', nil, tbPart.dTh, tbPart.sDestRefOff, tbInfo.sName)
|
||||
local nMyRef = TOOL.CreateReference( tbInfo.nId, 'OutLoop', 'A1', nil, 0, tbPart.sRefOff)
|
||||
TOOL.SetPairInfo( tbInfo.nId, nMyRef, sNamePartDest, nIdToRef, -1)
|
||||
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)
|
||||
local sNamePartDest = EgtGetName(tbInfo.nParent)
|
||||
TOOL.SetPairInfo( tbInfo, nMyRef, sNamePartDest, nIdToRef, -1)
|
||||
-- creo il solido e lo accoppio
|
||||
if SLD then
|
||||
SLD.CurrId = TOOL.tbInfo.nId
|
||||
SLD.Main()
|
||||
end
|
||||
|
||||
-- debug
|
||||
TOOL.SaveMePlease()
|
||||
-- debug
|
||||
|
||||
if ASS then
|
||||
ASS.nVeinCtx = EgtGetContext()
|
||||
@@ -977,12 +1013,15 @@ function TOOL.CreateSplitBottom( tbIdEdges, dOffset)
|
||||
local tbInfo = TOOL.tbInfo
|
||||
-- da intefaccia devo settare:-----------------------------------------------
|
||||
-- - TOOL.tbIdEdges
|
||||
-- - dOffset
|
||||
-- - dSlopeAng
|
||||
-- - dDiamBore
|
||||
-- - dTh
|
||||
-- - dOffset
|
||||
|
||||
for i = 1, #tbIdEdges do
|
||||
tbInfo.dTh = TOOL.dTh
|
||||
tbInfo.nParent = tbParent[i]
|
||||
tbInfo.nEdge = 3 -- so già che il pezzo che creo si attaccherà al lato A3 del loop della paretina del lavandino
|
||||
nPrev = CreateSplitBottomPart(tbInfo, i, tbIdEdges, ptCenter, nPrev, nFirst)
|
||||
|
||||
-- modifico le paretine vicine se serve
|
||||
@@ -1035,7 +1074,7 @@ local function CountInLoops(nEdgeId)
|
||||
local nNextLay = EgtGetFirstNameInGroup(nParent, "InLoop")
|
||||
local c = 1
|
||||
while nNextLay ~= nLay do
|
||||
nNextLay = EgtGetNextName(nNextLay)
|
||||
nNextLay = EgtGetNextName(nNextLay, "InLoop")
|
||||
c = c + 1
|
||||
end
|
||||
return c
|
||||
|
||||
Reference in New Issue
Block a user