- aggiunta la funzione per l'accoppiamento automatico
- piccole correzioni e migliorie.
This commit is contained in:
+91
-7
@@ -254,6 +254,7 @@ function ASS.RedoTemp()
|
||||
end
|
||||
|
||||
local function RetrieveSurfNorm( nPartId)
|
||||
-- recupero la normale della faccia principale del Part a partire dall'id del Part
|
||||
local nLayR = EgtGetFirstNameInGroup( nPartId, "Region")
|
||||
local nId = EgtGetFirstInGroup(nLayR)
|
||||
local nSurfId = GDB_ID.NULL
|
||||
@@ -269,6 +270,8 @@ local function RetrieveSurfNorm( nPartId)
|
||||
end
|
||||
|
||||
local function RetrieveParent( nId)
|
||||
-- recupero il parent dell'oggetto nId
|
||||
-- se è un oggetto all'interno contenuto in un Part che si chiama SOLID allora recupero il Part
|
||||
nId = EgtGetParent(EgtGetParent(nId))
|
||||
local sName = ""
|
||||
sName = EgtGetName(nId, "s")
|
||||
@@ -292,6 +295,7 @@ local function RetrievePaired()
|
||||
end
|
||||
|
||||
local function RetrieveLocAxis()
|
||||
-- recupero l'id della terna, se esiste
|
||||
nTernaId = GDB_ID.NULL
|
||||
nTernaId = EgtGetInfo( ASS.nPartId, "Terna", "i")
|
||||
if not nTernaId then
|
||||
@@ -302,6 +306,7 @@ local function RetrieveLocAxis()
|
||||
end
|
||||
|
||||
local function RetrieveLocOrig()
|
||||
-- recupero l'origine della terna
|
||||
if nTernaId == GDB_ID.NULL then do return end end
|
||||
local LayOrig = EgtGetFirstNameInGroup(nTernaId, "ORIG")
|
||||
ptOrigId = EgtGetFirstNameInGroup(LayOrig, "ORIG")
|
||||
@@ -331,7 +336,7 @@ end
|
||||
function ASS.MoveSingle()
|
||||
-- muovo il pezzo MA NON i suoi accoppiati
|
||||
EgtMove( ASS.nPartId, ASS.vtMove)
|
||||
local nChild = EgtGetInfo( nId, "Child", "i")
|
||||
local nChild = EgtGetInfo( ASS.nPartId, "Child", "i")
|
||||
EgtMove( nChild, ASS.vtMove)
|
||||
if RetrieveLocAxis() then
|
||||
EgtMove(nTernaId, ASS.vtMove)
|
||||
@@ -386,7 +391,7 @@ function ASS.RotateSingle()
|
||||
end
|
||||
-- ruoto il pezzo MA NON i suoi accoppiati
|
||||
EgtRotate( ASS.nPartId, ASS.ptAx, ASS.vtAx, ASS.dAng)
|
||||
local nChild = EgtGetInfo( nId, "Child","i")
|
||||
local nChild = EgtGetInfo( ASS.nPartId, "Child","i")
|
||||
EgtRotate( nChild, ASS.ptAx, ASS.vtAx, ASS.dAng)
|
||||
-- se richiesto salvo la storia
|
||||
if ASS.bActiveHist then
|
||||
@@ -399,14 +404,16 @@ end
|
||||
|
||||
function ASS.FlipParallel()
|
||||
local vtNorm = V_NULL()
|
||||
-- recupero la normale della superficie ORIG()inale
|
||||
-- recupero la normale della superficie originale
|
||||
vtNorm = RetrieveSurfNorm( RetrievePart(ASS.nPartId))
|
||||
local ptMid
|
||||
ptMid = EgtMP(ASS.nIdFirstLine, GDB_RT.GLOB)
|
||||
ASS.ptAx = ptMid
|
||||
--ptMid = EgtMP(ASS.nIdFirstLine, GDB_RT.GLOB)
|
||||
--ASS.ptAx = ptMid
|
||||
ASS.ptAx = ptPair
|
||||
ASS.vtAx = vtNorm
|
||||
ASS.dAng = 180
|
||||
ASS.Rotate()
|
||||
ASS.EdgePair()
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -414,13 +421,14 @@ function ASS.FlipPerpendicular()
|
||||
-- recupero la normale della faccia principale del part del secondo part
|
||||
local vtNorm = V_NULL()
|
||||
vtNorm = RetrieveSurfNorm( RetrieveParent(ASS.nIdSecondLine))
|
||||
local vtStartDir = EgtSV(ASS.nIdSecondLine)
|
||||
local vtStartDir = EgtSV(ASS.nIdSecondLine, GDB_RT.GLOB)
|
||||
local vtAx = vtNorm ^ vtStartDir
|
||||
-- recupero il punto usato per l'accoppiamento
|
||||
ASS.ptAx = ptPair
|
||||
ASS.vtAx = vtAx
|
||||
ASS.dAng = 180
|
||||
ASS.Rotate()
|
||||
ASS.EdgePair()
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -428,7 +436,6 @@ function ASS.FacePair()
|
||||
-- setto e controllo
|
||||
EgtSetContext(ASS.nVeinCtx)
|
||||
if ASS.nPartId == GDB_ID.NULL then return false end
|
||||
if ASS.nIdFirstLine == GDB_ID.NULL then return false end
|
||||
if ASS.nIdSecondLine == GDB_ID.NULL then return false end
|
||||
-- recupero gli id dei Part
|
||||
local nIdToPair = RetrieveParent(ASS.nIdSecondLine)
|
||||
@@ -640,3 +647,80 @@ end
|
||||
|
||||
--dofile("D:\\Temp\\marmo\\repeat2.lua")
|
||||
|
||||
function ASS.PairAll()
|
||||
--local sTime = os.date( '%y%m%d%H%M%S', os.time())
|
||||
EgtSetContext(ASS.nVeinCtx)
|
||||
local nPart = EgtGetFirstPart()
|
||||
EgtOutLog(tostring(nPart))
|
||||
while nPart do
|
||||
local sLineToPair = EgtGetInfo(nPart, "PairToRef")
|
||||
local sMyLineToPairName = EgtGetInfo( nPart, "PairMyRef")
|
||||
if sLineToPair then
|
||||
-- recupero l'id del lato da accoppiare
|
||||
local sLayName = "Ref"
|
||||
local nLayRef = EgtGetFirstNameInGroup(nPart, sLayName)
|
||||
local nMyLineToPair = EgtGetFirstNameInGroup(nLayRef, sMyLineToPairName)
|
||||
-- spezzo l'informazione per risalire al lato di destionazione dell'accoppiamento
|
||||
local vToInfo = EgtSplitString(sLineToPair, "_")
|
||||
local sLineToPairName = vToInfo[3]
|
||||
local sPartName = vToInfo[1].."_"..vToInfo[2]
|
||||
local nPartToPair = EgtGetFirstNameInGroup(GDB_ID.ROOT, sPartName)
|
||||
local nLay = EgtGetFirstNameInGroup(nPartToPair, sLayName)
|
||||
local nLineToPair = EgtGetFirstNameInGroup(nLay, sLineToPairName)
|
||||
|
||||
local nSpin = EgtGetInfo(nPart, "PairSpin", "i")
|
||||
ASS.nPartId = nPart
|
||||
ASS.nIdFirstLine = nMyLineToPair
|
||||
ASS.nIdSecondLine = nLineToPair
|
||||
-- se lo spin è negativo vuol dire che devo accoppiare start del primo con end del secondo
|
||||
-- sennò start con start
|
||||
ASS.nOption = (nSpin == -1 and 1 or 0)
|
||||
ASS.EdgePair()
|
||||
local ptFirst
|
||||
local ptSecond
|
||||
if ASS.nOption == 0 then
|
||||
--Start-Start
|
||||
ptFirst = EgtEP( ASS.nIdFirstLine, GDB_RT.GLOB)
|
||||
ptSecond = EgtEP( ASS.nIdSecondLine, GDB_RT.GLOB)
|
||||
elseif ASS.nOption == 1 then
|
||||
--Start-End
|
||||
ptFirst = EgtEP( ASS.nIdFirstLine, GDB_RT.GLOB)
|
||||
ptSecond = EgtSP( ASS.nIdSecondLine, GDB_RT.GLOB)
|
||||
elseif ASS.nOption == 2 then
|
||||
--End-Start
|
||||
ptFirst = EgtSP( ASS.nIdFirstLine, GDB_RT.GLOB)
|
||||
ptSecond = EgtEP( ASS.nIdSecondLine, GDB_RT.GLOB)
|
||||
elseif ASS.nOption == 3 then
|
||||
--End-End
|
||||
ptFirst = EgtSP( ASS.nIdFirstLine, GDB_RT.GLOB)
|
||||
ptSecond = EgtSP( ASS.nIdSecondLine, GDB_RT.GLOB)
|
||||
elseif ASS.nOption == 4 then
|
||||
--Mid-Mid
|
||||
if nSpin == 1 then
|
||||
ptFirst = EgtSP( ASS.nIdFirstLine, GDB_RT.GLOB)
|
||||
ptSecond = EgtSP( ASS.nIdSecondLine, GDB_RT.GLOB)
|
||||
elseif nSpin == -1 then
|
||||
ptFirst = EgtSP( ASS.nIdFirstLine, GDB_RT.GLOB)
|
||||
ptSecond = EgtEP( ASS.nIdSecondLine, GDB_RT.GLOB)
|
||||
end
|
||||
end
|
||||
if not AreSamePointApprox( ptFirst, ptSecond) then
|
||||
ASS.FlipParallel()
|
||||
end
|
||||
-- recupero l'angolo che deve esserci tra le due facce dei part alla fine dell'accoppiamento
|
||||
local nAngGoal = EgtGetInfo(nPart, "PairAng", "i")
|
||||
-- calcolo l'angolo attuale tra le due normali e quindi la rotazione che devo applicare per differenza
|
||||
local vtSurf1 = RetrieveSurfNorm(nPart)
|
||||
local vtSurf2 = RetrieveSurfNorm(RetrieveParent(ASS.nIdSecondLine))
|
||||
ASS.vtAx = EgtSV(ASS.nIdSecondLine, GDB_RT.GLOB)
|
||||
local dAngCurr = GetRotation(vtSurf1, vtSurf2, ASS.vtAx)
|
||||
ASS.dAng = dAngCurr - nAngGoal
|
||||
ASS.ptAx = EgtSP(ASS.nIdSecondLine, GDB_RT.GLOB)
|
||||
ASS.Rotate()
|
||||
-- aggiorno le info di accoppiamento
|
||||
ASS.nPartToPair = nPartToPair
|
||||
ASS.UpdatePairInfo()
|
||||
end
|
||||
nPart = EgtGetNext(nPart)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user