This commit is contained in:
Emmanuele Sassi
2024-06-25 17:46:04 +02:00
18 changed files with 2177 additions and 481 deletions
+23 -1
View File
@@ -109,11 +109,33 @@
"EgtReplaceString",
"EgtCircle",
"EgtArc2PV",
"EgtTdbSetCurrTool",
"EgtSurfTmSubtract",
"EgtSurfTmIntersect",
"GDB_IN",
"GEO",
"dist"
"dist",
"EgtSetMachiningParam",
"EgtCreateMachining",
"EgtSetMachiningGeometry",
"EgtGetMachiningParam",
"EgtGetLastMachMgrError",
"EgtSetOperationMode",
"EgtApplyMachining",
"EgtSetCurrPhase",
"EgtApplyAllMachinings",
"EgtGetDebugLevel",
"EgtTdbGetCurrToolParam",
"EgtTdbGetCurrToolThDiam",
"EgtTdbGetCurrToolMaxDepth",
"EgtTdbGetCurrToolThLength",
"EgtFindToolInCurrSetup",
"EgtTdbGetFirstTool",
"EgtTdbGetNextTool",
"EgtMdbSave",
"EgtMoveRawPart",
"EgtCurveThickness",
"EgtSetCurrMachining"
],
"Lua.diagnostics.disable": [
"empty-block"
+67
View File
@@ -0,0 +1,67 @@
-- FeatureData.lua by Egalware s.r.l. 2024/06/18
-- Libreria lettura o calcolo dati e proprietà della feature
-- Tabella per definizione modulo
local FeatureData = {}
-- Carico i dati globali
local WinData = require( 'WinData')
-------------------------------------------------------------------------------------------------------------
-- Recupero dati foro
function FeatureData.GetDrillingData( Proc)
local bOk, ptCentre, vtDir, dRadius = EgtCurveIsACircle( Proc.id)
Proc.dDiam = dRadius * 2
Proc.dLen = abs( EgtCurveThickness( Proc.id)) or 0
Proc.ptCentre = ptCentre
Proc.vtDir = vtDir
return Proc
end
-------------------------------------------------------------------------------------------------------------
-- Recupero dati taglio
function FeatureData.GetCuttingData( Proc)
return Proc
end
-------------------------------------------------------------------------------------------------------------
-- Recupero dati foro
function FeatureData.GetPocketingData( Proc)
return Proc
end
-------------------------------------------------------------------------------------------------------------
-- Recupero dati foro
function FeatureData.GetMillingData( Proc)
return Proc
end
-------------------------------------------------------------------------------------------------------------
-- Recupero dati profilatura
function FeatureData.GetProfilingData( Proc)
-- recupero utensili
Proc.nToolsToUse = EgtGetInfo( Proc.id, 'NTOOLS', 'i') or 0
Proc.sEntityName = EgtGetInfo( Proc.id, 'N', 's') or nil
Proc.bHeadProfile = Proc.sEntityName == 'Left' or Proc.sEntityName == 'Right'
Proc.bSideProfile = Proc.sEntityName == 'In' or Proc.sEntityName == 'Out'
Proc.Tools = {}
for t = 1, Proc.nToolsToUse do
local Data = {}
Data.sName = EgtGetInfo( Proc.id, 'TOOL_NAME_' .. tostring(t), 's') or 0
Data.dRadialOffset = EgtGetInfo( Proc.id, 'OFFR_' .. tostring(t), 'd') or 0
Data.dLongitudinalOffset = EgtGetInfo( Proc.id, 'OFFL_' .. tostring(t), 'd') or 0
table.insert( Proc.Tools, Data)
end
Proc.ProfileType = EgtGetInfo( Proc.id, 'ProfileType', 's') or ''
return Proc
end
-------------------------------------------------------------------------------------------------------------
return FeatureData
+50
View File
@@ -0,0 +1,50 @@
-- Identity.lua by Egalware s.r.l. 2024/06/18
-- Libreria Riconoscimento della feature
-- Tabella per definizione modulo
local Identity = {}
---------------------------------------------------------------------
------------------------ STANDARD FEATURES ------------------------
---------------------------------------------------------------------
-- Feature : Drilling
function Identity.IsDrilling( Proc)
return Proc.sType == 'Hole'
end
---------------------------------------------------------------------
-- Feature : Cutting
function Identity.IsCutting( Proc)
return Proc.sType == 'Cut'
end
---------------------------------------------------------------------
-- Feature : Milling
function Identity.IsMilling( Proc)
return Proc.sType == 'Milling'
end
---------------------------------------------------------------------
-- Feature : Pocketing
function Identity.IsPocketing( Proc)
return Proc.sType == 'Pocket'
end
---------------------------------------------------------------------
-- Feature : Profiling
function Identity.IsProfiling( Proc)
return Proc.sType == 'Profiling'
end
---------------------------------------------------------------------
----------------------------- PIECES ------------------------------
---------------------------------------------------------------------
function Identity.GetPieceIndexPart( PARTS, idGeom)
local nIndexPart
for i = 1, #PARTS do
if PARTS[i].id == idGeom then
nIndexPart = i
break
end
end
return nIndexPart
end
---------------------------------------------------------------------
return Identity
+360
View File
@@ -0,0 +1,360 @@
-- MachiningLib.lua by Egalware s.r.l. 2024/06/17
-- Libreria ricerca lavorazioni per serramenti
-- Tabella per definizione modulo
local MachiningLib = {}
-- Include
require( 'EgtBase')
-- Carico i dati globali
local WinData = require( 'WinData')
local ID = require( 'Identity')
EgtOutLog( ' MachiningLib started', 1)
-------------------------------------------------------------------------------------------------------------
-- funzione per cercare utensile tipo FRESA con certe caratteristiche
function MachiningLib.FindMill( Proc, ToolSearchParameters)
local ToolInfo = {}
local nBestToolIndex
local dBestToolResidualDepth = 0
for i = 1, #TOOLS do
-- prima verifico che utensile sia compatibile
local bIsToolCompatible = true
if ToolSearchParameters.sName and ToolSearchParameters.sName ~= TOOLS[i].sName then
bIsToolCompatible = false
elseif ToolSearchParameters.dMaxToolDiameter and TOOLS[i].dDiameter > ToolSearchParameters.dMaxToolDiameter then
bIsToolCompatible = false
elseif ToolSearchParameters.sMillShape and ToolSearchParameters.sMillShape == 'STANDARD' and ( TOOLS[i].dSideAngle ~= 0 or TOOLS[i].bIsPen) then
bIsToolCompatible = false
elseif ToolSearchParameters.sMillShape and ToolSearchParameters.sMillShape == 'DOVETAIL' and not TOOLS[i].bIsDoveTail then
bIsToolCompatible = false
elseif ToolSearchParameters.sMillShape and ToolSearchParameters.sMillShape == 'TSHAPEMILL' and not TOOLS[i].bIsTMill then
bIsToolCompatible = false
elseif ToolSearchParameters.sMillShape and ToolSearchParameters.sMillShape == 'PEN' and not TOOLS[i].bIsPen then
bIsToolCompatible = false
elseif ToolSearchParameters.sType and TOOLS[i].sType ~= ToolSearchParameters.sType then
-- se sto cercando una fresa che non può lavorare di testa, quelle che lavorano di testa sono comunque ammesse
if TOOLS[i].sType == 'MILL_STD' and ToolSearchParameters.sType == 'MILL_NOTIP' then
bIsToolCompatible = true
else
bIsToolCompatible = false
end
end
-- scelgo il migliore
if bIsToolCompatible then
local dCurrentMaxMatReduction = WinData.COLL_SIC or 5
-- dCurrMachReduction = negativo -> limitare, positivo -> mm extra disponibili
local dCurrentResidualDepth = ToolSearchParameters.dElevation + dCurrentMaxMatReduction - TOOLS[i].dMaxDepth
-- se non ancora trovato, oppure se completo e il migliore fino ad ora non è completo: corrente è il migliore
if not nBestToolIndex or ( dBestToolResidualDepth > 0 and dCurrentResidualDepth <= 0) then
nBestToolIndex = i
dBestToolResidualDepth = dCurrentResidualDepth
-- altrimenti scelgo il migliore
else
-- se entrambi completi
if dBestToolResidualDepth <= 0 and dCurrentResidualDepth <= 0 then
-- se il migliore era su aggregato e corrente montanto direttamente, prediligo utensile montato direttamente
if not TOOLS[i].SetupInfo.bToolOnAggregate and TOOLS[i].SetupInfo.bToolOnAggregate then
nBestToolIndex = i
dBestToolResidualDepth = dCurrentResidualDepth
-- se hanno stesso montaggio
elseif TOOLS[i].SetupInfo.bToolOnAggregate == TOOLS[nBestToolIndex].SetupInfo.bToolOnAggregate then
-- scelgo utensile con indice di bontà utensile calcolato come: lunghezza / massimo materiale / diametro
if ( TOOLS[i].dLength / TOOLS[i].dMaxMaterial) / TOOLS[i].dDiameter < ( TOOLS[nBestToolIndex].dLength / TOOLS[nBestToolIndex].dMaxMaterial) / TOOLS[nBestToolIndex].dDiameter then
nBestToolIndex = i
dBestToolResidualDepth = dCurrentResidualDepth
end
end
-- se entrambi incompleti
elseif dBestToolResidualDepth > 0 and dCurrentResidualDepth > 0 then
--scelgo quello che lavora di più
if dCurrentResidualDepth < dBestToolResidualDepth then
nBestToolIndex = i
dBestToolResidualDepth = dCurrentResidualDepth
end
end
end
end
end
ToolInfo.nToolIndex = nBestToolIndex
ToolInfo.dResidualDepth = dBestToolResidualDepth
return ToolInfo
end
-------------------------------------------------------------------------------------------------------------
-- funzione per cercare utensile tipo LAMA con certe caratteristiche
-- TODO da completare
function MachiningLib.FindBlade( Proc, ToolSearchParameters)
local ToolInfo = {}
-- parametri opzionali
ToolSearchParameters.dElevation = ToolSearchParameters.dElevation or 0
ToolSearchParameters.bForceLongcutBlade = ToolSearchParameters.bForceLongcutBlade or false
local nBestToolIndex
for i = 1, #TOOLS do
local bIsToolCompatible = false
-- TODO per il momento si prende la prima lama. Da completare
if TOOLS[i].sFamily == 'SAWBLADE' then
bIsToolCompatible = true
end
if bIsToolCompatible then
nBestToolIndex = i
break
end
end
ToolInfo.nToolIndex = nBestToolIndex
return ToolInfo
end
-------------------------------------------------------------------------------------------------------------
-- funzione per cercare utensile tipo PUNTA A FORARE con certe caratteristiche
-- TODO da fare
function MachiningLib.FindDrill()
end
-------------------------------------------------------------------------------------------------------------
-- funzione che ritorna fase di lavoro
function MachiningLib.GetPhaseMach( Proc)
local nPhase
-- se info già calcolata
if Proc.nPhase then
nPhase = Proc.nPhase
-- altrimenti si calcola il comportamento standard
else
if Proc.sEntityName == 'Left' or Proc.sEntityName == 'Out' then
nPhase = 1
end
if Proc.sEntityName == 'Right' or Proc.sEntityName == 'In' then
nPhase = 2
end
end
return nPhase
end
-------------------------------------------------------------------------------------------------------------
-- salva in lista globale la lavorazione appena calcolata
function MachiningLib.AddNewMachining( ProcToAdd, MachiningToAdd, AuxInfoToAdd)
-- Controllo parametri obbligatori
if not MachiningToAdd.nType or not MachiningToAdd.nToolIndex or not MachiningToAdd.Geometry or not ProcToAdd.id then
return false
end
-- Drilling
if MachiningToAdd.nType == MCH_MY.DRILLING then
MachiningToAdd.sTypeName = 'Drill_'
-- Milling
elseif MachiningToAdd.nType == MCH_MY.MILLING then
-- se utensile lama
if TOOLS[MachiningToAdd.nToolIndex].sFamily == 'SAWBLADE' then
MachiningToAdd.sTypeName = 'Cut_'
else
MachiningToAdd.sTypeName = 'Mill_'
end
-- Pocketing
elseif MachiningToAdd.nType == MCH_MY.POCKETING then
MachiningToAdd.sTypeName = 'Pocket_'
-- Mortising
elseif MachiningToAdd.nType == MCH_MY.MORTISING then
MachiningToAdd.sTypeName = 'ChSaw_'
end
-- se nome non definito, assegno alla lavorazioen un nome standard
if not MachiningToAdd.sOperationName then
MachiningToAdd.sOperationName = MachiningToAdd.sTypeName .. ( EgtGetName( ProcToAdd.id) or tostring( ProcToAdd.id)) -- TODO serve scrivere faccia? -->> .. '_' .. tostring( MachiningToAdd.Geometry[1][2])
end
if not MachiningToAdd.sToolName then
MachiningToAdd.sToolName = TOOLS[MachiningToAdd.nToolIndex].sName
end
local Machining = {}
Machining.Proc = ProcToAdd
Machining.Machining = MachiningToAdd
Machining.AuxInfo = AuxInfoToAdd
table.insert( MACHININGS, Machining)
return true
end
-------------------------------------------------------------------------------------------------------------
-- funzione per aggiungere una nuova lavorazione
function MachiningLib.AddOperation( OperationToInsert)
local nErr
local sErr = ''
local bAreAllMachiningApplyOk = true
-- creazione lavorazione
local nOperationId = EgtCreateMachining( OperationToInsert.Machining.sOperationName, OperationToInsert.Machining.nType, OperationToInsert.Machining.sToolName)
EgtSetCurrMachining( nOperationId)
if nOperationId then
-- impostazione geometria
EgtSetMachiningGeometry( OperationToInsert.Machining.Geometry)
-- impostazione parametri lavorazione
if OperationToInsert.Machining.sDepth then
EgtSetMachiningParam( MCH_MP.DEPTH_STR, OperationToInsert.Machining.sDepth)
end
if OperationToInsert.Machining.bInvert then
EgtSetMachiningParam( MCH_MP.INVERT, OperationToInsert.Machining.bInvert)
end
if OperationToInsert.Machining.nWorkSide then
EgtSetMachiningParam( MCH_MP.WORKSIDE, OperationToInsert.Machining.nWorkSide)
end
if OperationToInsert.Machining.nFaceuse then
EgtSetMachiningParam( MCH_MP.FACEUSE, OperationToInsert.Machining.nFaceuse)
end
if OperationToInsert.Machining.nSCC then
EgtSetMachiningParam( MCH_MP.SCC, OperationToInsert.Machining.nSCC)
end
if OperationToInsert.Machining.bToolInvert then
EgtSetMachiningParam( MCH_MP.TOOLINVERT, OperationToInsert.Machining.bToolInvert)
end
if OperationToInsert.Machining.sBlockedAxis then
EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, OperationToInsert.Machining.sBlockedAxis)
end
if OperationToInsert.Machining.sInitialAngles then
EgtSetMachiningParam( MCH_MP.INITANGS, OperationToInsert.Machining.sInitialAngles)
end
if OperationToInsert.Machining.nHeadSide then
EgtSetMachiningParam( MCH_MP.HEADSIDE, OperationToInsert.Machining.nHeadSide)
end
if OperationToInsert.Machining.nSubType then
EgtSetMachiningParam( MCH_MP.SUBTYPE, OperationToInsert.Machining.nSubType)
end
if OperationToInsert.Machining.dOverlap then
EgtSetMachiningParam( MCH_MP.OVERL, OperationToInsert.Machining.dOverlap)
end
-- step
if OperationToInsert.Machining.Steps then
if OperationToInsert.Machining.Steps.dStepType then
EgtSetMachiningParam( MCH_MP.STEPTYPE, OperationToInsert.Machining.Steps.dStepType)
end
if OperationToInsert.Machining.Steps.dStep then
EgtSetMachiningParam( MCH_MP.STEP, OperationToInsert.Machining.Steps.dStep)
end
if OperationToInsert.Machining.Steps.dSideStep then
EgtSetMachiningParam( MCH_MP.SIDESTEP, OperationToInsert.Machining.Steps.dSideStep)
end
end
if OperationToInsert.Machining.dStartPos then
EgtSetMachiningParam( MCH_MP.STARTPOS, OperationToInsert.Machining.dStartPos)
end
if OperationToInsert.Machining.dReturnPos then
EgtSetMachiningParam( MCH_MP.RETURNPOS, OperationToInsert.Machining.dReturnPos)
end
if OperationToInsert.Machining.dRadialOffset then
EgtSetMachiningParam( MCH_MP.OFFSR, OperationToInsert.Machining.dRadialOffset)
end
if OperationToInsert.Machining.dLongitudinalOffset then
EgtSetMachiningParam( MCH_MP.OFFSL, OperationToInsert.Machining.dLongitudinalOffset)
end
-- paraemtri attacco
if OperationToInsert.Machining.LeadIn then
if OperationToInsert.Machining.LeadIn.nType then
EgtSetMachiningParam( MCH_MP.LEADINTYPE, OperationToInsert.Machining.LeadIn.nType)
end
if OperationToInsert.Machining.LeadIn.dStartAddLength then
EgtSetMachiningParam( MCH_MP.STARTADDLEN, OperationToInsert.Machining.LeadIn.dStartAddLength)
end
if OperationToInsert.Machining.LeadIn.dTangentDistance then
EgtSetMachiningParam( MCH_MP.LITANG, OperationToInsert.Machining.LeadIn.dTangentDistance)
end
if OperationToInsert.Machining.LeadIn.dPerpDistance then
EgtSetMachiningParam( MCH_MP.LIPERP, OperationToInsert.Machining.LeadIn.dPerpDistance)
end
if OperationToInsert.Machining.LeadIn.dElevation then
EgtSetMachiningParam( MCH_MP.LIELEV, OperationToInsert.Machining.LeadIn.dElevation)
end
if OperationToInsert.Machining.LeadIn.dCompLength then
EgtSetMachiningParam( MCH_MP.LICOMPLEN, OperationToInsert.Machining.LeadIn.dCompLength)
end
end
-- parametri uscita
if OperationToInsert.Machining.LeadOut then
if OperationToInsert.Machining.LeadOut.nType then
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, OperationToInsert.Machining.LeadOut.nType)
end
if OperationToInsert.Machining.LeadOut.dEndAddLength then
EgtSetMachiningParam( MCH_MP.ENDADDLEN, OperationToInsert.Machining.LeadOut.dEndAddLength)
end
if OperationToInsert.Machining.LeadOut.dTangentDistance then
EgtSetMachiningParam( MCH_MP.LOTANG, OperationToInsert.Machining.LeadOut.dTangentDistance)
end
if OperationToInsert.Machining.LeadOut.dPerpDistance then
EgtSetMachiningParam( MCH_MP.LOPERP, OperationToInsert.Machining.LeadOut.dPerpDistance)
end
if OperationToInsert.Machining.LeadOut.dElevation then
EgtSetMachiningParam( MCH_MP.LOELEV, OperationToInsert.Machining.LeadOut.dElevation)
end
if OperationToInsert.Machining.LeadOut.dCompLength then
EgtSetMachiningParam( MCH_MP.LOCOMPLEN, OperationToInsert.Machining.LeadOut.dCompLength)
end
end
if OperationToInsert.Machining.dStartSlowLen then
EgtSetMachiningParam( MCH_MP.STARTSLOWLEN, OperationToInsert.Machining.dStartSlowLen)
end
if OperationToInsert.Machining.dEndSlowLen then
EgtSetMachiningParam( MCH_MP.ENDSLOWLEN, OperationToInsert.Machining.dEndSlowLen)
end
if OperationToInsert.Machining.dThrouAddLen then
EgtSetMachiningParam( MCH_MP.THROUADDLEN, OperationToInsert.Machining.dThrouAddLen)
end
-- parametri da settare nelle note di sistema
-- TODO da decidere quali sono le note da salvare qui. Probabilmente tutte quelle relative all'ordine delle lavorazioni
local sSystemNotes = EgtGetMachiningParam( MCH_MP.SYSNOTES)
--if OperationToInsert.Machining.nMachiningOrder then
-- sSystemNotes = EgtSetValInNotes( sSystemNotes, 'MachiningOrder', OperationToInsert.Machining.nMachiningOrder)
--end
EgtSetMachiningParam( MCH_MP.SYSNOTES, sSystemNotes)
-- parametri da settare nelle note utente
local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES)
if OperationToInsert.Machining.dMaxElev then
sUserNotes = EgtSetValInNotes( sUserNotes, 'MaxElev', OperationToInsert.Machining.dMaxElev)
end
EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes)
local b3MachEncumbrance = nil
local bIsApplyOk = MachiningLib.ApplyMachining( true, false)
if not bIsApplyOk then
bAreAllMachiningApplyOk = false
nErr, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nOperationId, false)
else
local nClId = EgtGetFirstNameInGroup( nOperationId, 'CL')
local ptMin = EgtGetInfo( nClId, 'MMIN', 'p')
local ptMax = EgtGetInfo( nClId, 'MMAX', 'p')
-- box percorso lavorazione
b3MachEncumbrance = BBox3d( ptMin, ptMax)
end
return bIsApplyOk, sErr, b3MachEncumbrance
else
return false, 'UNEXPECTED ERROR: Error on creating machining'
end
end
-------------------------------------------------------------------------------------------------------------
function MachiningLib.ApplyMachining( bRecalc, bApplyPost)
local bResult = EgtApplyMachining( bRecalc, bApplyPost)
return bResult
end
-------------------------------------------------------------------------------------------------------------
return MachiningLib
+482
View File
@@ -0,0 +1,482 @@
-- WinExec.lua by Egalware s.r.l. 2024/06/13
-- Libreria esecuzione lavorazioni per Serramenti
-- Tabella per definizione modulo
local WinExec = {}
-- Include
require( 'EgtBase')
-- Carico i dati globali
local WinData = require( 'WinData')
local WinLib = require( 'WinLib')
local ID = require( 'Identity')
local FeatureData = require( 'FeatureData')
local MachiningLib = require( 'MachiningLib')
-- carico librerie di lavorazione
_G.package.loaded.Drilling = nil
_G.package.loaded.Cutting = nil
_G.package.loaded.Pocketing = nil
_G.package.loaded.Milling = nil
_G.package.loaded.Profiling = nil
local Drilling = require( 'Drilling')
local Cutting = require( 'Cutting')
local Pocketing = require( 'Pocketing')
local Milling = require( 'Milling')
local Profiling = require( 'Profiling')
EgtOutLog( ' WinExec started', 1)
EgtMdbSave()
-------------------------------------------------------------------------------------------------------------
-- *** variabili globali ***
-------------------------------------------------------------------------------------------------------------
TOOLS = nil
MACHININGS = nil
-------------------------------------------------------------------------------------------------------------
-- *** COSTANTI *** TODO -> DA SPOSTARE IN WINDATA???
-------------------------------------------------------------------------------------------------------------
TH_DIAMETER_HSK63 = 63
TH_LENGTH_HSK63 = 75
SIDEANGLE_DOVETAIL = 15
-------------------------------------------------------------------------------------------------------------
-- *** funzioni di base ***
-------------------------------------------------------------------------------------------------------------
local function GetToolTypeNameFromToolTypeID( dToolTypeID)
if dToolTypeID == MCH_TY.DRILL_STD then
return 'DRILL_STD', 'DRILLBIT'
elseif dToolTypeID == MCH_TY.DRILL_LONG then
return 'DRILL_LONG', 'DRILLBIT'
elseif dToolTypeID == MCH_TY.SAW_STD then
return 'SAW_STD', 'SAWBLADE'
elseif dToolTypeID == MCH_TY.SAW_FLAT then
return 'SAW_FLAT', 'SAWBLADE'
elseif dToolTypeID == MCH_TY.MILL_STD then
return 'MILL_STD', 'MILL'
elseif dToolTypeID == MCH_TY.MILL_NOTIP then
return 'MILL_NOTIP', 'MILL'
elseif dToolTypeID == MCH_TY.MORTISE_STD then
return 'MORTISE_STD', 'MORTISE'
else
return nil
end
end
-------------------------------------------------------------------------------------------------------------
local function IsToolOk( Tool)
-- controllo che i dati necessari siano impostati
if Tool.dMaxMaterial and Tool.dDiameter and Tool.dLength and Tool.sHead and Tool.sUUID then
-- se DRILLBIT non ho altri dati
if Tool.sFamily == 'DRILLBIT' then
return true
-- altrimenti controllo dati aggiuntivi altre famiglie di utensili
elseif Tool.sFamily == 'MORTISE' then
if Tool.dCornerRadius then
return true
end
else
if Tool.dThickness then
return true
end
end
end
return false
end
-------------------------------------------------------------------------------------------------------------
function WinExec.GetToolsFromDB()
-- TODO gli utensili profilati devono essere messi in una lista a parte ad accesso diretto TOOLS['Prof1'] in modo da non dover scorrere la lista
-- dato che saranno molti e l'applicazione sarà diretta. Non serve ciclarli
-- creo lista globale utensili disponibili
TOOLS = {}
-- lista appoggio utensile
local Tool = {}
-- recupero tutti gli utensili : punte a forare, lame, frese e motoseghe
Tool.sName = EgtTdbGetFirstTool( MCH_TF.DRILLBIT + MCH_TF.SAWBLADE + MCH_TF.MILL + MCH_TF.MORTISE)
while Tool.sName ~= '' do
-- imposto utensile come corrente per recuperarne i dati
EgtTdbSetCurrTool( Tool.sName)
-- verifico se utensile disponibile in attrezzaggio attuale e che abbia un tipo ben definito
local bToolLoadedOnSetup, sToolTCPos = EgtFindToolInCurrSetup( Tool.sName)
local nToolTypeId = EgtTdbGetCurrToolParam( MCH_TP.TYPE)
local sToolType, sToolFamily = GetToolTypeNameFromToolTypeID( nToolTypeId)
-- se verifica condizioni minime, recupero tutti gli altri dati
if bToolLoadedOnSetup and sToolType then
-- TODO Tool.AName -> da rimuovere perchè non serve. Per il momento lo manteniamo solo perchè è più facile vedere e interpretare la lista utensili nella watch di zerobrane
-- Nell'utilizzo, si legge sempre il Tool.Name
Tool.AName = Tool.sName
Tool.sTcPos = sToolTCPos
Tool.sFamily = sToolFamily
Tool.sType = sToolType
Tool.nTypeId = nToolTypeId
Tool.dMaxMaterial = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)
Tool.dDiameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
Tool.dLength = EgtTdbGetCurrToolParam( MCH_TP.LEN)
Tool.dSpeed = EgtTdbGetCurrToolParam( MCH_TP.SPEED)
Tool.bIsCCW = Tool.dSpeed < 0
Tool.Feeds = {}
Tool.Feeds.dFeed = EgtTdbGetCurrToolParam( MCH_TP.FEED)
Tool.Feeds.dStartFeed = EgtTdbGetCurrToolParam( MCH_TP.STARTFEED)
Tool.Feeds.dEndFeed = EgtTdbGetCurrToolParam( MCH_TP.ENDFEED)
Tool.Feeds.dTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED)
-- TODO serve funzione in WinData che data la posizione dell'utensile e della testa, capisca il montaggio (testa sopra - testa sotto - aggregato - ecc...)
Tool.sHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD)
Tool.SetupInfo = {}
Tool.SetupInfo = WinData.GetSetupInfo( Tool.sHead)
Tool.sUUID = EgtTdbGetCurrToolParam( MCH_TP.UUID)
Tool.sUserNotes = EgtTdbGetCurrToolParam( MCH_TP.USERNOTES)
Tool.dMaxDepth = EgtTdbGetCurrToolMaxDepth() or Tool.dMaxMaterial
Tool.ToolHolder = {}
Tool.ToolHolder.dDiameter = EgtTdbGetCurrToolThDiam() or TH_DIAMETER_HSK63 -- diametro standard HSK63
Tool.ToolHolder.dLength = EgtTdbGetCurrToolThLength() or TH_LENGTH_HSK63 -- lunghezza standard HSK63
-- parametri scritti nelle note
Tool.nDouble = EgtGetValInNotes( Tool.sUserNotes, 'DOUBLE')
-- lettura parametri non comuni ( famiglia DRILLBIT non ha parametri specifici)
if sToolFamily ~= 'DRILLBIT' then
Tool.dThickness = EgtTdbGetCurrToolParam( MCH_TP.THICK)
Tool.dLongitudinalOffset = EgtTdbGetCurrToolParam( MCH_TP.LONOFFSET)
Tool.dRadialOffset = EgtTdbGetCurrToolParam( MCH_TP.RADOFFSET)
-- recupero parametri propri delle frese
if sToolFamily == 'MILL' then
Tool.dStemDiameter = EgtTdbGetCurrToolParam( MCH_TP.STEMDIAM) or Tool.ToolHolder.dDiameter -- se non settato, considero diametro come ToolHolder
Tool.dSideAngle = EgtTdbGetCurrToolParam( MCH_TP.SIDEANG) or 0
-- verifico che parametri siano compatibili con una fresa a coda di rondine ( angolo di fianco standard Coda di rondine -> 15°)
Tool.bIsDoveTail = Tool.Type == 'MILL_NOTIP' and abs( abs( Tool.dSideAngle) - SIDEANGLE_DOVETAIL) < 1
-- verifico che sia una fresa tipo T-Mill o BlockHaus
Tool.dSideDepth = EgtGetValInNotes( Tool.sUserNotes, 'SIDEDEPTH') or 0 -- se non settato nell'utensile, dico che non ha massimo affondamento laterale
Tool.bIsTMill = Tool.dSideDepth > 0
Tool.dStep = EgtGetValInNotes( Tool.sUserNotes, 'STEP') or ( Tool.dMaxMaterial / 3) -- se non settato nell'utensile, considero metà del tagliente
Tool.dSideStep = EgtGetValInNotes( Tool.sUserNotes, 'SIDESTEP') or floor( Tool.dDiameter / 3) -- se non settato nell'utensile, considero metà del diametro
Tool.bIsPen = abs( Tool.dSpeed) < 5
-- recupero parametri propri delle lame
elseif sToolFamily == 'SAWBLADE' then
Tool.bIsUsedForLongCut = EgtGetValInNotes( Tool.sUserNotes, 'LONGCUT') == 1 or false -- false coem valore di default
Tool.dStep = EgtGetValInNotes( Tool.sUserNotes, 'STEP') or Tool.dThickness -- se non settato nell'utensile, considero lo spessore lama
Tool.dSideStep = EgtGetValInNotes( Tool.sUserNotes, 'SIDESTEP') or Tool.dMaxMaterial -- se non settato nell'utensile, considero un quarto del diametro
-- recupero parametri propri delle motoseghe
elseif sToolFamily == 'MORTISE' then
Tool.dDistance = EgtTdbGetCurrToolParam( MCH_TP.DIST) or 90 -- 90mm dimensione standard aggregato catena
Tool.bIsMortise = EgtGetValInNotes( Tool.sUserNotes, 'MORTISE') == 1
Tool.bIsChainSaw = not Tool.bIsMortise
Tool.dStep = EgtGetValInNotes( Tool.sUserNotes, 'STEP') or floor( Tool.dMaxMaterial / 3) -- se non settato nell'utensile, considero un terzo della lunghezza
Tool.dSideStep = EgtGetValInNotes( Tool.sUserNotes, 'SIDESTEP') or ( Tool.dThickness - 1) -- se non settato nell'utensile, considero spessore catena meno 1mm di sicurezza
Tool.dCornerRadius = EgtTdbGetCurrToolParam( MCH_TP.CORNRAD)
Tool.dWidth = Tool.dDiameter
end
end
-- se tutti i dati necessari sono disponibili, inserisco utensile nella lista globale degli utensili disponibili
if IsToolOk( Tool) then
table.insert( TOOLS, Tool)
-- altrimenti scrivo nel log che l'utensile non è conforme
else
EgtOutLog( '*** ' .. Tool.sName .. ' : NOT-COMPLIANT ***', 1)
end
-- reset dati
Tool = {}
end
-- recupero utensile successivo ( punte a forare, lame, frese e motoseghe)
Tool.sName = EgtTdbGetNextTool( MCH_TF.DRILLBIT + MCH_TF.SAWBLADE + MCH_TF.MILL + MCH_TF.MORTISE)
end
end
-------------------------------------------------------------------------------------------------------------
-- *** Inserimento delle lavorazioni nelle travi ***
-------------------------------------------------------------------------------------------------------------
local function CollectFeatures( vProc, Part)
-- recupero le feature
local LayerId = {}
LayerId[1] = WinLib.GetAddGroup( Part.id)
LayerId[2] = EgtGetFirstNameInGroup( Part.id or GDB_ID.NULL, 'Processings')
for nInd = 1, 2 do
local ProcId = EgtGetFirstInGroup( LayerId[nInd] or GDB_ID.NULL)
while ProcId do
local nEntType = EgtGetType( ProcId)
if nEntType == GDB_TY.SRF_MESH or nEntType == GDB_TY.EXT_TEXT or
nEntType == GDB_TY.CRV_LINE or nEntType == GDB_TY.CRV_ARC or nEntType == GDB_TY.CRV_BEZ or nEntType == GDB_TY.CRV_COMPO then
local sType = EgtGetInfo( ProcId, 'FEATURE_TYPE', 's')
local nDo = EgtGetInfo( ProcId, 'DO', 'i') or 1
if sType and nDo == 1 then
local Proc = {}
Proc.idPart = Part.id
Proc.id = ProcId
Proc.nFlg = 1
Proc.sType = sType
Proc.b3Box = EgtGetBBoxGlob( ProcId, GDB_BB.STANDARD)
Proc.nPhase = EgtGetInfo( ProcId, 'PHASE', 'i') or nil
-- informazioni facce
Proc.AffectedFaces = WinLib.GetAffectedFaces( Proc, Part)
-- se esiste la geometria
if Proc.b3Box and not Proc.b3Box:isEmpty() then
-- calcolo dati specifici per tipologia di feature / lavorazione
-- se foro
if ID.IsDrilling( Proc) then
Proc = FeatureData.GetDrillingData( Proc)
end
-- se taglio
if ID.IsCutting( Proc) then
Proc = FeatureData.GetCuttingData( Proc)
end
-- se fresatura
if ID.IsMilling( Proc) then
Proc = FeatureData.GetMillingData( Proc)
end
-- se svuotatura
if ID.IsPocketing( Proc) then
Proc = FeatureData.GetPocketingData( Proc)
end
-- se profilatura
if ID.IsProfiling( Proc) then
Proc = FeatureData.GetProfilingData( Proc)
end
-- inserisco feature in lista
table.insert( vProc, Proc)
else
Proc.nFlg = 0
table.insert( vProc, Proc)
EgtOutLog( ' Feature ' .. tostring( Proc.idFeature) .. ' is empty (no geometry)')
end
end
end
ProcId = EgtGetNext( ProcId)
end
end
return vProc
end
-------------------------------------------------------------------------------------------------------------
local function GetFeatureInfoAndDependency( vProc, Part)
-- ciclo tutte le feature
for i = 1, #vProc do
local Proc = vProc[i]
-- controllo la feature con tutte le altre per recuperare le dipendenze
for j = 1, #vProc do
-- non si controlla la feature con se stessa
if i ~= j then
local ProcB = vProc[j]
-- TODO dipendenze da controllare :
-- * gruppo di forature con aggregato 2/3 uscite
-- * Se 'Left' e 'Out' hanno stesso profilo, vanno concatenati (anche 'Right' se consentito dalle dimensioni)
end
end
end
return vProc
end
-------------------------------------------------------------------------------------------------------------
-- Ordina le feature in base a fase di lavorazione
-- L'ordine è indicativamente:
-- 1) Tagli di testa
-- 2) Fori
-- 3) Scassi serratura/maniglia
-- 4) Profili testa
-- 5) Profili longitudinali
-- 6) Incontri/scontri
-- TODO Ordinamento da fare
local function OrderMachining( MACHININGS)
-- local vProcToSort = vProc
-- -- funzione di confronto. TRUE = B1 prima di B2. FALSE = B2 prima di B1
-- local function CompareFeatures( B1, B2)
-- -- se secondo disabilitato, va lasciato dopo
-- if B1.nFlg ~= 0 and B2.nFlg == 0 then
-- return true
-- elseif B1.nPhase and B2.nPhase and B1.nPhase < B2.nPhase then
-- return true
-- elseif B1.nPhase and B2.nPhase and B2.nPhase < B1.nPhase then
-- return true
-- -- altrimenti si inverte
-- else
-- return false
-- end
-- end
-- -- test della funzione di ordinamento
-- if EgtGetDebugLevel() >= 3 then
-- EgtOutLog( ' CompareFeatures Test ')
-- local bCompTest = true
-- for i = 1, #vProcToSort do
-- for j = i + 1, #vProcToSort do
-- local bComp1 = CompareFeatures( vProcToSort[i], vProcToSort[j])
-- local bComp2 = CompareFeatures( vProcToSort[j], vProcToSort[i])
-- if bComp1 == bComp2 then
-- bCompTest = false
-- EgtOutLog( string.format( ' ProcId : %d vs %d --> ERROR', vProcToSort[i].id, vProcToSort[j].id))
-- end
-- end
-- end
-- if bCompTest then
-- EgtOutLog( ' ALL OK')
-- end
-- end
-- -- eseguo ordinamento
-- table.sort( vProcToSort, CompareFeatures)
return true
end
-------------------------------------------------------------------------------------------------------------
-- applica le lavorazioni
local function AddMachinings( vProc, PARTS)
local bMachiningOk = true
for nFeatureIndex = 1, #vProc do
local Proc = vProc[nFeatureIndex]
local Part = PARTS[vProc[nFeatureIndex].nIndexPiece]
if ID.IsDrilling( Proc) then
bMachiningOk = Drilling.Make( Proc, Part)
end
-- se taglio
if ID.IsCutting( Proc) then
bMachiningOk = Cutting.Make( Proc, Part)
end
-- se fresatura
if ID.IsMilling( Proc) then
bMachiningOk = Milling.Make( Proc, Part)
end
-- se svuotatura
if ID.IsPocketing( Proc) then
bMachiningOk = Pocketing.Make( Proc, Part)
end
-- se profilatura
if ID.IsProfiling( Proc) then
bMachiningOk = Profiling.Make( Proc, Part)
end
end
return bMachiningOk
end
-------------------------------------------------------------------------------------------------------------
local function PrintFeatures( vProc, PARTS)
EgtOutLog( ' === PARTS ====')
for i = 1, #PARTS do
EgtOutLog( ' RawBox(' .. tostring( i) .. ') =' .. tostring( PARTS[i].RawBox))
end
EgtOutLog( ' === FEATURES ====')
for i = 1, #vProc do
local Proc = vProc[i]
local sOut = string.format( 'Id=%3d Flg=%2d Type=%s', Proc.id, Proc.nFlg, Proc.sType)
EgtOutLog( sOut)
end
end
-------------------------------------------------------------------------------------------------------------
local function CheckAndMovePawPart( nIdRawToMove, vtMove)
EgtMoveRawPart( nIdRawToMove, vtMove)
end
-------------------------------------------------------------------------------------------------------------
function WinExec.ProcessFeatures( PARTS)
-- ciclo sui pezzi
local nTotErr = 0
local Stats = {}
local vProc = {}
MACHININGS = {}
-- si recuperano tutte le feature di tutti i pezzi in una lista unica
for nPart = 1, #PARTS do
-- recupero le feature di lavorazione della trave
vProc = CollectFeatures( vProc, PARTS[nPart])
-- recupero informazioni ausiliarie feature e dipendenze tra feature dello stesso pezzo
vProc = GetFeatureInfoAndDependency( vProc, PARTS[nPart])
end
-- debug
if EgtGetDebugLevel() >= 1 then
PrintFeatures( vProc, PARTS)
end
EgtOutLog( ' *** AddMachinings ***', 1)
-- esegue le lavorazioni e le salva in lista
AddMachinings( vProc, PARTS)
-- ordina le lavorazioni
OrderMachining( MACHININGS)
-- scrivo lavorazioni prima fase
EgtSetCurrPhase( 1)
for i = 1, #MACHININGS do
if MACHININGS[i].AuxInfo.nPhase == 1 then
-- aggiunge effettivamente la lavorazione e restituisce gli ingombri
local bIsApplyOk, sErr, b3MachEncumbrance = MachiningLib.AddOperation( MACHININGS[i]) -- TODO ingombro lavorazione mi restituisce dati sbagliati. C'è un riferimento?
-- se feature di testa, sposto testa in base a ingombro lavorazione
if MACHININGS[i].Proc.bHeadProfile and b3MachEncumbrance then
local nIndexPart = ID.GetPieceIndexPart( PARTS, MACHININGS[i].Proc.idPart)
PARTS[nIndexPart].DispOffsets.Phase1.dOffsetX = b3MachEncumbrance:getMax():getX() - PARTS[nIndexPart].b3FinishedPart:getMin():getX() + 5
end
end
end
-- TODO lo spostamento, oltre a controllare le collisioni con il profilo di testa, deve anche considerare il pinzaggio del pezzo nel suo insieme?
-- Es.: basterebbe aggiungere un offset di 50mm per la testa, ma se metto 60mm, posso utilizzare una morsa in più che altrimenti avrei dovuto togliere per una collisione con una svuotatura
-- sposto pezzo per permettere pinzaggio migliore e non aver colisione in testa
for i = 1, #PARTS do
-- TODO Sbaglia a calcolare ingombro!!
--local vtMove = Vector3d( - PARTS[nIndexPart].DispOffsets.Phase1.dOffsetX, - PARTS[nIndexPart].DispOffsets.Phase1.dOffsetY, PARTS[nIndexPart].DispOffsets.Phase1.dOffsetZ)
local vtMove = Vector3d( -60, 0, 0)
if vtMove ~= V_NULL() then
CheckAndMovePawPart( PARTS[i].idRaw, vtMove)
end
end
-- scrivo lavorazioni seconda fase
EgtSetCurrPhase( 2)
for i = 1, #MACHININGS do
if MACHININGS[i].AuxInfo.nPhase == 2 then
-- aggiunge effettivamente la lavorazione
local bIsApplyOk, sErr, b3MachEncumbrance = MachiningLib.AddOperation( MACHININGS[i]) -- TODO ingombro lavorazione mi restituisce dati sbagliati. C'è un riferimento?
-- se feature di testa, sposto testa in base a ingombro lavorazione
if MACHININGS[i].Proc.bHeadProfile and b3MachEncumbrance then
local nIndexPart = ID.GetPieceIndexPart( PARTS, MACHININGS[i].Proc.idPart)
PARTS[nIndexPart].DispOffsets.Phase1.dOffsetX = PARTS[nIndexPart].b3FinishedPart:getMax():getX() - b3MachEncumbrance:getMin():getX() + 5
end
end
end
-- sposto pezzo per permettere pinzaggio migliore e non aver colisione in testa
for i = 1, #PARTS do
-- TODO Sbaglia a calcolare ingombro!!
-- local vtMove = Vector3d( PARTS[nIndexPart].DispOffsets.Phase2.dOffsetX, PARTS[nIndexPart].DispOffsets.Phase2.dOffsetY, PARTS[nIndexPart].DispOffsets.Phase2.dOffsetZ)
local vtMove = Vector3d( 60, 0, 0)
if vtMove ~= V_NULL() then
CheckAndMovePawPart( PARTS[i].idRaw, vtMove)
end
end
EgtOutLog( ' *** End AddMachinings ***', 1)
-- Aggiornamento finale di tutto
EgtSetCurrPhase( 1)
local bApplOk, sApplErrors, sApplWarns = EgtApplyAllMachinings()
if not bApplOk then
nTotErr = nTotErr + 1
table.insert( Stats, {nErr = 1, sMsg=sApplErrors})
end
return ( nTotErr == 0), Stats
end
-------------------------------------------------------------------------------------------------------------
return WinExec
+57
View File
@@ -0,0 +1,57 @@
-- WinLib.lua by Egalware s.r.l. 2024/06/14
-- Libreria globale per Serramenti
-- Tabella per definizione modulo
local WinLib = {}
-- Include
require( 'EgtBase')
local WinData = require( 'WinData')
EgtOutLog( ' WinLib started', 1)
-------------------------------------------------------------------------------------------------------------
-- restituisce le facce della parte interessate dalla feature Proc
function WinLib.GetAffectedFaces( Proc, Part)
local vtFacesAffected = { bTop = false, bBottom = false, bFront = false, bBack = false, bLeft = false, bRight = false}
if Proc.b3Box and not Proc.b3Box:isEmpty() then
if Proc.b3Box:getMax():getZ() > Part.b3Solid:getMax():getZ() - 500 * GEO.EPS_SMALL then
vtFacesAffected.bTop = true
end
if Proc.b3Box:getMin():getZ() < Part.b3Solid:getMin():getZ() + 500 * GEO.EPS_SMALL then
vtFacesAffected.bBottom = true
end
if Proc.b3Box:getMin():getY() < Part.b3Solid:getMin():getY() + 500 * GEO.EPS_SMALL then
vtFacesAffected.bFront = true
end
if Proc.b3Box:getMax():getY() > Part.b3Solid:getMax():getY() - 500 * GEO.EPS_SMALL then
vtFacesAffected.bBack = true
end
if Proc.b3Box:getMin():getX() < Part.b3Solid:getMin():getX() + 500 * GEO.EPS_SMALL then
vtFacesAffected.bLeft = true
end
if Proc.b3Box:getMax():getX() > Part.b3Solid:getMax():getX() - 500 * GEO.EPS_SMALL then
vtFacesAffected.bRight = true
end
end
return vtFacesAffected
end
-------------------------------------------------------------------------------------------------------------
function WinLib.GetAddGroup( PartId)
-- recupero il nome del gruppo di lavoro corrente
local sMchGrp = EgtGetMachGroupName( EgtGetCurrMachGroup() or GDB_ID.NULL)
if not sMchGrp then
return nil, nil
end
-- cerco il gruppo aggiuntivo omonimo nel pezzo e se esiste lo restituisco
local AddGrpId = EgtGetFirstNameInGroup( PartId or GDB_ID.NULL, sMchGrp)
-- restituisco Id e Nome
return AddGrpId, sMchGrp
end
-------------------------------------------------------------------------------------------------------------
return WinLib
+321
View File
@@ -0,0 +1,321 @@
-- Process.lua by Egalware s.r.l. 2024/06/13
-- Gestione calcolo disposizione e lavorazioni per serramenti
-- Si opera sulla macchina corrente
-- 2024/06/13 PRIMA VERSIONE
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( true)
-- TODO da cancellare quando verrà passato automaticamente da programma
local WIN = {}
WIN.BASEDIR = 'C:\\EgtData\\EgwWindowLua\\CAMAuto'
-- Imposto direttorio libreria specializzata per serramenti
EgtAddToPackagePath( WIN.BASEDIR .. '\\LuaLibs\\?.lua')
-- Imposto direttorio strategie. N.B. Le strategie dovranno essere caricate con il nome del direttorio padre
EgtAddToPackagePath( WIN.BASEDIR .. '\\Strategies\\?.lua')
-- Verifico che la macchina corrente sia abilitata per la lavorazione delle Travi
local sMachDir = EgtGetCurrMachineDir()
if not sMachDir then
EgtOutBox( 'Errore nel caricamento della macchina corrente', 'Lavora Serramenti', 'ERROR')
return
end
if not EgtExistsFile( sMachDir .. '\\Window\\WinData.lua') then
EgtOutBox( 'La macchina corrente non è configurata per lavorare serramenti', 'Lavora Serramenti', 'ERROR')
return
end
-- Elimino direttori altre macchine e imposto direttorio macchina corrente per ricerca librerie
EgtRemoveBaseMachineDirFromPackagePath()
EgtAddToPackagePath( sMachDir .. '\\Window\\?.lua')
-- Segnalazione avvio
EgtOutLog( '*** Window Process Start ***', 1)
-- Carico le librerie
_G.package.loaded.WinData = nil
_G.package.loaded.WinExec = nil
_G.package.loaded.WinLib = nil
_G.package.loaded.FeatureData = nil
_G.package.loaded.MachiningLib = nil
local WinExec = require( 'WinExec')
-- Carico i dati globali
local WinData = require( 'WinData')
-- Variabili globali
PARTS = {}
-- Colore del grezzo
local ColA = Color3d( 255, 165, 0, 30)
-------------------------------------------------------------------------------------------------------------
-- *** Recupero i pezzi da processare ***
-------------------------------------------------------------------------------------------------------------
local function MyProcessInputData()
-- Recupero le travi selezionate
local nId = EgtGetFirstSelectedObj()
while nId do
local nPartId = EgtGetParent( EgtGetParent( nId or GDB_ID.NULL) or GDB_ID.NULL)
if nPartId then
local bFound = false
for i = 1, #PARTS do
if PARTS[i].id == nPartId then
bFound = true
break
end
end
if not bFound then
table.insert( PARTS, { nInd = #PARTS + 1, id = nPartId, sName = ( EgtGetName( nPartId) or ( 'Id=' .. tonumber( nPartId)))})
end
end
nId = EgtGetNextSelectedObj()
end
if #PARTS == 0 then
EgtOutBox( 'Non sono state selezionati pezzi', 'Lavora Pezzi', 'ERROR')
return false
else
-- recupero tutte le dimensioni necessarie
local sOut = ''
for i = 1, #PARTS do
PARTS[i].b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[i].id, 'Solid') or GDB_ID.NULL, GDB_BB.STANDARD)
PARTS[i].b3FinishedPart = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[i].id, 'Geo') or GDB_ID.NULL, GDB_BB.STANDARD)
local idFrame = EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( PARTS[i].id, 'Geo'), 'AuxFrame') or EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( PARTS[i].id, 'Geo'), 'Frame')
PARTS[i].frame = EgtFR( idFrame)
sOut = sOut .. PARTS[i].sName .. ', '
end
sOut = sOut:sub( 1, -3)
EgtOutLog( 'Pezzi selezionati : ' .. sOut, 1)
end
EgtDeselectAll()
return true
end
-------------------------------------------------------------------------------------------------------------
local function GetDataConfig()
-- recupero utensili dal magazzino
WinExec.GetToolsFromDB()
-- TODO da gestire eventuali errori bloccanti
return true
end
-------------------------------------------------------------------------------------------------------------
local function UpdateRawPosition( PARTS)
for i = 1, #PARTS do
PARTS[i].b3FinishedPart = EgtGetBBoxGlob( PARTS[i].id or GDB_ID.NULL, GDB_BB.STANDARD)
PARTS[i].b3RawPart = EgtGetBBoxGlob( PARTS[i].idRaw or GDB_ID.NULL, GDB_BB.STANDARD)
end
end
-------------------------------------------------------------------------------------------------------------
local function GetDispOffsetFromNotes( nPieceIndex)
local bAllOffsetsAreOk = false
PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetX = 0 -- dovrà essere calcolato in base alle lavorazioni
PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetY = EgtGetInfo( PARTS[nPieceIndex].id, 'OFFY_1', 'd')
PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetZ = EgtGetInfo( PARTS[nPieceIndex].id, 'OFFZ_1', 'd')
PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetX = 0 -- dovrà essere calcolato in base alle lavorazioni
PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetY = EgtGetInfo( PARTS[nPieceIndex].id, 'OFFY_2', 'd')
PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetZ = EgtGetInfo( PARTS[nPieceIndex].id, 'OFFZ_2', 'd')
-- controllo se tutti gli offset siano settati
if PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetY and PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetZ and
PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetY and PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetZ then
bAllOffsetsAreOk = true
end
return bAllOffsetsAreOk
end
-------------------------------------------------------------------------------------------------------------
local function GetDispOffsetFromInput( nPieceIndex)
-- assegno alle stringhe i valori letti, in modo che vengano proposti quelli nel dialogo
local sOffYPh1 = EgtIf( PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetY, tostring( PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetY), tostring( PARTS[nPieceIndex].dPartWidth / 2))
local sOffZPh1 = EgtIf( PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetZ, tostring( PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetZ), '0')
local sOffYPh2 = EgtIf( PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetY, tostring( PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetY), tostring( PARTS[nPieceIndex].dPartWidth / 2))
local sOffZPh2 = EgtIf( PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetZ, tostring( PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetZ), '0')
local vInp = EgtDialogBox( 'Dati di disposizione pezzo: ' .. PARTS[nPieceIndex].sName,
{'Sporgenza laterale FASE1', sOffYPh1}, {'Posizione Z FASE1', sOffZPh1},
{'Sporgenza laterale FASE2', sOffYPh2}, {'Posizione Z FASE2', sOffZPh2})
if not vInp or #vInp == 0 then
return false
end
-- salvo input nei valori che utilizzerò dopo
PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetY = tonumber( vInp[1])
PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetZ = tonumber( vInp[2])
PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetY = tonumber( vInp[3])
PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetZ = tonumber( vInp[4])
return true
end
---------------------------------------------------------------------
-- Crea il grezzo che verrà messo in macchina
---------------------------------------------------------------------
local function AddOverMaterialToRaw( PARTS)
for i = 1, #PARTS do
-- prima di aggiungere sovramateriale al grezzo, calcolo dimensioni del finito
local b3FinishedPart = EgtGetBBoxGlob( PARTS[i].id or GDB_ID.NULL, GDB_BB.STANDARD)
PARTS[i].b3FinishedPart = b3FinishedPart
PARTS[i].dPartLength = PARTS[i].b3FinishedPart:getDimX()
PARTS[i].dPartWidth = PARTS[i].b3FinishedPart:getDimY()
PARTS[i].dPartHeight = PARTS[i].b3FinishedPart:getDimZ()
-- recupero e aggiungo offset
PARTS[i].RawOffset = {}
-- recupero info sovramateriale
PARTS[i].RawOffset.dOverMatIn = EgtGetInfo( PARTS[i].id, 'OVERMAT_IN', 'd') or 5
PARTS[i].RawOffset.dOverMatOut = EgtGetInfo( PARTS[i].id, 'OVERMAT_OUT', 'd') or 5
PARTS[i].RawOffset.dOverMatLeft = EgtGetInfo( PARTS[i].id, 'OVERMAT_LEFT', 'd') or 5
PARTS[i].RawOffset.dOverMatRight = EgtGetInfo( PARTS[i].id, 'OVERMAT_RIGHT', 'd') or 5
PARTS[i].dRawLength = PARTS[i].RawOffset.dOverMatLeft + PARTS[i].dPartLength + PARTS[i].RawOffset.dOverMatRight
PARTS[i].dRawWidth = PARTS[i].RawOffset.dOverMatOut + PARTS[i].dPartWidth + PARTS[i].RawOffset.dOverMatIn
PARTS[i].dRawHeight = PARTS[i].dPartHeight
EgtModifyRawPartSize( PARTS[i].idRaw, PARTS[i].dRawLength, PARTS[i].dRawWidth, PARTS[i].dPartHeight)
local vtMove = Vector3d( PARTS[i].RawOffset.dOverMatLeft, PARTS[i].RawOffset.dOverMatOut, 0)
EgtMovePartInRawPart( PARTS[i].id, vtMove)
-- TODO da controllare, se ruotato di 180° bisognerebbe prendere dOverMatIn. Lo stesso per la X
PARTS[i].OffsetPartToRaw = {}
PARTS[i].OffsetPartToRaw.X = PARTS[i].RawOffset.dOverMatLeft
PARTS[i].OffsetPartToRaw.Y = PARTS[i].RawOffset.dOverMatOut
end
end
---------------------------------------------------------------------
-- Crea il grezzo che verrà messo in macchina
---------------------------------------------------------------------
local function CreateRaws( PARTS)
for i = 1, #PARTS do
-- si crea un grezzo "finto" (un cubo da 100mm) nell'origine del pezzo, verrà poi dimensionato uan volta adeguato con i vari sovramateriali
PARTS[i].idRaw = EgtAddRawPart( PARTS[i].frame:getOrigin(), 100, 100, 100, ColA)
EgtAddPartToRawPart( PARTS[i].id, ORIG(), PARTS[i].idRaw)
end
end
---------------------------------------------------------------------
-- Allinea i pezzi in base a come devono essere disposti sulla tavola
---------------------------------------------------------------------
-- TODO in questa fase bisogna già sapere qual è la prima fase e posizionare il pezzo di conseguenza
-- TODO (bassa priorità) adesso allinea sempre in X, ma bisognerebbe farlo in base ad un parametro in WINDATA che dice come si dispongono in macchina
local function AlignRawsToTable( PARTS)
for i = 1, #PARTS do
-- allineo il pezzo all'interno del grezzo
local dRotX, dRotY, dRotZ = GetFixedAxesRotABCFromFrame( PARTS[i].frame)
-- se devo ruotare
if dRotZ ~= 0 then
EgtRotatePartInRawPart( PARTS[i].id, Z_AX(), -dRotZ)
-- sposto punto in basso a sinistra del pezzo sul punto in basso a sinistra del grezzo
local dPartPosX = EgtGetBBoxGlob( PARTS[i].id, GDB_BB.STANDARD):getMin():getX()
local dPartPosY = EgtGetBBoxGlob( PARTS[i].id, GDB_BB.STANDARD):getMin():getY()
local dRawPosX = EgtGetRawPartBBox( PARTS[i].idRaw):getMin():getX()
local dRawPosY = EgtGetRawPartBBox( PARTS[i].idRaw):getMin():getY()
local vtMove = Vector3d( dRawPosX - dPartPosX, dRawPosY - dPartPosY, 0)
EgtMovePartInRawPart( PARTS[i].id, vtMove)
end
end
return true
end
-------------------------------------------------------------------------------------------------------------
-- *** Funzione per trovare nome MachGroup ***
-------------------------------------------------------------------------------------------------------------
local function NewMachGroupName()
local nMachGroupId = EgtGetFirstMachGroup()
if not nMachGroupId then return 1 end
local nMaxMachGroup = 0
while nMachGroupId do
local sMachGroupName = EgtGetMachGroupName(nMachGroupId)
local nMachGroupName = tonumber(sMachGroupName)
if nMachGroupName > nMaxMachGroup then
nMaxMachGroup = nMachGroupName
end
nMachGroupId = EgtGetNextMachGroup(nMachGroupId)
end
return nMaxMachGroup + 1
end
-------------------------------------------------------------------------------------------------------------
-- *** Inserimento delle travi nel grezzo ***
-------------------------------------------------------------------------------------------------------------
local function MyProcessPieces()
-- creo macchinata
local MachGroupName = NewMachGroupName()
local nMachGroup = EgtAddMachGroup( MachGroupName)
-- si crea il grezzo
CreateRaws( PARTS)
-- allineo i pezzi come orientamento richiesto dalla macchina
AlignRawsToTable( PARTS)
-- aggiungo sovramateriale ai grezzi
AddOverMaterialToRaw( PARTS)
-- recupero offset per posizionamento
for i = 1, #PARTS do
PARTS[i].DispOffsets = {}
PARTS[i].DispOffsets.Phase1 = {}
PARTS[i].DispOffsets.Phase2 = {}
local bInsertedAllOffs = GetDispOffsetFromNotes( i)
-- se non sono settati nelle note, li chiedo
if not bInsertedAllOffs then
bInsertedAllOffs = GetDispOffsetFromInput( i)
end
-- se non sono stati inseriti o c'è stato un errore esco subito
if not bInsertedAllOffs then
return false
end
end
-- si dispongono i pezzi sulla tavola
WinData.ExecDisposition( PARTS)
UpdateRawPosition( PARTS)
-- Impostazione dell'attrezzaggio di default
-- TODO se lascio il campo vuoto non mi carica il default!!!!!!!
local bOk = EgtImportSetup( 'CIAO')
return true
end
-------------------------------------------------------------------------------------------------------------
-- *** Inserimento delle lavorazioni ***
-------------------------------------------------------------------------------------------------------------
local function MyProcessFeatures()
local bOk = WinExec.ProcessFeatures( PARTS)
return true
end
-------------------------------------------------------------------------------------------------------------
-- *** Esecuzione ***
-------------------------------------------------------------------------------------------------------------
if not MyProcessInputData() then return end
if not MyProcessPieces() then return end
if not GetDataConfig() then return end
-- Abilito Vmill
EgtSetInfo( EgtGetCurrMachGroup(), 'Vm', '1')
if not MyProcessFeatures() then return end
+22
View File
@@ -0,0 +1,22 @@
-- Cutting.lua by Egalware s.r.l. 2024/06/13
-- Libreria esecuzione lavorazioni per Serramenti -> Lavorazione di taglio
-- Tabella per definizione modulo
local Cutting = {}
-- Include
require( 'EgtBase')
-- Carico i dati globali
local WinData = require( 'WinData')
EgtOutLog( ' Cutting started', 1)
EgtMdbSave()
-------------------------------------------------------------------------------------------------------------
function Cutting.Make( Proc, Part)
return true
end
-------------------------------------------------------------------------------------------------------------
return Cutting
+22
View File
@@ -0,0 +1,22 @@
-- Drilling.lua by Egalware s.r.l. 2024/06/13
-- Libreria esecuzione lavorazioni per Serramenti -> Lavorazione di foratura
-- Tabella per definizione modulo
local Drilling = {}
-- Include
require( 'EgtBase')
-- Carico i dati globali
local WinData = require( 'WinData')
EgtOutLog( ' Drilling started', 1)
EgtMdbSave()
-------------------------------------------------------------------------------------------------------------
function Drilling.Make( Proc, Part)
return true
end
-------------------------------------------------------------------------------------------------------------
return Drilling
+22
View File
@@ -0,0 +1,22 @@
-- Milling.lua by Egalware s.r.l. 2024/06/13
-- Libreria esecuzione lavorazioni per Serramenti -> Lavorazione di fresatura
-- Tabella per definizione modulo
local Milling = {}
-- Include
require( 'EgtBase')
-- Carico i dati globali
local WinData = require( 'WinData')
EgtOutLog( ' Milling started', 1)
EgtMdbSave()
-------------------------------------------------------------------------------------------------------------
function Milling.Make( Proc, Part)
return true
end
-------------------------------------------------------------------------------------------------------------
return Milling
+22
View File
@@ -0,0 +1,22 @@
-- Pocketing.lua by Egalware s.r.l. 2024/06/13
-- Libreria esecuzione lavorazioni per Serramenti -> Lavorazione di svuotatura
-- Tabella per definizione modulo
local Pocketing = {}
-- Include
require( 'EgtBase')
-- Carico i dati globali
local WinData = require( 'WinData')
EgtOutLog( ' Pocketing started', 1)
EgtMdbSave()
-------------------------------------------------------------------------------------------------------------
function Pocketing.Make( Proc, Part)
return true
end
-------------------------------------------------------------------------------------------------------------
return Pocketing
+62
View File
@@ -0,0 +1,62 @@
-- Profiling.lua by Egalware s.r.l. 2024/06/13
-- Libreria esecuzione lavorazioni per Serramenti -> Lavorazione di profilatura
-- Tabella per definizione modulo
local Profiling = {}
-- Include
require( 'EgtBase')
-- Carico i dati globali
local WinData = require( 'WinData')
local MachiningLib = require( 'MachiningLib')
EgtOutLog( ' Profiling started', 1)
EgtMdbSave()
-------------------------------------------------------------------------------------------------------------
function Profiling.Make( Proc, Part)
local ToolInfo = {}
-- se so che utensili utilizzare, associazione diretta
if Proc.nToolsToUse then
for i = 1, Proc.nToolsToUse do
local Machining = {}
local AuxInfo = {}
Machining.LeadIn = {}
Machining.LeadOut = {}
Machining.Steps = {}
local ToolSearchParameters = {}
ToolSearchParameters.sName = Proc.Tools[i].sName
ToolSearchParameters.dElevation = 0
ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters)
-- se trovato utensile
if ToolInfo.nToolIndex then
Machining.nType = MCH_MY.MILLING
Machining.nWorkSide = MCH_MILL_WS.RIGHT
Machining.nToolIndex = ToolInfo.nToolIndex
Machining.sDepth = 0
Machining.dRadialOffset = Proc.Tools[i].dRadialOffset
Machining.dLongitudinalOffset = Proc.Tools[i].dLongitudinalOffset
Machining.LeadIn.nType = MCH_MILL_LI.TANGENT
Machining.LeadIn.dTangentDistance = TOOLS[ToolInfo.nToolIndex].dDiameter
Machining.LeadIn.dPerpDistance = TOOLS[ToolInfo.nToolIndex].dDiameter
Machining.LeadOut.nType = MCH_MILL_LO.TANGENT
Machining.LeadOut.dTangentDistance = TOOLS[ToolInfo.nToolIndex].dDiameter
Machining.LeadOut.dPerpDistance = 0
Machining.Geometry = Proc.id
AuxInfo.nPhase = MachiningLib.GetPhaseMach( Proc)
MachiningLib.AddNewMachining( Proc, Machining, AuxInfo)
else
return false, 'Tool not found'
end
end
-- altrimenti cerco tra quelli disponibili
else
; --per il momento non serve. Le info sull'utensile arrivano sempre
end
return true
end
-------------------------------------------------------------------------------------------------------------
return Profiling
+75 -67
View File
@@ -57,9 +57,17 @@ EgtNewFile()
-- importo profilo prescelto
WinCreate.ImportProfile( sProfilePath)
-- creo telaio rettangolare
-- creo telaio generico
local FrameJointType = WIN_JNT.FULL_H
local nFrameId = WinCreate.CreateFrame( WindowWidth, WindowHeight, FrameJointType, FrameJointType, FrameJointType, FrameJointType)
local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPE.RECT, FrameJointType, FrameJointType, FrameJointType, FrameJointType, WindowWidth, WindowHeight)
-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPE.CHAMFER_SIDE, FrameJointType, FrameJointType, FrameJointType, FrameJointType, WindowWidth, WindowHeight, WindowHeight + 500)
-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPE.CHAMFER_SIDE, FrameJointType, FrameJointType, FrameJointType, FrameJointType, WindowWidth, WindowHeight + 500, WindowHeight)
-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPE.CHAMFER, FrameJointType, FrameJointType, FrameJointType, FrameJointType, WindowWidth, WindowHeight, WindowHeight + 500)
-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPE.ROUND_ARC, FrameJointType, FrameJointType, FrameJointType, FrameJointType, WindowWidth, WindowHeight)
-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPE.SEGMENTAL_ARC, FrameJointType, FrameJointType, FrameJointType, FrameJointType, WindowWidth, WindowHeight, WindowHeight + 100)
-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPE.POINTED_ARC, FrameJointType, FrameJointType, FrameJointType, FrameJointType, WindowWidth, WindowHeight, WindowHeight + 600)
-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPE.TRG, FrameJointType, FrameJointType, WIN_JNT.ANGLED, WIN_JNT.ANGLED, WindowWidth, WindowHeight, 0)
-- -- creo telaio generico
-- local nDrawFramePartId = EgtGroup( GDB_ID.ROOT)
@@ -71,23 +79,23 @@ local nFrameId = WinCreate.CreateFrame( WindowWidth, WindowHeight, FrameJointTyp
-- --local nFrameTopId = EgtLine( nDrawFrameLayerId, Point3d( WindowWidth, WindowHeight, 0), Point3d( 0, WindowHeight, 0))
-- local nFrameLeftId = EgtLine( nDrawFrameLayerId, Point3d( 0, WindowHeight, 0), Point3d( 0, 0, 0))
-- local FrameJointType = WIN_JNT.ANGLED
-- local nFrameId = WinCreate.CreateGenFrame( nFrameBottomId, nFrameRightId, nFrameTopId, nFrameLeftId, FrameJointType, FrameJointType, FrameJointType, FrameJointType)
-- local nFrameId = WinCreate.CreateGenFrame( {nFrameBottomId, nFrameRightId, nFrameTopId, nFrameLeftId}, FrameJointType, FrameJointType, FrameJointType, FrameJointType)
------------------------ Finestra vetro fisso ------------------------
-- -- aggiungo zoccolo
-- WinCreate.AddBottomRail( nFrameId)
-- -- aggiungo vetro
-- local nFillId = WinCreate.AddFill( nFrameId, WIN_FILLTYPES.GLASS)
-- aggiungo zoccolo
WinCreate.AddBottomRail( nFrameId)
-- aggiungo vetro
local nFillId = WinCreate.AddFill( nFrameId, WIN_FILLTYPES.GLASS)
------------------------ Finestra vetro fisso con divisione orizzontale ------------------------
-- -- aggiungo zoccolo
-- WinCreate.AddBottomRail( nFrameId)
--
-- -- definisco prima divisione
-- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 2)
--
-- -- aggiungo vetri
-- local nFill1Id = WinCreate.AddFill( nArea1Id, WIN_FILLTYPES.GLASS)
-- local nFill2Id = WinCreate.AddFill( nArea2Id, WIN_FILLTYPES.GLASS)
@@ -96,10 +104,10 @@ local nFrameId = WinCreate.CreateFrame( WindowWidth, WindowHeight, FrameJointTyp
-- -- aggiungo zoccolo
-- WinCreate.AddBottomRail( nFrameId)
--
-- -- definisco prima divisione
-- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 2)
--
-- -- aggiungo vetri
-- local nFill1Id = WinCreate.AddFill( nArea1Id, WIN_FILLTYPES.GLASS)
-- local nFill2Id = WinCreate.AddFill( nArea2Id, WIN_FILLTYPES.GLASS)
@@ -108,36 +116,36 @@ local nFrameId = WinCreate.CreateFrame( WindowWidth, WindowHeight, FrameJointTyp
-- -- aggiungo zoccolo
-- WinCreate.AddBottomRail( nFrameId)
--
-- -- definisco divisioni
-- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 2)
-- local nArea11Id, nArea12Id = WinCreate.AddSplit( nArea1Id, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 2)
-- local nArea21Id, nArea22Id = WinCreate.AddSplit( nArea2Id, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 2)
--
-- -- aggiungo vetri
-- local nFill1Id = WinCreate.AddFill( nArea11Id, WIN_FILLTYPES.GLASS)
-- local nFill2Id = WinCreate.AddFill( nArea12Id, WIN_FILLTYPES.GLASS)
-- local nFill3Id = WinCreate.AddFill( nArea21Id, WIN_FILLTYPES.GLASS)
-- local nFill4Id = WinCreate.AddFill( nArea22Id, WIN_FILLTYPES.GLASS)
-- ------------------------ Finestra anta singola ------------------------
------------------------ Finestra anta singola ------------------------
-- aggiungo anta
local SashJointType = WIN_JNT.FULL_V
local nSashId = WinCreate.AddSash( nFrameId, SashJointType, SashJointType, SashJointType, SashJointType)
-- aggiungo vetro
local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS)
-- -- aggiungo anta
-- local SashJointType = WIN_JNT.FULL_V
-- local nSashId = WinCreate.AddSash( nFrameId, SashJointType, SashJointType, SashJointType, SashJointType)
--
-- -- aggiungo vetro
-- local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS)
------------------------ Finestra anta singola con divisione orizzontale ------------------------
-- -- aggiungo anta
-- local SashJointType = WIN_JNT.FULL_V
-- local nSashId = WinCreate.AddSash( nFrameId, SashJointType, SashJointType, SashJointType, SashJointType)
--
-- -- definisco prima divisione
-- local nArea1Id, nArea2Id = WinCreate.AddSplit( nSashId, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 3)
--
-- -- aggiungo vetri
-- local nFill1Id = WinCreate.AddFill( nArea1Id, WIN_FILLTYPES.GLASS)
-- local nFill2Id = WinCreate.AddFill( nArea2Id, WIN_FILLTYPES.GLASS)
@@ -147,10 +155,10 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS)
-- -- aggiungo anta
-- local SashJointType = WIN_JNT.FULL_V
-- local nSashId = WinCreate.AddSash( nFrameId, SashJointType, SashJointType, SashJointType, SashJointType)
--
-- -- definisco prima divisione
-- local nArea1Id, nArea2Id = WinCreate.AddSplit( nSashId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 2)
--
-- -- aggiungo vetri
-- local nFill1Id = WinCreate.AddFill( nArea1Id, WIN_FILLTYPES.GLASS)
-- local nFill2Id = WinCreate.AddFill( nArea2Id, WIN_FILLTYPES.GLASS)
@@ -160,12 +168,12 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS)
-- -- aggiungo anta
-- local SashJointType = WIN_JNT.FULL_V
-- local nSashId = WinCreate.AddSash( nFrameId, SashJointType, SashJointType, SashJointType, SashJointType)
--
-- -- definisco divisioni
-- local nArea1Id, nArea2Id = WinCreate.AddSplit( nSashId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 2)
-- local nArea11Id, nArea12Id = WinCreate.AddSplit( nArea1Id, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 2)
-- local nArea21Id, nArea22Id = WinCreate.AddSplit( nArea2Id, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 2)
--
-- -- aggiungo vetri
-- local nFill1Id = WinCreate.AddFill( nArea11Id, WIN_FILLTYPES.GLASS)
-- local nFill2Id = WinCreate.AddFill( nArea12Id, WIN_FILLTYPES.GLASS)
@@ -198,17 +206,17 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS)
-- -- definisco prima divisione
-- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 2)
--
-- -- aggiungo prima anta
-- local SashJointType = WIN_JNT.FULL_V
-- local nSash1Id = WinCreate.AddSash( nArea1Id, SashJointType, SashJointType, SashJointType, SashJointType)
--
-- -- aggiungo vetro
-- local nFill1Id = WinCreate.AddFill( nSash1Id, WIN_FILLTYPES.GLASS)
--
-- -- aggiungo seconda anta
-- local nSash2Id = WinCreate.AddSash( nArea2Id, SashJointType, SashJointType, SashJointType, SashJointType)
--
-- -- aggiungo vetro
-- local nFill2Id = WinCreate.AddFill( nSash2Id, WIN_FILLTYPES.GLASS)
@@ -216,17 +224,17 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS)
-- -- definisco prima divisione
-- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 2, _, WIN_SPLITTYPES.FRENCH)
--
-- -- aggiungo prima anta
-- local SashJointType = WIN_JNT.FULL_V
-- local nSash1Id = WinCreate.AddSash( nArea1Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.INACTIVE)
--
-- -- aggiungo vetro
-- local nFill1Id = WinCreate.AddFill( nSash1Id, WIN_FILLTYPES.GLASS)
--
-- -- aggiungo seconda anta
-- local nSash2Id = WinCreate.AddSash( nArea2Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.ACTIVE)
--
-- -- aggiungo vetro
-- local nFill2Id = WinCreate.AddFill( nSash2Id, WIN_FILLTYPES.GLASS)
@@ -251,27 +259,27 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS)
------------------------ Finestra tripla anta con montanti verticali ------------------------
-- -- definisco prima divisione
-- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3)
-- local nArea1Id, nArea0Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3)
--
-- -- definisco seconda divisione
-- local nArea2Id, nArea3Id = WinCreate.AddSplit( nArea2Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3)
-- local nArea2Id, nArea3Id = WinCreate.AddSplit( nArea0Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3)
--
-- -- aggiungo prima anta
-- local SashJointType = WIN_JNT.FULL_V
-- local nSash1Id = WinCreate.AddSash( nArea1Id, SashJointType, SashJointType, SashJointType, SashJointType)
--
-- -- aggiungo vetro
-- local nFill1Id = WinCreate.AddFill( nSash1Id, WIN_FILLTYPES.GLASS)
--
-- -- aggiungo seconda anta
-- local nSash2Id = WinCreate.AddSash( nArea2Id, SashJointType, SashJointType, SashJointType, SashJointType)
--
-- -- aggiungo vetro
-- local nFill2Id = WinCreate.AddFill( nSash2Id, WIN_FILLTYPES.GLASS)
--
-- -- aggiungo terza anta
-- local nSash3Id = WinCreate.AddSash( nArea3Id, SashJointType, SashJointType, SashJointType, SashJointType)
--
-- -- aggiungo vetro
-- local nFill3Id = WinCreate.AddFill( nSash3Id, WIN_FILLTYPES.GLASS)
@@ -307,27 +315,27 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS)
------------------------ Finestra tripla anta con montante verticale e ante battente e ricevente ------------------------
-- -- definisco prima divisione
-- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3)
-- local nArea1Id, nArea0Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3)
--
-- -- definisco seconda divisione
-- local nArea2Id, nArea3Id = WinCreate.AddSplit( nArea2Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3, _, WIN_SPLITTYPES.FRENCH)
-- local nArea2Id, nArea3Id = WinCreate.AddSplit( nArea0Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3, _, WIN_SPLITTYPES.FRENCH)
--
-- -- aggiungo prima anta
-- local SashJointType = WIN_JNT.FULL_V
-- local nSash1Id = WinCreate.AddSash( nArea1Id, SashJointType, SashJointType, SashJointType, SashJointType)
--
-- -- aggiungo vetro
-- local nFill1Id = WinCreate.AddFill( nSash1Id, WIN_FILLTYPES.GLASS)
--
-- -- aggiungo seconda anta
-- local nSash2Id = WinCreate.AddSash( nArea2Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.INACTIVE)
--
-- -- aggiungo vetro
-- local nFill2Id = WinCreate.AddFill( nSash2Id, WIN_FILLTYPES.GLASS)
--
-- -- aggiungo terza anta
-- local nSash3Id = WinCreate.AddSash( nArea3Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.ACTIVE)
--
-- -- aggiungo vetro
-- local nFill3Id = WinCreate.AddFill( nSash3Id, WIN_FILLTYPES.GLASS)
@@ -335,26 +343,26 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS)
-- -- definisco prima divisione
-- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 3)
--
-- -- definisco seconda divisione
-- local nArea2Id, nArea3Id = WinCreate.AddSplit( nArea2Id, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 3)
--
-- -- aggiungo prima anta
-- local SashJointType = WIN_JNT.FULL_V
-- local nSash1Id = WinCreate.AddSash( nArea1Id, SashJointType, SashJointType, SashJointType, SashJointType)
--
-- -- aggiungo vetro
-- local nFill1Id = WinCreate.AddFill( nSash1Id, WIN_FILLTYPES.GLASS)
--
-- -- aggiungo seconda anta
-- local nSash2Id = WinCreate.AddSash( nArea2Id, SashJointType, SashJointType, SashJointType, SashJointType)
--
-- -- aggiungo vetro
-- local nFill2Id = WinCreate.AddFill( nSash2Id, WIN_FILLTYPES.GLASS)
--
-- -- aggiungo terza anta
-- local nSash3Id = WinCreate.AddSash( nArea3Id, SashJointType, SashJointType, SashJointType, SashJointType)
--
-- -- aggiungo vetro
-- local nFill3Id = WinCreate.AddFill( nSash3Id, WIN_FILLTYPES.GLASS)
@@ -461,39 +469,39 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS)
-- -- definisco divisione orizzontale
-- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 2)
--
-- -- definisco divisioni verticali
-- local nArea11Id, nArea12Id = WinCreate.AddSplit( nArea1Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3)
-- local nArea12Id, nArea13Id = WinCreate.AddSplit( nArea12Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3)
-- local nArea21Id, nArea23Id = WinCreate.AddSplit( nArea2Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3)
-- local nArea21Id, nArea22Id = WinCreate.AddSplit( nArea21Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3)
-- local nArea22Id, nArea23Id = WinCreate.AddSplit( nArea23Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3)
--
-- -- aggiungo prima anta
-- local SashJointType = WIN_JNT.FULL_V
-- local nSash1Id = WinCreate.AddSash( nArea11Id, SashJointType, SashJointType, SashJointType, SashJointType)
-- -- aggiungo vetro
-- local nFill1Id = WinCreate.AddFill( nSash1Id, WIN_FILLTYPES.GLASS)
--
-- -- aggiungo seconda anta
-- local nSash2Id = WinCreate.AddSash( nArea12Id, SashJointType, SashJointType, SashJointType, SashJointType)
-- -- aggiungo vetro
-- local nFill2Id = WinCreate.AddFill( nSash2Id, WIN_FILLTYPES.GLASS)
--
-- -- aggiungo terza anta
-- local nSash3Id = WinCreate.AddSash( nArea13Id, SashJointType, SashJointType, SashJointType, SashJointType)
-- -- aggiungo vetro
-- local nFill3Id = WinCreate.AddFill( nSash3Id, WIN_FILLTYPES.GLASS)
--
-- -- aggiungo quarta anta
-- local nSash4Id = WinCreate.AddSash( nArea21Id, SashJointType, SashJointType, SashJointType, SashJointType)
-- -- aggiungo vetro
-- local nFill4Id = WinCreate.AddFill( nSash4Id, WIN_FILLTYPES.GLASS)
--
-- -- aggiungo quinta anta
-- local nSash5Id = WinCreate.AddSash( nArea22Id, SashJointType, SashJointType, SashJointType, SashJointType)
-- -- aggiungo vetro
-- local nFill5Id = WinCreate.AddFill( nSash5Id, WIN_FILLTYPES.GLASS)
--
-- -- aggiungo sesta anta
-- local nSash6Id = WinCreate.AddSash( nArea23Id, SashJointType, SashJointType, SashJointType, SashJointType)
-- -- aggiungo vetro
+11
View File
@@ -18,6 +18,17 @@ local WinConst = {}
------------------------------------------- PARAMETERS -------------------------------------------
-- tipi di telaio
WIN_FRAME_TYPE = {
RECT = 1,
CHAMFER_SIDE = 2,
CHAMFER = 3,
ROUND_ARC = 4,
SEGMENTAL_ARC = 5,
POINTED_ARC = 6,
TRIANGLE = 7,
}
-- Tipi di giunzioni (joint)
WIN_JNT = {
ANGLED = 1,
+383 -335
View File
@@ -35,13 +35,59 @@ local function CopyInfo( nDest, nSou, sInfo)
EgtSetInfo( nDest, sInfo, sVal)
end
---------------------------------------------------------------------
-- funzione che trova punto di intersezione fra due curve eventualmente estendendole
local function FindIntersectionPoint( nCrv1, nCrv2)
local ptRef = EgtSP( nCrv1)
local ptInt = EgtIP( nCrv1, nCrv2, ptRef)
if not ptInt then
-- se entrambe linee
if EgtGetType( nCrv1) == GDB_TY.CRV_LINE and EgtGetType( nCrv2) == GDB_TY.CRV_LINE then
EgtExtendCurveStartByLen( nCrv1, 10000)
EgtExtendCurveEndByLen( nCrv1, 10000)
EgtExtendCurveStartByLen( nCrv2, 10000)
EgtExtendCurveEndByLen( nCrv2, 10000)
ptInt = EgtIP( nCrv1, nCrv2, ptRef)
-- se entrambi archi
elseif EgtGetType( nCrv1) == GDB_TY.CRV_ARC and EgtGetType( nCrv2) == GDB_TY.CRV_ARC then
-- TO DO. Al momento non ci sono esempi di questo tipo
-- se arco e linea
else
local nLine = EgtIf( EgtGetType( nCrv1) == GDB_TY.CRV_LINE, nCrv1, nCrv2)
local nArc = EgtIf( nLine == nCrv1, nCrv2, nCrv1)
-- tento di trovare intersezione prolungando la linea
EgtExtendCurveStartByLen( nLine, 10000)
EgtExtendCurveEndByLen( nLine, 10000)
ptInt = EgtIP( nArc, nLine, ptRef)
if not ptInt then
-- creo circonferenza corrispondente all'arco
local nCircle = EgtCircle( GDB_ID.ROOT, EgtCP( nArc), EgtArcRadius( nArc))
-- trovo l'intersezione tra retta e circonferenza
local ptDist = EgtIf( nArc == nCrv2, EgtEP( nArc), EgtSP( nArc))
local _, ptRef = EgtPointCurveDist( ptDist, nLine)
ptInt = EgtIP( nCircle, nLine, ptRef)
EgtErase( nCircle)
-- allungo l'arco per arrivare al punto di intersezione
if nArc == nCrv2 then
EgtModifyCurveEndPoint( nArc, ptInt)
else
EgtModifyCurveStartPoint( nArc, ptInt)
end
end
end
end
return ptInt
end
---------------------------------------------------------------------
-- funzione che dato un gruppo contenente curve ordinate che creano una curva chiusa,
-- ne estende/taglia i contorni per ottenere una curva chiusa continua
local function TrimAndOrientOrderedCurveLayer( nLayerId)
local IntersCurveList = {}
local LastCurveInters
local ptInters
local nCurveId = EgtGetFirstInGroup( nLayerId)
-- ciclo sui segmenti per ottenere lista intersezioni
while nCurveId do
@@ -49,15 +95,7 @@ local function TrimAndOrientOrderedCurveLayer( nLayerId)
if not nPrevId then
nPrevId = EgtGetLastInGroup( nLayerId)
end
ptInters = EgtIP( nCurveId, nPrevId, EgtSP( nCurveId))
if not ptInters then
local dDist = dist( EgtEP( nPrevId), EgtSP( nCurveId))
EgtExtendCurveStartByLen( nCurveId, 2 * dDist)
EgtExtendCurveEndByLen( nCurveId, 2 * dDist)
EgtExtendCurveStartByLen( nPrevId, 2 * dDist)
EgtExtendCurveEndByLen( nPrevId, 2 * dDist)
ptInters = EgtIP( nCurveId, nPrevId, EgtSP( nCurveId))
end
local ptInters = FindIntersectionPoint( nCurveId, nPrevId)
if LastCurveInters then
LastCurveInters.EndInters = Point3d( ptInters)
end
@@ -67,11 +105,12 @@ local function TrimAndOrientOrderedCurveLayer( nLayerId)
nCurveId = EgtGetNext( nCurveId)
end
IntersCurveList[#IntersCurveList].EndInters = IntersCurveList[1].StartInters
-- ciclo per tagliare ed orientare
for nIntersCurveIndex = 1, #IntersCurveList do
local CurveInters = IntersCurveList[nIntersCurveIndex]
local dStartParam = EgtCurveParamAtPoint( CurveInters.CurveId, CurveInters.StartInters)
local dEndParam = EgtCurveParamAtPoint( CurveInters.CurveId, CurveInters.EndInters)
local dStartParam = EgtCurveParamAtPoint( CurveInters.CurveId, CurveInters.StartInters, 100 * GEO.EPS_SMALL)
local dEndParam = EgtCurveParamAtPoint( CurveInters.CurveId, CurveInters.EndInters, 100 * GEO.EPS_SMALL)
EgtTrimCurveStartEndAtParam( CurveInters.CurveId, min( dStartParam, dEndParam), max( dStartParam, dEndParam))
if dStartParam > dEndParam then
EgtInvertCurve( CurveInters.CurveId)
@@ -91,7 +130,7 @@ local function TrimSplitWithOutline( nSplitId)
nOutlineId = EgtGetInfo( nEndIntersId, WIN_COPY, 'i')
local ptEndInters = EgtIP( nSplitId, nOutlineId, EgtSP( nSplitId))
local dEndInters = EgtCurveParamAtPoint( nSplitId, ptEndInters)
EgtTrimCurveEndAtParam( nSplitId, dEndInters)
EgtTrimCurveEndAtParam( nSplitId, dEndInters)
end
---------------------------------------------------------------------
@@ -727,69 +766,54 @@ local function GetOutlineProfileType( nOutlineId, bBottomRail)
end
---------------------------------------------------------------------
-- funzione che recupera l'outline precedente e successivo
-- funzione che recupera gli outline precedenti e successivi
local function GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId)
local nPrevOutlineId
local nNextOutlineId
local vPrevOutlineId = {}
local vNextOutlineId = {}
if nProfileType == WIN_PRF.SPLIT then
-- se split individuo l'outline associato al base outline che lo taglia
local nPrevBaseOutlineId = EgtGetInfo( nOutlineId, WIN_SPLIT_STARTINTERS, 'i')
nPrevOutlineId = EgtGetInfo( nPrevBaseOutlineId, WIN_COPY, 'i')
local nNextBaseOutlineId = EgtGetInfo( nOutlineId, WIN_SPLIT_ENDINTERS, 'i')
nNextOutlineId = EgtGetInfo( nNextBaseOutlineId, WIN_COPY, 'i')
-- se split recupero tutte le curve di base outline che lo tagliano
local vPrevBaseOutlineId = EgtGetInfo( nOutlineId, WIN_SPLIT_STARTINTERS, 'vi')
for i = 1, #vPrevBaseOutlineId do
-- recupero l'outline associato al base outline che lo taglia
table.insert( vPrevOutlineId, EgtGetInfo( vPrevBaseOutlineId[i], WIN_COPY, 'i'))
end
local vNextBaseOutlineId = EgtGetInfo( nOutlineId, WIN_SPLIT_ENDINTERS, 'vi')
for i = 1, #vNextBaseOutlineId do
table.insert( vNextOutlineId, EgtGetInfo( vNextBaseOutlineId[i], WIN_COPY, 'i'))
end
else
nPrevOutlineId = EgtGetPrev( nOutlineId)
if not nPrevOutlineId then
nPrevOutlineId = EgtGetLastInGroup( nOutlineLayerId)
end
nNextOutlineId = EgtGetNext( nOutlineId)
if not nNextOutlineId then
nNextOutlineId = EgtGetFirstInGroup( nOutlineLayerId)
end
vPrevOutlineId = { EgtGetPrev( nOutlineId) or EgtGetLastInGroup( nOutlineLayerId)}
vNextOutlineId = { EgtGetNext( nOutlineId) or EgtGetFirstInGroup( nOutlineLayerId)}
end
return nPrevOutlineId, nNextOutlineId
return vPrevOutlineId, vNextOutlineId
end
---------------------------------------------------------------------
-- funzione che restituisce il tipo di controprofilo dell'outline adiacente
local function GetProfileCtrIn( nProfileType, nPrevOutlineId, nOutlineId, nPrevProfileId)
local function GetProfileCtrIn( nPrevOutlineId, nOutlineId, nPrevProfileId)
local sPrevCtrIn = WIN_CTRIN
-- gestione particolare nel caso di split su split
if nProfileType == WIN_PRF.SPLIT then
-- recupero il base outline del prev e verifico se deriva da uno split
-- gestione particolare del caso di profilo di split
if not EgtGetFirstNameInGroup( nPrevProfileId, sPrevCtrIn) then
-- recupero la curva di base outline da cui deriva il precedente
local nPrevSouId = EgtGetInfo( nPrevOutlineId, WIN_COPY, 'i')
local sPrevSouName
repeat
nPrevSouId = EgtGetInfo( nPrevSouId, WIN_SOU, 'i')
sPrevSouName = EgtGetName( nPrevSouId or GDB_ID.NULL)
until not nPrevSouId or sPrevSouName == WIN_SPLIT
if sPrevSouName == WIN_SPLIT then
-- verifico da che lato sono dello split
local dOutlineDist, _, dSide = EgtPointCurveDistSide( EgtMP( nOutlineId), nPrevSouId, Z_AX())
-- recupero box dei controprofili rispetto al loro sistema di riferimento
local nSectionFrameId = EgtGetFirstNameInGroup( nPrevProfileId, WIN_SECTIONFRAME)
local frSectionFrame = EgtFR( nSectionFrameId, GDB_ID.ROOT)
local dMinDist = GEO.INFINITO
-- confronto distanze dei controprofili rispetto a distanza dell'outline per trovare il controprofilo piu' vicino
local nMinCtrInId
local nCtrInId = EgtGetFirstNameInGroup( nPrevProfileId, WIN_CTRIN .. '*')
while nCtrInId do
local b3CtrIn = EgtGetBBoxRef( nCtrInId, GDB_BB.STANDARD, frSectionFrame)
local dCtrInDist = abs( ( dSide * dOutlineDist) - b3CtrIn:getCenter():getX())
if dCtrInDist < dMinDist then
dMinDist = dCtrInDist
nMinCtrInId = nCtrInId
end
nCtrInId = EgtGetNextName( nCtrInId, WIN_CTRIN .. '*')
end
if nMinCtrInId then
sPrevCtrIn = EgtGetName( nMinCtrInId)
end
-- verifico da quale lato si trova la curva per decidere quale controprofilo considerare
local _, _, dSide = EgtPointCurveDistSide( EgtMP( nOutlineId), nPrevSouId, Z_AX())
if dSide == 1 then
sPrevCtrIn = WIN_CTRIN .. '1' -- dx
else
sPrevCtrIn = WIN_CTRIN .. '2' -- sx
end
end
return sPrevCtrIn
end
@@ -822,32 +846,39 @@ end
---------------------------------------------------------------------
-- funzione che crea il gruppo con i profili di un pezzo
local function CalcFrameProfiles( nPartId, nOutlineId, nPrevOutlineId, nNextOutlineId, nProfileType)
local function CalcFrameProfiles( nPartId, nOutlineId, vPrevOutlineId, vNextOutlineId, nProfileType)
-- creo gruppo per i profili
local nProfileLayerId = EgtGroup( nPartId)
EgtSetName( nProfileLayerId, WIN_PROFILE)
EgtSetStatus( nProfileLayerId, GDB_ST.OFF)
-- recupero profili e controprofili
local nOrigMainProfileId = GetOutlineProfileId( nOutlineId, nProfileType == WIN_PRF.BOTTOMRAIL)
-- se il tipo corrente è split il pezzo va tagliato con il bottomrail, altrimenti con il bottom
local nOrigStartProfileId = GetOutlineProfileId( nPrevOutlineId, nProfileType == WIN_PRF.SPLIT)
local nOrigEndProfileId = GetOutlineProfileId( nNextOutlineId, nProfileType == WIN_PRF.SPLIT)
-- creo copie di profilo e controprofili
-- recupero profilo principale e ne creo copia
local nOrigMainProfileId = GetOutlineProfileId( nOutlineId, nProfileType == WIN_PRF.BOTTOMRAIL)
local nMainProfileId = EgtCopy( nOrigMainProfileId, nProfileLayerId)
local sMainProfileType = EgtGetName( nMainProfileId)
EgtSetInfo( nMainProfileId, WIN_PRF_TYPE, sMainProfileType)
EgtSetName( nMainProfileId, WIN_PRF_MAIN)
local nStartProfileId = EgtCopy( nOrigStartProfileId, nProfileLayerId)
local sStartProfileType = EgtGetName( nStartProfileId)
EgtSetInfo( nStartProfileId, WIN_PRF_TYPE, sStartProfileType)
EgtSetName( nStartProfileId, WIN_PRF_START)
local nEndProfileId = EgtCopy( nOrigEndProfileId, nProfileLayerId)
local sEndProfileType = EgtGetName( nEndProfileId)
EgtSetInfo( nEndProfileId, WIN_PRF_TYPE, sEndProfileType)
EgtSetName( nEndProfileId, WIN_PRF_END)
-- recupero controprofili start e ne creo copia
for i = 1, #vPrevOutlineId do
-- se il tipo corrente è split il pezzo va tagliato con il bottomrail, altrimenti con il bottom
local nOrigStartProfileId = GetOutlineProfileId( vPrevOutlineId[i], nProfileType == WIN_PRF.SPLIT)
local nStartProfileId = EgtCopy( nOrigStartProfileId, nProfileLayerId)
local sStartProfileType = EgtGetName( nStartProfileId)
EgtSetInfo( nStartProfileId, WIN_PRF_TYPE, sStartProfileType)
EgtSetName( nStartProfileId, WIN_PRF_START)
end
-- recupero controprofili end e ne creo copia
for i = 1, #vNextOutlineId do
local nOrigEndProfileId = GetOutlineProfileId( vNextOutlineId[i], nProfileType == WIN_PRF.SPLIT)
local nEndProfileId = EgtCopy( nOrigEndProfileId, nProfileLayerId)
local sEndProfileType = EgtGetName( nEndProfileId)
EgtSetInfo( nEndProfileId, WIN_PRF_TYPE, sEndProfileType)
EgtSetName( nEndProfileId, WIN_PRF_END)
end
-- recupero le info di pinzaggio dal profilo di estrusione
CopyInfo( nPartId, nMainProfileId, WIN_PRC_OFFY_1)
CopyInfo( nPartId, nMainProfileId, WIN_PRC_OFFZ_1)
@@ -875,7 +906,7 @@ end
---------------------------------------------------------------------
-- funzione che crea le curve del geo
local function CreateFrameGeo( nOutlineId, nPrevOutlineId, nNextOutlineId, nStartPartJointType, nEndPartJointType, nProfileType, nGeoLayerId, nProfileLayerId)
local function CreateFrameGeo( nOutlineId, vPrevOutlineId, vNextOutlineId, nStartPartJointType, nEndPartJointType, nGeoLayerId, nProfileLayerId)
local nCurrProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_MAIN)
local nCurrProfileRefId = EgtGetFirstNameInGroup( nCurrProfileId, WIN_REF)
@@ -901,68 +932,69 @@ local function CreateFrameGeo( nOutlineId, nPrevOutlineId, nNextOutlineId, nStar
local nSemiProfileIn = EgtGetFirstNameInGroup( nCurrProfileId, WIN_IN) or EgtGetFirstNameInGroup( nCurrProfileId, WIN_IN .. '2')
EgtSetInfo( nCurrOffsetId, WIN_SEMI_PROFILE, nSemiProfileIn)
-- curva left
local nPrevCurveId
local nPrevSemiProfile
if nStartPartJointType == WIN_PART_JNT.ANGLED then
-- calcolo la bisettrice
local vtMedia = ( ( EgtSV( nOutlineId) - EgtEV( nPrevOutlineId)) / 2)
if not vtMedia:normalize() then
vtMedia = EgtSV( nOutlineId)
vtMedia:rotate( Z_AX(), 90)
end
nPrevCurveId = EgtLinePVL( nGeoLayerId, EgtSP( nOutlineId), vtMedia, 3 * b3CurrProfileFrame:getDimX())
EgtInvertCurve( nPrevCurveId)
else
nPrevCurveId = EgtCopy( nPrevOutlineId, nGeoLayerId)
local nPrevProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_START)
if nStartPartJointType == WIN_PART_JNT.SHORT then
local sCtrIn = GetProfileCtrIn( nProfileType, nPrevOutlineId, nOutlineId, nPrevProfileId)
local dPrevCPDelta = GetDeltaProfile( nPrevProfileId, sCtrIn)
EgtOffsetCurve( nPrevCurveId, - dPrevCPDelta)
EgtSetInfo( nGeoLayerId, WIN_STARTCPDELTA, dPrevCPDelta)
-- ricavo il semiprofilo associato
nPrevSemiProfile = EgtGetFirstNameInGroup( nPrevProfileId, sCtrIn)
-- curve left
for i = 1, #vPrevOutlineId do
local nPrevCurveId
local nPrevSemiProfile
if nStartPartJointType == WIN_PART_JNT.ANGLED then
-- calcolo la bisettrice
local vtMedia = ( ( EgtSV( nOutlineId) - EgtEV( vPrevOutlineId[i])) / 2)
if not vtMedia:normalize() then
vtMedia = EgtSV( nOutlineId)
vtMedia:rotate( Z_AX(), 90)
end
nPrevCurveId = EgtLinePVL( nGeoLayerId, EgtSP( nOutlineId), vtMedia, 3 * b3CurrProfileFrame:getDimX())
EgtInvertCurve( nPrevCurveId)
else
nPrevSemiProfile = EgtGetFirstNameInGroup( nPrevProfileId, WIN_OUT)
nPrevCurveId = EgtCopy( vPrevOutlineId[i], nGeoLayerId)
local nPrevProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_START)
if nStartPartJointType == WIN_PART_JNT.SHORT then
local sCtrIn = GetProfileCtrIn( vPrevOutlineId[i], nOutlineId, nPrevProfileId)
local dPrevCPDelta = GetDeltaProfile( nPrevProfileId, sCtrIn)
EgtOffsetCurve( nPrevCurveId, - dPrevCPDelta)
EgtSetInfo( nGeoLayerId, WIN_STARTCPDELTA, dPrevCPDelta)
-- ricavo il semiprofilo associato
nPrevSemiProfile = EgtGetFirstNameInGroup( nPrevProfileId, sCtrIn)
else
nPrevSemiProfile = EgtGetFirstNameInGroup( nPrevProfileId, WIN_OUT)
end
end
EgtSetName( nPrevCurveId, WIN_GEO_LEFT)
EgtSetInfo( nPrevCurveId, WIN_SEMI_PROFILE, nPrevSemiProfile)
EgtRelocateGlob( nPrevCurveId, nGeoLayerId, GDB_IN.LAST_SON)
end
EgtSetName( nPrevCurveId, WIN_GEO_LEFT)
EgtSetInfo( nPrevCurveId, WIN_SEMI_PROFILE, nPrevSemiProfile)
-- curva right
local nNextCurveId
local nNextSemiProfile
if nEndPartJointType == WIN_PART_JNT.ANGLED then
-- calcolo la bisettrice
local vtMedia = ( ( EgtSV( nNextOutlineId) - EgtEV( nOutlineId)) / 2)
if not vtMedia:normalize() then
vtMedia = EgtEV( nOutlineId)
vtMedia:rotate(Z_AX(), 90)
end
nNextCurveId = EgtLinePVL( nGeoLayerId, EgtEP( nOutlineId), vtMedia, 3 * b3CurrProfileFrame:getDimX())
else
nNextCurveId = EgtCopy( nNextOutlineId, nGeoLayerId)
local nNextProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_END)
if nEndPartJointType == WIN_PART_JNT.SHORT then
local sCtrIn = GetProfileCtrIn( nProfileType, nNextOutlineId, nOutlineId, nNextProfileId)
local dNextCPDelta = GetDeltaProfile( nNextProfileId, sCtrIn)
EgtOffsetCurve( nNextCurveId, - dNextCPDelta)
EgtSetInfo( nGeoLayerId, WIN_ENDCPDELTA, dNextCPDelta)
-- ricavo il semiprofilo associato
nNextSemiProfile = EgtGetFirstNameInGroup( nNextProfileId, sCtrIn)
-- curve right
for i = 1, #vNextOutlineId do
local nNextCurveId
local nNextSemiProfile
if nEndPartJointType == WIN_PART_JNT.ANGLED then
-- calcolo la bisettrice
local vtMedia = ( ( EgtSV( vNextOutlineId[i]) - EgtEV( nOutlineId)) / 2)
if not vtMedia:normalize() then
vtMedia = EgtEV( nOutlineId)
vtMedia:rotate(Z_AX(), 90)
end
nNextCurveId = EgtLinePVL( nGeoLayerId, EgtEP( nOutlineId), vtMedia, 3 * b3CurrProfileFrame:getDimX())
else
nNextSemiProfile = EgtGetFirstNameInGroup( nNextProfileId, WIN_OUT)
nNextCurveId = EgtCopy( vNextOutlineId[i], nGeoLayerId)
local nNextProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_END)
if nEndPartJointType == WIN_PART_JNT.SHORT then
local sCtrIn = GetProfileCtrIn( vNextOutlineId[i], nOutlineId, nNextProfileId)
local dNextCPDelta = GetDeltaProfile( nNextProfileId, sCtrIn)
EgtOffsetCurve( nNextCurveId, - dNextCPDelta)
EgtSetInfo( nGeoLayerId, WIN_ENDCPDELTA, dNextCPDelta)
-- ricavo il semiprofilo associato
nNextSemiProfile = EgtGetFirstNameInGroup( nNextProfileId, sCtrIn)
else
nNextSemiProfile = EgtGetFirstNameInGroup( nNextProfileId, WIN_OUT)
end
end
EgtSetName( nNextCurveId, WIN_GEO_RIGHT)
EgtSetInfo( nNextCurveId, WIN_SEMI_PROFILE, nNextSemiProfile)
EgtRelocateGlob( nNextCurveId, nCurrOffsetId, GDB_IN.BEFORE)
end
EgtSetName( nNextCurveId, WIN_GEO_RIGHT)
EgtSetInfo( nNextCurveId, WIN_SEMI_PROFILE, nNextSemiProfile)
-- riordino le curve per eseguire correttamente il trim
EgtRelocateGlob( nNextCurveId, nCurrCurveId, GDB_IN.AFTER)
EgtRelocateGlob( nCurrOffsetId, nNextCurveId, GDB_IN.AFTER)
EgtRelocateGlob( nPrevCurveId, nCurrOffsetId, GDB_IN.AFTER)
-- trim delle curve
TrimAndOrientOrderedCurveLayer( nGeoLayerId)
@@ -1017,8 +1049,8 @@ local function CalcFrameGeo( nPartId, nOutlineId, nOutlineLayerId, nProfileType)
local nGeoLayerId = EgtGroup( nPartId)
EgtSetName( nGeoLayerId, WIN_GEO)
-- recupero outline precedente e successivo
local nPrevOutlineId, nNextOutlineId = GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId)
-- recupero outline precedenti e successivi ( solo nel caso di split possono essere più di uno)
local vPrevOutlineId, vNextOutlineId = GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId)
-- recupero il tipo di giunzioni
local nStartJointType
@@ -1033,19 +1065,20 @@ local function CalcFrameGeo( nPartId, nOutlineId, nOutlineLayerId, nProfileType)
nStartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TL, 'i')
nEndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BL, 'i')
elseif nProfileType == WIN_PRF.RIGHT then
-- recupero tipo di giunzioni
nStartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BR, 'i')
nEndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TR, 'i')
else
-- nei casi di profilo BottomRail e Split non serve settare dei valori per StartJointType ed EndJointType perchè
-- in CalcPartJointType la loro giunzione viene settata a short
end
-- se pezzo non e' split, giunzione diversa da bisettrice ed arco a tutto sesto forzo il tipo a bisettrice
if nProfileType ~= WIN_PRF.SPLIT and nStartJointType ~= WIN_JNT.ANGLED and AreSameVectorApprox( EgtEV( nPrevOutlineId), EgtSV( nOutlineId)) then
nStartJointType = WIN_JNT.ANGLED
-- se pezzo non e' split, giunzione diversa da bisettrice e arco a tutto sesto oppure elementi entrambi top, forzo il tipo a bisettrice
if nProfileType ~= WIN_PRF.SPLIT and nStartJointType ~= WIN_JNT.ANGLED and
( AreSameVectorApprox( EgtEV( vPrevOutlineId[1]), EgtSV( nOutlineId)) or EgtGetName( nOutlineId) == EgtGetName( vPrevOutlineId[1])) then
nStartJointType = WIN_JNT.ANGLED
end
if nProfileType ~= WIN_PRF.SPLIT and nEndJointType ~= WIN_JNT.ANGLED and AreSameVectorApprox( EgtEV( nOutlineId), EgtSV( nNextOutlineId)) then
nEndJointType = WIN_JNT.ANGLED
if nProfileType ~= WIN_PRF.SPLIT and nEndJointType ~= WIN_JNT.ANGLED and
( AreSameVectorApprox( EgtEV( nOutlineId), EgtSV( vNextOutlineId[1])) or EgtGetName( nOutlineId) == EgtGetName( vNextOutlineId[1])) then
nEndJointType = WIN_JNT.ANGLED
end
-- calcolo il tipo di giunzione per la parte
@@ -1057,10 +1090,10 @@ local function CalcFrameGeo( nPartId, nOutlineId, nOutlineLayerId, nProfileType)
EgtSetInfo( nOutlineId, WIN_ENDJOINT, nEndPartJointType)
-- creo il gruppo con i profili del pezzo
local nProfileLayerId = CalcFrameProfiles( nPartId, nOutlineId, nPrevOutlineId, nNextOutlineId, nProfileType)
local nProfileLayerId = CalcFrameProfiles( nPartId, nOutlineId, vPrevOutlineId, vNextOutlineId, nProfileType)
-- creo lati dell'outline
local nGeoOutId = CreateFrameGeo( nOutlineId, nPrevOutlineId, nNextOutlineId, nStartPartJointType, nEndPartJointType, nProfileType, nGeoLayerId, nProfileLayerId)
local nGeoOutId = CreateFrameGeo( nOutlineId, vPrevOutlineId, vNextOutlineId, nStartPartJointType, nEndPartJointType, nGeoLayerId, nProfileLayerId)
-- calcolo le lavorazioni associate ai profili
CalcProfilingProcessings( nPartId, nGeoLayerId)
@@ -1118,8 +1151,8 @@ local function AddStartDowels( nOutlineId, nPrevOutlineId, nProfileLayerId, nDow
EgtTransform( nDowelId, frOrig, GDB_RT.GLOB)
EgtTransform( nDowelId, frDest, GDB_RT.GLOB)
EgtMove( nDowelId, dStart * vtRef)
EgtModifyCurveExtrusion( nDowelId, vtRef)
EgtModifyCurveThickness( nDowelId, dEnd - dStart)
EgtModifyCurveExtrusion( nDowelId, - vtRef)
EgtModifyCurveThickness( nDowelId, - ( dEnd - dStart))
-- setto info di lavorazione
EgtSetInfo( nDowelId, WIN_PRC_FEATURE_TYPE, WIN_PRC_TYPE.HOLE)
@@ -1192,8 +1225,8 @@ local function AddStartDowels( nOutlineId, nPrevOutlineId, nProfileLayerId, nDow
EgtTransform( nDowelId, frOrig)
EgtTransform( nDowelId, frDest)
EgtMove( nDowelId, vtRef * dStart)
EgtModifyCurveExtrusion( nDowelId, vtRef)
EgtModifyCurveThickness( nDowelId, dEnd - dStart)
EgtModifyCurveExtrusion( nDowelId, - vtRef)
EgtModifyCurveThickness( nDowelId, - ( dEnd - dStart))
-- setto info di lavorazione
EgtSetInfo( nDowelId, WIN_PRC_FEATURE_TYPE, WIN_PRC_TYPE.HOLE)
@@ -1258,8 +1291,8 @@ local function AddEndDowels( nOutlineId, nEndOutlineId, nProfileLayerId, nDowelL
EgtTransform( nDowelId, frOrig)
EgtTransform( nDowelId, frDest)
EgtMove( nDowelId, - vtRef * dStart)
EgtModifyCurveExtrusion( nDowelId, - vtRef)
EgtModifyCurveThickness( nDowelId, dEnd - dStart)
EgtModifyCurveExtrusion( nDowelId, vtRef)
EgtModifyCurveThickness( nDowelId, - ( dEnd - dStart))
-- setto info di lavorazione
EgtSetInfo( nDowelId, WIN_PRC_FEATURE_TYPE, WIN_PRC_TYPE.HOLE)
@@ -1331,8 +1364,8 @@ local function AddEndDowels( nOutlineId, nEndOutlineId, nProfileLayerId, nDowelL
EgtTransform( nDowelId, frOrig, GDB_RT.GLOB)
EgtTransform( nDowelId, frDest, GDB_RT.GLOB)
EgtMove( nDowelId, - vtRef * dStart)
EgtModifyCurveExtrusion( nDowelId, - vtRef)
EgtModifyCurveThickness( nDowelId, dEnd - dStart)
EgtModifyCurveExtrusion( nDowelId, vtRef)
EgtModifyCurveThickness( nDowelId, - ( dEnd - dStart))
-- setto info di lavorazione
EgtSetInfo( nDowelId, WIN_PRC_FEATURE_TYPE, WIN_PRC_TYPE.HOLE)
@@ -1447,8 +1480,8 @@ local function CalSplitDowel( nSplitLayerId, nOutlineId, nProfileType, nPartId)
-- posiziono il dowel e gli assegno estrusione e spessore
EgtMove( nDowelId, vtDowelDir * dStart)
EgtModifyCurveExtrusion( nDowelId, vtDowelDir)
EgtModifyCurveThickness( nDowelId, dEnd - dStart)
EgtModifyCurveExtrusion( nDowelId, - vtDowelDir)
EgtModifyCurveThickness( nDowelId, - ( dEnd - dStart))
-- setto info di lavorazione
EgtSetInfo( nDowelId, WIN_PRC_FEATURE_TYPE, WIN_PRC_TYPE.HOLE)
@@ -1512,7 +1545,7 @@ end
local function CalcFrameDowels( nPartId, nOutlineId, nOutlineLayerId, nProfileType)
-- creo fori per spine su Start ed End
local nPrevOutlineId, nNextOutlineId = GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId)
local vPrevOutlineId, vNextOutlineId = GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId)
local nProfileLayerId = EgtGetFirstNameInGroup( nPartId, WIN_PROFILE)
local nProcLayerId = EgtGetFirstNameInGroup( nPartId, WIN_PRC)
local nGeoLayerId = EgtGetFirstNameInGroup( nPartId, WIN_GEO)
@@ -1521,8 +1554,12 @@ local function CalcFrameDowels( nPartId, nOutlineId, nOutlineLayerId, nProfileTy
local nSolidLayerId = EgtGetFirstNameInGroup( nPartId, WIN_SOLID)
nMainExtrusionId = EgtGetFirstNameInGroup( nSolidLayerId, WIN_SRF_MAIN)
end
AddStartDowels( nOutlineId, nPrevOutlineId, nProfileLayerId, nProcLayerId, nGeoLayerId, nMainExtrusionId)
AddEndDowels( nOutlineId, nNextOutlineId, nProfileLayerId, nProcLayerId, nGeoLayerId, nMainExtrusionId)
for i = 1, #vPrevOutlineId do
AddStartDowels( nOutlineId, vPrevOutlineId[i], nProfileLayerId, nProcLayerId, nGeoLayerId, nMainExtrusionId)
end
for i = 1, #vNextOutlineId do
AddEndDowels( nOutlineId, vNextOutlineId[i], nProfileLayerId, nProcLayerId, nGeoLayerId, nMainExtrusionId)
end
-- split dowels
AddSplitDowels( nOutlineId, nOutlineLayerId, nPartId, nProfileType)
@@ -1533,40 +1570,46 @@ end
---------------------------------- SOLIDO ----------------------------------------
----------------------------------------------------------------------------------
-- funzione che recupera tipo di inizio e fine pezzo
local function CalcStartEndProfileType( nProfileType, nOutlineId, nStartProfileId, nEndProfileId)
local function CalcStartEndProfileType( nProfileType, nOutlineId, vStartProfileId, vEndProfileId)
local sStartProfileType
local sEndProfileType
local StartJointType = EgtGetInfo( nOutlineId, WIN_STARTJOINT, 'i')
if StartJointType == WIN_PART_JNT.ANGLED then
sStartProfileType = WIN_MINIZINKEN
elseif StartJointType == WIN_PART_JNT.SHORT then
sStartProfileType = WIN_CTRINOFST
elseif StartJointType == WIN_PART_JNT.FULL then
sStartProfileType = WIN_OUTOFST
end
local EndJointType = EgtGetInfo( nOutlineId, WIN_ENDJOINT, 'i')
if EndJointType == WIN_PART_JNT.ANGLED then
sEndProfileType = WIN_MINIZINKEN
elseif EndJointType == WIN_PART_JNT.SHORT then
sEndProfileType = WIN_CTRINOFST
elseif EndJointType == WIN_PART_JNT.FULL then
sEndProfileType = WIN_OUTOFST
end
local vsStartProfileType = {}
local vsEndProfileType = {}
if nProfileType == WIN_PRF.SPLIT then
local nStartBaseOutlineId = EgtGetInfo( nOutlineId, WIN_SPLIT_STARTINTERS, 'i')
local nStartId = EgtGetInfo( nStartBaseOutlineId, WIN_COPY, 'i')
local nEndBaseOutlineId = EgtGetInfo( nOutlineId, WIN_SPLIT_ENDINTERS, 'i')
local nEndId = EgtGetInfo( nEndBaseOutlineId, WIN_COPY, 'i')
sStartProfileType = GetProfileCtrIn( nProfileType, nStartId, nOutlineId, nStartProfileId)
sEndProfileType = GetProfileCtrIn( nProfileType, nEndId, nOutlineId, nEndProfileId)
sStartProfileType = WIN_OFST .. sStartProfileType
sEndProfileType = WIN_OFST .. sEndProfileType
local vStartBaseOutlineId = EgtGetInfo( nOutlineId, WIN_SPLIT_STARTINTERS, 'vi')
for i = 1, #vStartBaseOutlineId do
local nStartId = EgtGetInfo( vStartBaseOutlineId[i], WIN_COPY, 'i')
local sStartProfileType = GetProfileCtrIn( nStartId, nOutlineId, vStartProfileId[i])
table.insert( vsStartProfileType, WIN_OFST .. sStartProfileType)
end
local vEndBaseOutlineId = EgtGetInfo( nOutlineId, WIN_SPLIT_ENDINTERS, 'vi')
for i = 1, #vEndBaseOutlineId do
local nEndId = EgtGetInfo( vEndBaseOutlineId[i], WIN_COPY, 'i')
local sEndProfileType = GetProfileCtrIn( nEndId, nOutlineId, vEndProfileId[i])
table.insert( vsEndProfileType, WIN_OFST .. sEndProfileType)
end
else
local StartJointType = EgtGetInfo( nOutlineId, WIN_STARTJOINT, 'i')
if StartJointType == WIN_PART_JNT.ANGLED then
vsStartProfileType = { WIN_MINIZINKEN}
elseif StartJointType == WIN_PART_JNT.SHORT then
vsStartProfileType = { WIN_CTRINOFST}
elseif StartJointType == WIN_PART_JNT.FULL then
vsStartProfileType = { WIN_OUTOFST}
end
local EndJointType = EgtGetInfo( nOutlineId, WIN_ENDJOINT, 'i')
if EndJointType == WIN_PART_JNT.ANGLED then
vsEndProfileType = { WIN_MINIZINKEN}
elseif EndJointType == WIN_PART_JNT.SHORT then
vsEndProfileType = { WIN_CTRINOFST}
elseif EndJointType == WIN_PART_JNT.FULL then
vsEndProfileType = { WIN_OUTOFST}
end
end
return sStartProfileType, sEndProfileType
return vsStartProfileType, vsEndProfileType
end
---------------------------------------------------------------------
@@ -1583,18 +1626,26 @@ local function CalcFrameSolid( nPartId, nOutlineId, nGeoId, nProfileType)
-- recupero profili e controprofili
local nProfileLayerId = EgtGetFirstNameInGroup( nPartId, WIN_PROFILE)
local nMainProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_MAIN)
local nStartProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_START)
local nEndProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_END)
local vStartProfileId = EgtGetNameInGroup( nProfileLayerId, WIN_PRF_START)
local vEndProfileId = EgtGetNameInGroup( nProfileLayerId, WIN_PRF_END)
-- recupero geo
local nGeoLayerId = EgtGetParent( nGeoId)
local nPrevGeoId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_LEFT)
local nNextGeoId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_RIGHT)
local vPrevGeoId = EgtGetNameInGroup( nGeoLayerId, WIN_GEO_LEFT)
local vNextGeoId = EgtGetNameInGroup( nGeoLayerId, WIN_GEO_RIGHT)
-- recupero BBox e larghezza del geo
local dGeoWidth = EgtGetInfo( nGeoId, WIN_GEOWIDTH, 'd')
-- recupero i controprofili in base al tipo di giunzioni
local sStartProfileType, sEndProfileType = CalcStartEndProfileType( nProfileType, nOutlineId, nStartProfileId, nEndProfileId)
local vsStartProfileType, vsEndProfileType = CalcStartEndProfileType( nProfileType, nOutlineId, vStartProfileId, vEndProfileId)
-- verifico se outline è split interno ad area di split per controlli su inversione del profilo
local bSplitInsideSplitArea = false
if nProfileType == WIN_PRF.SPLIT then
local nAreaId = EgtGetParent( EgtGetParent( nOutlineId))
local nAreaType = EgtGetInfo( nAreaId, WIN_AREATYPE, 'i')
bSplitInsideSplitArea = ( nAreaType == WIN_AREATYPES.SPLIT)
end
-- a) MAIN EXTRUSION
-- creo guida Main
@@ -1622,132 +1673,128 @@ local function CalcFrameSolid( nPartId, nOutlineId, nGeoId, nProfileType)
-- b) START PROFILE
-- posiziono il profilo Start
local nRefStartProfileId = EgtGetFirstNameInGroup( nStartProfileId, WIN_REF)
local b3RefStartProfile = EgtGetBBoxGlob(nRefStartProfileId, GDB_BB.STANDARD)
local dStartDelta = EgtGetInfo( nGeoLayerId, WIN_STARTCPDELTA, 'd') or 0
-- creo guida per estrusione
local nStartGuideId = EgtCopy( nPrevGeoId, nSolidLayerId)
EgtExtendCurveStartByLen( nStartGuideId, 2 * dGeoWidth)
EgtExtendCurveEndByLen( nStartGuideId, 2 * dGeoWidth)
-- recupero frame del profilo
local nStartProfileFrameId = EgtGetFirstNameInGroup( nStartProfileId, WIN_SECTIONFRAME)
local frStartProfile = EgtFR( nStartProfileFrameId)
-- lo sposto se controprofilo
frStartProfile:move( - frStartProfile:getVersX() * dStartDelta)
frStartProfile:invert()
-- lo applico a tutte le geometrie del profilo
EgtTransform( EgtGetAllInGroup( nStartProfileId), frStartProfile)
-- assegno come riferimento del profilo il punto start dell'outline
EgtChangeGroupFrame( nStartProfileId, Frame3d( EgtSP( nStartGuideId), - EgtSV( nStartGuideId)))
-- verifico se outline è split interno ad area di split per controlli su inversione del profilo
local bSplitInsideSplitArea = false
if nProfileType == WIN_PRF.SPLIT then
local nAreaId = EgtGetParent( EgtGetParent( nOutlineId))
local nAreaType = EgtGetInfo( nAreaId, WIN_AREATYPE, 'i')
bSplitInsideSplitArea = ( nAreaType == WIN_AREATYPES.SPLIT)
end
if bSplitInsideSplitArea then
-- verifico se il suo start deriva da uno split
local nStartId = EgtGetInfo( nOutlineId, WIN_SPLIT_STARTINTERS, 'i')
local nStartSouId = nStartId
local sStartSouName
repeat
nStartSouId = EgtGetInfo( nStartSouId, WIN_SOU, 'i')
sStartSouName = EgtGetName( nStartSouId or GDB_ID.NULL)
until not nStartSouId or sStartSouName == WIN_SPLIT
if sStartSouName == WIN_SPLIT then
-- recupero vettore tangente nel punto medio della curva di contorno
local ptMidStart = EgtMP( nStartId)
local vtMidStart = EgtMV( nStartId)
-- recupero vettore tangente nello stesso punto della curva split originale
local dMidStartOnStartSou = EgtCurveParamAtPoint( nStartSouId, ptMidStart)
local vtMidStartSou = EgtUV( nStartSouId, dMidStartOnStartSou, -1)
-- se i due vettori non sono orientati nella stessa direzione
if not AreSameVectorApprox( vtMidStart, vtMidStartSou) then
-- ruoto di 180 gradi il profilo
local frStartProfileS = EgtFR( nStartProfileFrameId, GDB_ID.ROOT)
EgtRotate( nStartProfileId, frStartProfileS:getOrigin(), frStartProfileS:getVersY(), 180, GDB_RT.GLOB)
for i = 1, #vPrevGeoId do
-- posiziono il profilo Start
local nRefStartProfileId = EgtGetFirstNameInGroup( vStartProfileId[i], WIN_REF)
local b3RefStartProfile = EgtGetBBoxGlob( nRefStartProfileId, GDB_BB.STANDARD)
local dStartDelta = EgtGetInfo( nGeoLayerId, WIN_STARTCPDELTA, 'd') or 0
-- creo guida per estrusione
local nStartGuideId = EgtCopy( vPrevGeoId[i], nSolidLayerId)
EgtExtendCurveStartByLen( nStartGuideId, 2 * dGeoWidth)
EgtExtendCurveEndByLen( nStartGuideId, 2 * dGeoWidth)
-- recupero frame del profilo
local nStartProfileFrameId = EgtGetFirstNameInGroup( vStartProfileId[i], WIN_SECTIONFRAME)
local frStartProfile = EgtFR( nStartProfileFrameId)
-- lo sposto se controprofilo
frStartProfile:move( - frStartProfile:getVersX() * dStartDelta)
frStartProfile:invert()
-- lo applico a tutte le geometrie del profilo
EgtTransform( EgtGetAllInGroup( vStartProfileId[i]), frStartProfile)
-- assegno come riferimento del profilo il punto start dell'outline
EgtChangeGroupFrame( vStartProfileId[i], Frame3d( EgtSP( nStartGuideId), - EgtSV( nStartGuideId)))
if bSplitInsideSplitArea then
-- verifico se il suo start deriva da uno split
local nStartId = EgtGetInfo( nOutlineId, WIN_SPLIT_STARTINTERS, 'i')
local nStartSouId = nStartId
local sStartSouName
repeat
nStartSouId = EgtGetInfo( nStartSouId, WIN_SOU, 'i')
sStartSouName = EgtGetName( nStartSouId or GDB_ID.NULL)
until not nStartSouId or sStartSouName == WIN_SPLIT
if sStartSouName == WIN_SPLIT then
-- recupero vettore tangente nel punto medio della curva di contorno
local ptMidStart = EgtMP( nStartId)
local vtMidStart = EgtMV( nStartId)
-- recupero vettore tangente nello stesso punto della curva split originale
local dMidStartOnStartSou = EgtCurveParamAtPoint( nStartSouId, ptMidStart)
local vtMidStartSou = EgtUV( nStartSouId, dMidStartOnStartSou, -1)
-- se i due vettori non sono orientati nella stessa direzione
if not AreSameVectorApprox( vtMidStart, vtMidStartSou) then
-- ruoto di 180 gradi il profilo
local frStartProfileS = EgtFR( nStartProfileFrameId, GDB_ID.ROOT)
EgtRotate( vStartProfileId[i], frStartProfileS:getOrigin(), frStartProfileS:getVersY(), 180, GDB_RT.GLOB)
end
end
end
-- recupero outline del profilo Start e lo estrudo
local nOutStartProfileId
if vsStartProfileType[i] == WIN_MINIZINKEN then
nOutStartProfileId = EgtLine( vStartProfileId[i], EgtSP( vPrevGeoId[i]), EgtSP( vPrevGeoId[i]) - Z_AX() * b3RefStartProfile:getDimY(), GDB_RT.GLOB)
EgtInvertCurve( nOutStartProfileId)
else
nOutStartProfileId = EgtGetFirstNameInGroup( vStartProfileId[i], vsStartProfileType[i])
end
local nStartExtrusionId = EgtSurfTmSwept( nSolidLayerId, nOutStartProfileId, nStartGuideId, false, WIN_SURF_APPROX)
-- eseguo intersezione per ottenere un solido unico
-- ( tagliare le due superfici con EgtSurfTmCut e poi unirle potrebbe creare piccoli buchi legati alle diverse approssimazioni)
EgtSurfTmIntersect( nMainExtrusionId, nStartExtrusionId)
EgtErase( nStartExtrusionId)
EgtErase( nStartGuideId)
end
-- recupero outline del profilo Start e lo estrudo
local nOutStartProfileId
if sStartProfileType == WIN_MINIZINKEN then
nOutStartProfileId = EgtLine( nStartProfileId, EgtSP( nPrevGeoId), EgtSP( nPrevGeoId) - Z_AX() * b3RefStartProfile:getDimY(), GDB_RT.GLOB)
EgtInvertCurve( nOutStartProfileId)
else
nOutStartProfileId = EgtGetFirstNameInGroup( nStartProfileId, sStartProfileType)
end
local nStartExtrusionId = EgtSurfTmSwept( nSolidLayerId, nOutStartProfileId, nStartGuideId, false, WIN_SURF_APPROX)
-- eseguo intersezione per ottenere un solido unico
-- ( tagliare le due superfici con EgtSurfTmCut e poi unirle potrebbe creare piccoli buchi legati alle diverse approssimazioni)
EgtSurfTmIntersect( nMainExtrusionId, nStartExtrusionId)
EgtErase( nStartExtrusionId)
EgtErase( nStartGuideId)
-- c) END PROFILE
-- posiziono il profilo End
local nRefEndProfileId = EgtGetFirstNameInGroup( nEndProfileId, WIN_REF)
local b3RefEndProfile = EgtGetBBoxGlob(nRefEndProfileId, GDB_BB.STANDARD)
local dEndDelta = EgtGetInfo( nGeoLayerId, WIN_ENDCPDELTA, 'd') or 0
-- creo guida per estrusione
local nEndGuideId = EgtCopy( nNextGeoId, nSolidLayerId)
EgtExtendCurveStartByLen( nEndGuideId, 2 * dGeoWidth)
EgtExtendCurveEndByLen( nEndGuideId, 2 * dGeoWidth)
-- recupero frame del profilo
local nEndProfileFrameId = EgtGetFirstNameInGroup( nEndProfileId, WIN_SECTIONFRAME)
local frEndProfile = EgtFR( nEndProfileFrameId)
frEndProfile:move( - frEndProfile:getVersX() * dEndDelta)
frEndProfile:invert()
-- lo applico a tutte le geometrie del profilo
EgtTransform( EgtGetAllInGroup( nEndProfileId), frEndProfile)
-- assegno come riferimento del profilo il punto start dell'outline
EgtChangeGroupFrame( nEndProfileId, Frame3d( EgtSP( nEndGuideId), - EgtSV( nEndGuideId)))
-- verifico se necessario ruotare di 180 gradi il profilo
if bSplitInsideSplitArea then
-- verifico se end deriva da split
local nEndId = EgtGetInfo( nOutlineId, WIN_SPLIT_ENDINTERS, 'i')
local nEndSouId = nEndId
local sEndSouName
repeat
nEndSouId = EgtGetInfo( nEndSouId, WIN_SOU)
sEndSouName = EgtGetName( nEndSouId or GDB_ID.NULL)
until not nEndSouId or sEndSouName == WIN_SPLIT
if sEndSouName == WIN_SPLIT then
-- recupero vettore tangente nel punto medio della curva di contorno
local ptMidEnd = EgtMP( nEndId)
local vtMidEnd = EgtMV( nEndId)
-- recupero vettore tangente nello stesso punto della curva split originale
local dMidStartOnEndSou = EgtCurveParamAtPoint( nEndSouId, ptMidEnd)
local vtMidEndSou = EgtUV( nEndSouId, dMidStartOnEndSou, -1)
-- se i due vettori non sono orientati nella stessa direzione
if not AreSameVectorApprox( vtMidEnd, vtMidEndSou) then
-- ruoto di 180 gradi il profilo
local frEndProfileS = EgtFR( nEndProfileFrameId, GDB_ID.ROOT)
EgtRotate( nEndProfileId, frEndProfileS:getOrigin(), frEndProfileS:getVersY(), 180, GDB_RT.GLOB)
for i = 1, #vNextGeoId do
-- posiziono il profilo End
local nRefEndProfileId = EgtGetFirstNameInGroup( vEndProfileId[i], WIN_REF)
local b3RefEndProfile = EgtGetBBoxGlob( nRefEndProfileId, GDB_BB.STANDARD)
local dEndDelta = EgtGetInfo( nGeoLayerId, WIN_ENDCPDELTA, 'd') or 0
-- creo guida per estrusione
local nEndGuideId = EgtCopy( vNextGeoId[i], nSolidLayerId)
EgtExtendCurveStartByLen( nEndGuideId, 2 * dGeoWidth)
EgtExtendCurveEndByLen( nEndGuideId, 2 * dGeoWidth)
-- recupero frame del profilo
local nEndProfileFrameId = EgtGetFirstNameInGroup( vEndProfileId[i], WIN_SECTIONFRAME)
local frEndProfile = EgtFR( nEndProfileFrameId)
frEndProfile:move( - frEndProfile:getVersX() * dEndDelta)
frEndProfile:invert()
-- lo applico a tutte le geometrie del profilo
EgtTransform( EgtGetAllInGroup( vEndProfileId[i]), frEndProfile)
-- assegno come riferimento del profilo il punto start dell'outline
EgtChangeGroupFrame( vEndProfileId[i], Frame3d( EgtSP( nEndGuideId), - EgtSV( nEndGuideId)))
-- verifico se necessario ruotare di 180 gradi il profilo
if bSplitInsideSplitArea then
-- verifico se end deriva da split
local nEndId = EgtGetInfo( nOutlineId, WIN_SPLIT_ENDINTERS, 'i')
local nEndSouId = nEndId
local sEndSouName
repeat
nEndSouId = EgtGetInfo( nEndSouId, WIN_SOU)
sEndSouName = EgtGetName( nEndSouId or GDB_ID.NULL)
until not nEndSouId or sEndSouName == WIN_SPLIT
if sEndSouName == WIN_SPLIT then
-- recupero vettore tangente nel punto medio della curva di contorno
local ptMidEnd = EgtMP( nEndId)
local vtMidEnd = EgtMV( nEndId)
-- recupero vettore tangente nello stesso punto della curva split originale
local dMidStartOnEndSou = EgtCurveParamAtPoint( nEndSouId, ptMidEnd)
local vtMidEndSou = EgtUV( nEndSouId, dMidStartOnEndSou, -1)
-- se i due vettori non sono orientati nella stessa direzione
if not AreSameVectorApprox( vtMidEnd, vtMidEndSou) then
-- ruoto di 180 gradi il profilo
local frEndProfileS = EgtFR( nEndProfileFrameId, GDB_ID.ROOT)
EgtRotate( vEndProfileId[i], frEndProfileS:getOrigin(), frEndProfileS:getVersY(), 180, GDB_RT.GLOB)
end
end
end
-- recupero outline del profilo End e lo estrudo
local nOutEndProfileId
if vsEndProfileType[i] == WIN_MINIZINKEN then
nOutEndProfileId = EgtLine( vEndProfileId[i], EgtSP( vNextGeoId[i]), EgtSP( vNextGeoId[i]) - Z_AX() * b3RefEndProfile:getDimY(), GDB_RT.GLOB)
EgtInvertCurve( nOutEndProfileId)
else
nOutEndProfileId = EgtGetFirstNameInGroup( vEndProfileId[i], vsEndProfileType[i])
end
local nEndExtrusionId = EgtSurfTmSwept( nSolidLayerId, nOutEndProfileId, nEndGuideId, false, WIN_SURF_APPROX)
-- eseguo intersezione per ottenere un solido unico
EgtSurfTmIntersect( nMainExtrusionId, nEndExtrusionId)
EgtErase( nEndExtrusionId)
EgtErase( nEndGuideId)
end
-- recupero outline del profilo End e lo estrudo
local nOutEndProfileId
if sEndProfileType == WIN_MINIZINKEN then
nOutEndProfileId = EgtLine( nEndProfileId, EgtSP( nNextGeoId), EgtSP( nNextGeoId) - Z_AX() * b3RefEndProfile:getDimY(), GDB_RT.GLOB)
EgtInvertCurve( nOutEndProfileId)
else
nOutEndProfileId = EgtGetFirstNameInGroup( nEndProfileId, sEndProfileType)
end
local nEndExtrusionId = EgtSurfTmSwept( nSolidLayerId, nOutEndProfileId, nEndGuideId, false, WIN_SURF_APPROX)
-- eseguo intersezione per ottenere un solido unico
EgtSurfTmIntersect( nMainExtrusionId, nEndExtrusionId)
EgtErase( nEndExtrusionId)
EgtErase( nEndGuideId)
end
@@ -1807,7 +1854,6 @@ local function CreatePartFromOutline( nAreaLayerId, nOutlineId, bBottomRail)
-- calcolo i fori per le spine
CalcFrameDowels( nPartId, nOutlineId, nOutlineLayerId, nProfileType)
-- b) Fill
elseif nAreaType == WIN_AREATYPES.FILL then
-- imposto nome del pezzo
@@ -1837,30 +1883,29 @@ end
---------------------------- STRIP ----------------------------------
---------------------------------------------------------------------
-- funzione che restitutisce lo Strip piu' vicino
local function GetStripNearestToOutline( nProfileId, nOutlineId)
-- recupero strip
local ptStartOutline = EgtMP( nOutlineId)
local vtStartOutline = EgtSV( nOutlineId)
local nStartStripId = EgtGetFirstNameInGroup( nProfileId, WIN_STRIP)
if not nStartStripId then
local nStripMinDistId
local dMinDistance
local nStripId = EgtGetFirstNameInGroup( nProfileId, WIN_STRIP .. '*')
while nStripId do
local b3Strip = EgtGetBBoxGlob( nStripId, GDB_BB.STANDARD)
-- calcolo il vettore distanza
local vtDistance = b3Strip:getCenter() - ptStartOutline
-- ne ricavo la componente nella stessa direzione dell'outline
local dDistance = abs( vtDistance * vtStartOutline)
if not dMinDistance or dDistance < dMinDistance then
dMinDistance = dDistance
nStripMinDistId = nStripId
end
nStripId = EgtGetNextName( nStripId, WIN_STRIP .. '*')
-- ( analoga a GetProfileCtrIn)
local function GetStripNearestToOutline( nPrevProfileId, nPrevOutlineId, nOutlineId)
local nStripId = EgtGetFirstNameInGroup( nPrevProfileId, WIN_STRIP)
-- gestione particolare del caso di profilo di split
if not nStripId then
-- recupero la curva di base outline da cui deriva il precedente
local nPrevSouId = EgtGetInfo( nPrevOutlineId, WIN_COPY, 'i')
local sPrevSouName
repeat
nPrevSouId = EgtGetInfo( nPrevSouId, WIN_SOU, 'i')
sPrevSouName = EgtGetName( nPrevSouId or GDB_ID.NULL)
until not nPrevSouId or sPrevSouName == WIN_SPLIT
-- verifico da quale lato si trova la curva per decidere quale controprofilo considerare
local _, _, dSide = EgtPointCurveDistSide( EgtMP( nOutlineId), nPrevSouId, Z_AX())
if dSide == 1 then
nStripId = EgtGetFirstNameInGroup( nPrevProfileId, WIN_STRIP .. '1') -- dx
else
nStripId = EgtGetFirstNameInGroup( nPrevProfileId, WIN_STRIP .. '2') -- sx
end
nStartStripId = nStripMinDistId
end
return nStartStripId
return nStripId
end
---------------------------------------------------------------------
@@ -1885,7 +1930,7 @@ local function CreateStripGuideLines( nOutlineId, nStripId, nProfileId, nSolidLa
EgtOffsetCurve( nStripMaxOffsetId, dMainStripMaxDelta)
return nStripMinOffsetId, nStripMaxOffsetId
end
---------------------------------------------------------------------
@@ -1924,7 +1969,10 @@ local function CreateStripFromOutline( nAreaId, nOutlineId)
-- recupero gli outline precedente e successivo ( non serve utilizzare un WIN_PRF accurato perchè conta solo sia diverso da split)
local nOutlineLayerId = EgtGetParent( nOutlineId)
local nPrevOutlineId, nNextOutlineId = GetPrevNextOutline( WIN_PRF.NULL, nOutlineId, nOutlineLayerId)
local vPrevOutlineId, vNextOutlineId = GetPrevNextOutline( WIN_PRF.NULL, nOutlineId, nOutlineLayerId)
local nPrevOutlineId = vPrevOutlineId[1]
local nNextOutlineId = vNextOutlineId[1]
-- recupero i pezzi precedente e successivo, prendendo eventualmente quelli di bottomrail
local nPrevPartId = FindAssociatedPart( nPrevOutlineId)
local nNextPartId = FindAssociatedPart( nNextOutlineId)
@@ -1940,20 +1988,20 @@ local function CreateStripFromOutline( nAreaId, nOutlineId)
-- recupero guida Main
local nGuideId = EgtGetFirstNameInGroup( nSolidLayerId, WIN_MAINGUIDE)
-- recupero strip piu' vicino a prev outline
local nMainStripId = GetStripNearestToOutline( nMainProfileId, nPrevOutlineId)
local nMainStripId = GetStripNearestToOutline( nMainProfileId, nOutlineId, nPrevOutlineId)
-- estrudo MainStrip
local nMainStripExtrusionId = EgtSurfTmSwept( nSolidLayerId, nMainStripId, nGuideId, false, WIN_SURF_APPROX)
EgtSetName( nMainStripExtrusionId, WIN_SRF_STRIP)
-- b) taglio con start
-- recupero strip dello start piu' vicino ad outline
local nStartStripId = GetStripNearestToOutline( nStartProfileId, nOutlineId)
local nStartStripId = GetStripNearestToOutline( nStartProfileId, nPrevOutlineId, nOutlineId)
-- disegno guida start per lo strip trovando le intersezioni degli outline minimi e massimi tra MainStrip e StartStrip
local nMainStripMinOffsetId, nMainStripMaxOffsetId = CreateStripGuideLines( nOutlineId, nMainStripId, nMainProfileId, nSolidLayerId)
local nStartStripMinOffsetId, nStartStripMaxOffsetId = CreateStripGuideLines( nPrevOutlineId, nStartStripId, nStartProfileId, nSolidLayerId)
local ptStripMinStart = EgtIP( nMainStripMinOffsetId, nStartStripMinOffsetId, EgtSP( nMainStripMinOffsetId))
local ptStripMaxStart = EgtIP( nMainStripMaxOffsetId, nStartStripMaxOffsetId, EgtSP( nMainStripMaxOffsetId))
local ptStripMinStart = FindIntersectionPoint( nMainStripMinOffsetId, nStartStripMinOffsetId)
local ptStripMaxStart = FindIntersectionPoint( nMainStripMaxOffsetId, nStartStripMaxOffsetId)
local nStartStripGuideId = EgtLine( nSolidLayerId, ptStripMinStart, ptStripMaxStart)
EgtExtendCurveStartByLen( nStartStripGuideId, 10)
EgtExtendCurveEndByLen( nStartStripGuideId, 10)
@@ -1972,12 +2020,12 @@ local function CreateStripFromOutline( nAreaId, nOutlineId)
-- c) taglio con end
-- recupero strip piu' vicino ad outline
local nEndStripId = GetStripNearestToOutline( nEndProfileId, nOutlineId)
local nEndStripId = GetStripNearestToOutline( nEndProfileId, nNextOutlineId, nOutlineId)
-- disegno guida end per lo strip trovando le intersezioni degli outline minimi e massimi tra MainStrip ed EndStrip
local nEndStripMinOffsetId, nEndStripMaxOffsetId = CreateStripGuideLines( nNextOutlineId, nEndStripId, nEndProfileId, nSolidLayerId)
local ptStripMinEnd = EgtIP( nMainStripMinOffsetId, nEndStripMinOffsetId, EgtSP( nMainStripMinOffsetId))
local ptStripMaxEnd = EgtIP( nMainStripMaxOffsetId, nEndStripMaxOffsetId, EgtSP( nMainStripMaxOffsetId))
local ptStripMinEnd = FindIntersectionPoint( nMainStripMinOffsetId, nEndStripMinOffsetId)
local ptStripMaxEnd = FindIntersectionPoint( nMainStripMaxOffsetId, nEndStripMaxOffsetId)
local nEndStripGuideId = EgtLine( nSolidLayerId, ptStripMinEnd, ptStripMaxEnd)
EgtExtendCurveStartByLen( nEndStripGuideId, 10)
EgtExtendCurveEndByLen( nEndStripGuideId, 10)
@@ -2069,7 +2117,7 @@ local function CalculateAreaParts( nAreaId)
end
end
end
-- disegno area di selezione per programma
local nSelectionLayerId = EgtGroup( nAreaId)
EgtSetName( nSelectionLayerId, WIN_SELECTION)
+190 -75
View File
@@ -59,73 +59,141 @@ function WinCreate.ImportProfile( sProfilePath)
return true
end
-- funzione che crea il buco rettangolare per la finestra
function WinCreate.CreateFrame( dWidth, dHeight, nJointBL, nJointBR, nJointTR, nJointTL)
----------------------------------------------------------------------------------
------------------------------------- TELAIO -------------------------------------
----------------------------------------------------------------------------------
-- funzione che crea il buco per la finestra a partire da curve generiche
-- TO DO rendere i joints un vettore con un numero variabile a seconda del tipo di finestra
function WinCreate.CreateGenFrame( vFrameCrvs, nJointBL, nJointBR, nJointTL, nJointTR)
-- creo gruppo per telaio
local nFrameAreaId = EgtGroup( GDB_ID.ROOT)
EgtSetName( nFrameAreaId, WIN_AREA .. '(' .. WIN_FRAME .. ')')
-- imposto il tipo
EgtSetInfo( nFrameAreaId, WIN_AREATYPE, WIN_AREATYPES.FRAME)
-- creo il gruppo con le curve di outline
local nAreaOutlineLayerId = EgtGroup( nFrameAreaId)
EgtSetName( nAreaOutlineLayerId, WIN_AREAOUTLINE)
EgtSetStatus( nAreaOutlineLayerId, GDB_ST.OFF)
-- disegno outline
local nFrameBottomId = EgtLine( nAreaOutlineLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0))
EgtSetName( nFrameBottomId, WIN_BOTTOM)
local nFrameRightId = EgtLine( nAreaOutlineLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight, 0))
EgtSetName( nFrameRightId, WIN_RIGHT)
local nFrameTopId = EgtLine( nAreaOutlineLayerId, Point3d( dWidth, dHeight, 0), Point3d( 0, dHeight, 0))
EgtSetName( nFrameTopId, WIN_TOP)
local nFrameLeftId = EgtLine( nAreaOutlineLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0))
EgtSetName( nFrameLeftId, WIN_LEFT)
for i = 1, #vFrameCrvs do
EgtRelocateGlob( vFrameCrvs[i], nAreaOutlineLayerId)
end
-- imposto tipo giunzioni
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_BL, nJointBL)
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_BR, nJointBR)
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_TL, nJointTL)
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_TR, nJointTR)
return nFrameAreaId
return nFrameAreaId
end
-- funzione che crea il buco per la finestra
function WinCreate.CreateGenFrame( nFrameBottomId, nFrameRightId, nFrameTopId, nFrameLeftId, nJointBL, nJointBR, nJointTR, nJointTL)
-- creo gruppo per telaio
local nFrameAreaId = EgtGroup( GDB_ID.ROOT)
EgtSetName( nFrameAreaId, WIN_AREA .. '(' .. WIN_FRAME .. ')')
-- imposto il tipo
EgtSetInfo( nFrameAreaId, WIN_AREATYPE, WIN_AREATYPES.FRAME)
local nAreaOutlineLayerId = EgtGroup( nFrameAreaId)
EgtSetName( nAreaOutlineLayerId, WIN_AREAOUTLINE)
----------------------------------------------------------------------------------
-- funzione che crea le curve che definiscono il telaio in base alla geometria richiesta
local function CreateFrameCurves( nLayerId, nType, dWidth, dHeight, dVal)
if nType == WIN_FRAME_TYPE.RECT then
-- telaio rettangolare
local nFrameBottomId = EgtLine( nLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0))
EgtSetName( nFrameBottomId, WIN_BOTTOM)
local nFrameRightId = EgtLine( nLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight, 0))
EgtSetName( nFrameRightId, WIN_RIGHT)
local nFrameTopId = EgtLine( nLayerId, Point3d( dWidth, dHeight, 0), Point3d( 0, dHeight, 0))
EgtSetName( nFrameTopId, WIN_TOP)
local nFrameLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0))
EgtSetName( nFrameLeftId, WIN_LEFT)
elseif nType == WIN_FRAME_TYPE.CHAMFER_SIDE then
-- dHeight è l'altezza del lato sx, dVal è l'altezza del lato dx
local nFrameBottomId = EgtLine( nLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0))
EgtSetName( nFrameBottomId, WIN_BOTTOM)
local nFrameRightId = EgtLine( nLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dVal, 0))
EgtSetName( nFrameRightId, WIN_RIGHT)
local nFrameTopId = EgtLine( nLayerId, Point3d( dWidth, dVal, 0), Point3d( 0, dHeight, 0))
EgtSetName( nFrameTopId, WIN_TOP)
local nFrameLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0))
EgtSetName( nFrameLeftId, WIN_LEFT)
elseif nType == WIN_FRAME_TYPE.CHAMFER then
-- dHeight è l'altezza dei lati verticali, dVal è l'altezza complessiva della finestra
local nFrameBottomId = EgtLine( nLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0))
EgtSetName( nFrameBottomId, WIN_BOTTOM)
local nFrameRightId = EgtLine( nLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight, 0))
EgtSetName( nFrameRightId, WIN_RIGHT)
local nFrameTop1Id = EgtLine( nLayerId, Point3d( dWidth, dHeight, 0), Point3d( dWidth / 2, dVal, 0))
local nFrameTop2Id = EgtLine( nLayerId, Point3d( dWidth / 2, dVal, 0), Point3d( 0, dHeight, 0))
EgtSetName( nFrameTop1Id, WIN_TOP)
EgtSetName( nFrameTop2Id, WIN_TOP)
local nFrameLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0))
EgtSetName( nFrameLeftId, WIN_LEFT)
elseif nType == WIN_FRAME_TYPE.ROUND_ARC then
-- arco a tutto sesto
local nFrameBottomId = EgtLine( nLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0))
EgtSetName( nFrameBottomId, WIN_BOTTOM)
local nFrameRightId = EgtLine( nLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight - 0.5 * dWidth, 0))
EgtSetName( nFrameRightId, WIN_RIGHT)
local nFrameTopId = EgtArcCPA( nLayerId, Point3d( 0.5 * dWidth, dHeight - 0.5 * dWidth, 0), Point3d( dWidth, dHeight - 0.5 * dWidth, 0), 180, 0)
EgtSetName( nFrameTopId, WIN_TOP)
local nFrameLeftId = EgtLine( nLayerId, Point3d( 0, dHeight - 0.5 * dWidth, 0), Point3d( 0, 0, 0))
EgtSetName( nFrameLeftId, WIN_LEFT)
elseif nType == WIN_FRAME_TYPE.SEGMENTAL_ARC then
-- arco ribassato
-- dHeight è l'altezza dei lati verticali, dVal è l'altezza complessiva della finestra
local nFrameBottomId = EgtLine( nLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0))
EgtSetName( nFrameBottomId, WIN_BOTTOM)
local nFrameRightId = EgtLine( nLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight, 0))
EgtSetName( nFrameRightId, WIN_RIGHT)
local nFrameTopId = EgtArc3P( nLayerId, Point3d( dWidth, dHeight, 0), Point3d( 0.5 * dWidth, dVal, 0), Point3d( 0, dHeight, 0))
EgtSetName( nFrameTopId, WIN_TOP)
local nFrameLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0))
EgtSetName( nFrameLeftId, WIN_LEFT)
elseif nType == WIN_FRAME_TYPE.POINTED_ARC then
-- arco a tutto sesto
-- dHeight è l'altezza dei lati verticali, dVal è l'altezza complessiva della finestra
-- verifico che le due altezze abbiano valori sensati per realizzare i due archi
if dVal - dHeight < 0.5 * dWidth then
return
end
local nFrameBottomId = EgtLine( nLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0))
EgtSetName( nFrameBottomId, WIN_BOTTOM)
local nFrameRightId = EgtLine( nLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight, 0))
EgtSetName( nFrameRightId, WIN_RIGHT)
local nFrameTop1Id = EgtArc2PV( nLayerId, Point3d( dWidth, dHeight, 0), Point3d( 0.5 * dWidth, dVal, 0), Y_AX())
EgtSetName( nFrameTop1Id, WIN_TOP)
local nFrameTop2Id = EgtArc2PV( nLayerId, Point3d( 0, dHeight, 0), Point3d( 0.5 * dWidth, dVal, 0), Y_AX())
EgtInvertCurve( nFrameTop2Id)
EgtSetName( nFrameTop2Id, WIN_TOP)
local nFrameLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0))
EgtSetName( nFrameLeftId, WIN_LEFT)
elseif nType == WIN_FRAME_TYPE.TRG then
local nFrameBottomId = EgtLine( nLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0))
EgtSetName( nFrameBottomId, WIN_BOTTOM)
local nFrameRightId = EgtLine( nLayerId, Point3d( dWidth, 0, 0), Point3d( dVal, dHeight, 0))
EgtSetName( nFrameRightId, WIN_RIGHT)
local nFrameLeftId = EgtLine( nLayerId, Point3d( dVal, dHeight, 0), Point3d( 0, 0, 0))
EgtSetName( nFrameLeftId, WIN_LEFT)
end
end
----------------------------------------------------------------------------------
-- funzione che crea il telaio a partire da una specifica geometria ( rettangolo, chamfer...)
function WinCreate.CreateFrame( nType, nJointBL, nJointBR, nJointTL, nJointTR, dWidth, dHeight, dHeight2)
-- creo un gruppo temporaneo per le curve di outline
local nTmpLay = EgtGroup( GDB_ID.ROOT)
-- disegno outline
EgtRelocateGlob( nFrameBottomId, nAreaOutlineLayerId)
EgtSetName( nFrameBottomId, WIN_BOTTOM)
EgtRelocateGlob( nFrameRightId, nAreaOutlineLayerId)
EgtSetName( nFrameRightId, WIN_RIGHT)
EgtRelocateGlob( nFrameTopId, nAreaOutlineLayerId)
EgtSetName( nFrameTopId, WIN_TOP)
EgtRelocateGlob( nFrameLeftId, nAreaOutlineLayerId)
EgtSetName( nFrameLeftId, WIN_LEFT)
-- imposto tipo giunzioni
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_BL, nJointBL)
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_BR, nJointBR)
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_TL, nJointTL)
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_TR, nJointTR)
CreateFrameCurves( nTmpLay, nType, dWidth, dHeight, dHeight2)
local nFrameAreaId = WinCreate.CreateGenFrame( EgtGetAllInGroup( nTmpLay), nJointBL, nJointBR, nJointTL, nJointTR)
EgtErase( nTmpLay)
return nFrameAreaId
end
-- -- funzione che crea il telaio a partire dal buco
-- function WinCreate.CreateFrameOnHole( nHoleLayerId, dWidth, dHeight)
-- local nAreaOutlineLayerId = EgtGroup( nHoleLayerId)
-- EgtSetName( nAreaOutlineLayerId, WIN_OUTLINE)
-- -- disegno outline
-- local nHoleBottomId = EgtLine( nAreaOutlineLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0))
-- EgtSetName( nHoleBottomId, WIN_BOTTOM)
-- local nHoleRightId = EgtLine( nAreaOutlineLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight, 0))
-- EgtSetName( nHoleRightId, WIN_RIGHT)
-- local nHoleTopId = EgtLine( nAreaOutlineLayerId, Point3d( dWidth, dHeight, 0), Point3d( 0, dHeight, 0))
-- EgtSetName( nHoleTopId, WIN_TOP)
-- local nHoleLeftId = EgtLine( nAreaOutlineLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0))
-- EgtSetName( nHoleLeftId, WIN_LEFT)
-- end
----------------------------------------------------------------------------------
-------------------------------------- ANTA --------------------------------------
----------------------------------------------------------------------------------
-- funzione che aggiunge una anta
function WinCreate.AddSash( nAreaId, nJointBL, nJointBR, nJointTR, nJointTL, nSashType)
-- creo nuova area
@@ -158,6 +226,9 @@ function WinCreate.AddSash( nAreaId, nJointBL, nJointBR, nJointTR, nJointTL, nSa
return nSashAreaId
end
----------------------------------------------------------------------------------
-------------------------------------- FILL --------------------------------------
----------------------------------------------------------------------------------
-- funzione che aggiunge un riempimento
function WinCreate.AddFill( nAreaId, FillType)
-- creo nuova area
@@ -176,32 +247,29 @@ function WinCreate.AddFill( nAreaId, FillType)
EgtSetInfo( nOutlineId, WIN_SOU, nAreaOutlineId)
EgtRemoveInfo( nOutlineId, WIN_CHILD)
AddInfo( nAreaOutlineId, WIN_CHILD, nOutlineId)
EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_BL)
EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_BR)
EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_TL)
EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_TR)
nAreaOutlineId = EgtGetNext( nAreaOutlineId)
end
-- rimuovo eventuali info di giunzioni
EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_BL)
EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_BR)
EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_TL)
EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_TR)
-- imposto tipo di fill
EgtSetInfo( nFillAreaId, WIN_FILLTYPE, FillType)
return nFillAreaId
end
----------------------------------------------------------------------------------
------------------------------------- SPLIT --------------------------------------
----------------------------------------------------------------------------------
-- funzione che crea un taglio split
function WinCreate.AddSplit( nAreaLayerId, SplitType, MeasureType, nPosition, nProportion, nSplitType)
function WinCreate.AddSplit( nAreaLayerId, SplitType, MeasureType, nPosition, nProportion, nSplitType)
-- creo layer temporaneo per split
local nTempSplitLayerId = EgtGroup( nAreaLayerId)
EgtSetName( nTempSplitLayerId, WIN_TEMPSPLIT)
-- recupero contorno area precedente
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_AREAOUTLINE)
local b3OutlineLayer = EgtGetBBox( nOutlineLayerId, GDB_BB.STANDARD)
local OutlineIds = {}
local nOutlineId = EgtGetFirstInGroup( nOutlineLayerId)
while nOutlineId do
local sName = EgtGetName( nOutlineId)
table.insert( OutlineIds, nOutlineId)
nOutlineId = EgtGetNext( nOutlineId)
end
local nTotSplitId
if SplitType == WIN_SPLITORIENTATION.VERTICAL then
-- creo linea
@@ -232,6 +300,7 @@ function WinCreate.AddSplit( nAreaLayerId, SplitType, MeasureType, nPosition, n
return nArea1Id, nArea2Id
end
----------------------------------------------------------------------------------
-- funzione che crea tagli split multipli
function WinCreate.AddSplits( nAreaLayerId, SplitType, MeasureType, PositionList, nProportion, nSplitType)
local AreaList = {}
@@ -285,6 +354,7 @@ function WinCreate.AddSplits( nAreaLayerId, SplitType, MeasureType, PositionList
return AreaList
end
----------------------------------------------------------------------------------
-- funzione che crea un taglio split da una curva generica
function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType)
-- se area nulla diventa di tipo split
@@ -320,8 +390,8 @@ function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType)
local EndInters
for nIndex = 1, #OutlineInters do
local CurrOutInters = OutlineInters[nIndex]
CurrOutInters.StartDistance = (CurrOutInters.IntersPoint - ptStartSplit):sqlen()
CurrOutInters.EndDistance = (CurrOutInters.IntersPoint - ptEndSplit):sqlen()
CurrOutInters.StartDistance = dist( CurrOutInters.IntersPoint, ptStartSplit)
CurrOutInters.EndDistance = dist( CurrOutInters.IntersPoint, ptEndSplit)
if not StartInters or CurrOutInters.StartDistance < StartInters.StartDistance then
StartInters = CurrOutInters
end
@@ -334,8 +404,36 @@ function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType)
EgtTrimCurveStartAtParam( nSplitId, dStartSplitInters)
local dEndSplitInters = EgtCurveParamAtPoint( nSplitId, EndInters.IntersPoint)
EgtTrimCurveEndAtParam( nSplitId, dEndSplitInters)
EgtSetInfo( nSplitId, WIN_SPLIT_STARTINTERS, StartInters.Id)
EgtSetInfo( nSplitId, WIN_SPLIT_ENDINTERS, EndInters.Id)
-- sistemo le info di intersezione
local dPar1 = EgtCurveParamAtPoint( StartInters.Id, StartInters.IntersPoint, 100 * GEO.EPS_SMALL)
local _, dParE1 = EgtCurveDomain( StartInters.Id)
if dPar1 < GEO.EPS_SMALL then
-- intersezione coinvolge anche curva precedente
local nOther = EgtGetPrev( StartInters.Id) or EgtGetLastInGroup( nOutlineLayerId)
EgtSetInfo( nSplitId, WIN_SPLIT_STARTINTERS, { nOther, StartInters.Id})
elseif abs( dPar1 - dParE1) < GEO.EPS_SMALL then
-- intersezione coinvolge anche curva successiva
local nOther = EgtGetNext( StartInters.Id) or EgtGetFirstInGroup( nOutlineLayerId)
EgtSetInfo( nSplitId, WIN_SPLIT_STARTINTERS, { StartInters.Id, nOther})
else
EgtSetInfo( nSplitId, WIN_SPLIT_STARTINTERS, { StartInters.Id})
end
local dPar2 = EgtCurveParamAtPoint( EndInters.Id, EndInters.IntersPoint, 100 * GEO.EPS_SMALL)
local _, dParE2 = EgtCurveDomain( EndInters.Id)
if dPar2 < GEO.EPS_SMALL then
-- intersezione coinvolge anche curva precedente
local nOther = EgtGetPrev( EndInters.Id) or EgtGetLastInGroup( nOutlineLayerId)
EgtSetInfo( nSplitId, WIN_SPLIT_ENDINTERS, { nOther, EndInters.Id})
elseif abs( dPar2 - dParE2) < GEO.EPS_SMALL then
-- intersezione coinvolge anche curva successiva
local nOther = EgtGetNext( EndInters.Id) or EgtGetFirstInGroup( nOutlineLayerId)
EgtSetInfo( nSplitId, WIN_SPLIT_ENDINTERS, { EndInters.Id, nOther})
else
EgtSetInfo( nSplitId, WIN_SPLIT_ENDINTERS, { EndInters.Id})
end
-- assegno nome profilo
EgtSetName( nSplitId, WIN_SPLIT)
-- creo aree
@@ -356,6 +454,7 @@ function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType)
return nArea1Id, nArea2Id
end
----------------------------------------------------------------------------------
-- funzione che crea tagli split da curve generiche
function WinCreate.AddGenSplits( nAreaLayerId, SplitList)
for nIndex = 1, #SplitList do
@@ -363,6 +462,7 @@ function WinCreate.AddGenSplits( nAreaLayerId, SplitList)
end
end
----------------------------------------------------------------------------------
-- funzione che crea le aree da un taglio split
function WinCreate.CreateAreaFromSplit( nAreaLayerId, nSplitId)
-- creo layer per le due aree
@@ -386,13 +486,18 @@ function WinCreate.CreateAreaFromSplit( nAreaLayerId, nSplitId)
if ptInters then
if nInters == 0 then
-- trovato primo punto di intersezione - inizio area 2
nInters = 1
local nCopyId = EgtCopy( nOutlineId, nArea2OutlineLayerId)
EgtSetInfo( nCopyId, WIN_SOU, nOutlineId)
EgtRemoveInfo( nCopyId, WIN_CHILD)
AddInfo( nOutlineId, WIN_CHILD, nCopyId)
local dStartIntersParam = EgtCurveParamAtPoint( nCopyId, ptInters)
EgtTrimCurveStartAtParam( nCopyId, dStartIntersParam)
local dStartIntersParam = EgtCurveParamAtPoint( nOutlineId, ptInters)
local _, dParE = EgtCurveDomain( nOutlineId)
if abs( dStartIntersParam - dParE) < GEO.EPS_SMALL then
-- se intersezione nel punto finale della curva la ignoro, la ritroverò analizzando l'outline successivo
else
nInters = 1
local nCopyId = EgtCopy( nOutlineId, nArea2OutlineLayerId)
EgtSetInfo( nCopyId, WIN_SOU, nOutlineId)
EgtRemoveInfo( nCopyId, WIN_CHILD)
AddInfo( nOutlineId, WIN_CHILD, nCopyId)
EgtTrimCurveStartAtParam( nCopyId, dStartIntersParam)
end
elseif nInters == 1 then
-- trovato secondo punto di intersezione - fine area 2
nInters = 2
@@ -423,6 +528,11 @@ function WinCreate.CreateAreaFromSplit( nAreaLayerId, nSplitId)
EgtSetName( nSplitCopyId, WIN_LEFT)
end
-- inizio area 1
local _, dEnd = EgtCurveDomain( nOutlineId)
if abs( dEndIntersParam - dEnd) < GEO.EPS_SMALL then
-- l'intersezione è sul punto finale della curva di outline, quindi è la curva successiva che dà inizio all'area 1
nOutlineId = EgtGetNext( nOutlineId) or EgtGetFirstInGroup( nOutlineLayerId)
end
nCopyId = EgtCopy( nOutlineId, nArea1OutlineLayerId)
EgtSetInfo( nCopyId, WIN_SOU, nOutlineId)
EgtRemoveInfo( nCopyId, WIN_CHILD)
@@ -495,10 +605,12 @@ function WinCreate.CreateAreaFromSplit( nAreaLayerId, nSplitId)
nFirstInAreaId = EgtGetFirstInGroup( nArea2OutlineLayerId)
sFirstInAreaName = EgtGetName( nFirstInAreaId)
end
-- error('qqq')
return nArea1Id, nArea2Id
end
----------------------------------------------------------------------------------
---------------------------------- BOTTOMRAIL ------------------------------------
----------------------------------------------------------------------------------
-- funzione che aggiunge uno zoccolo
function WinCreate.AddBottomRail( nAreaId)
local nAreaType = EgtGetInfo( nAreaId, WIN_AREATYPE, 'i')
@@ -510,8 +622,11 @@ function WinCreate.AddBottomRail( nAreaId)
end
end
----------------------------------------------------------------------------------
---------------------------------- FERRAMENTA ------------------------------------
----------------------------------------------------------------------------------
function WinCreate.AddHardware( nFrameId, sFavourite)
EgtSetInfo( nFrameId, WIN_HDW_FAVOURITE, sFavourite )
EgtSetInfo( nFrameId, WIN_HDW_FAVOURITE, sFavourite)
end
---------------------------------------------------------------------
+7 -2
View File
@@ -160,11 +160,15 @@ local function ConvertTableToGeometry( AreaTable, nAreaId)
ConvertCurveTableToEntity( nDrawFrameLayerId, CurrCurve)
end
local nFrameBottomId = EgtGetFirstInGroup(nDrawFrameLayerId)
EgtSetName( nFrameBottomId, WIN_BOTTOM)
local nFrameRightId = EgtGetNext(nFrameBottomId)
EgtSetName( nFrameRightId, WIN_RIGHT)
local nFrameTopId = EgtGetNext(nFrameRightId)
EgtSetName( nFrameTopId, WIN_TOP)
local nFrameLeftId = EgtGetNext(nFrameTopId)
EgtSetName( nFrameLeftId, WIN_LEFT)
-- creo frame
nAreaId = WinCreate.CreateGenFrame( nFrameBottomId, nFrameRightId, nFrameTopId, nFrameLeftId, AreaTable[JWD_JOINT][JWD_JOINT_BL], AreaTable[JWD_JOINT][JWD_JOINT_BR], AreaTable[JWD_JOINT][JWD_JOINT_TR], AreaTable[JWD_JOINT][JWD_JOINT_TL])
nAreaId = WinCreate.CreateGenFrame( {nFrameBottomId, nFrameRightId, nFrameTopId, nFrameLeftId}, AreaTable[JWD_JOINT][JWD_JOINT_BL], AreaTable[JWD_JOINT][JWD_JOINT_BR], AreaTable[JWD_JOINT][JWD_JOINT_TR], AreaTable[JWD_JOINT][JWD_JOINT_TL])
-- elimino contorno frame
EgtErase( nDrawFramePartId)
-- se BottomRail
@@ -185,7 +189,8 @@ local function ConvertTableToGeometry( AreaTable, nAreaId)
EgtSetName( nDrawFramePartId, 'DrawFrame')
local nDrawFrameLayerId = EgtGroup( nDrawFramePartId)
ConvertCurveTableToEntity( nDrawFrameLayerId, AreaTable[JWD_SPLIT][1])
local nArea1Id, nArea2Id = WinCreate.AddGenSplit( nAreaId, EgtGetFirstInGroup(nDrawFrameLayerId)) --, nSplitType)
local nArea1Id, nArea2Id = WinCreate.AddGenSplit( nAreaId, EgtGetFirstInGroup(nDrawFrameLayerId), AreaTable["SplitType"])
-- local nArea1Id, nArea2Id = WinCreate.AddGenSplit( nAreaId, EgtGetFirstInGroup(nDrawFrameLayerId))
EgtErase(nDrawFramePartId)
ConvertTableToGeometry( AreaTable[JWD_AREA .. 1], nArea1Id)
ConvertTableToGeometry( AreaTable[JWD_AREA .. 2], nArea2Id)
+1 -1
View File
@@ -43,7 +43,7 @@ end
_G.WinCreate_ImportProfile = WinCreate_ImportProfile
local function WinCreate_CreateFrame()
WDG.AREAID = WinCreate.CreateFrame(WDG.WIDTH, WDG.HEIGHT, WDG.JOINTBL, WDG.JOINTBR, WDG.JOINTTR, WDG.JOINTTL)
WDG.AREAID = WinCreate.CreateFrame(WDG.FRAMETYPE, WDG.JOINTBL, WDG.JOINTBR, WDG.JOINTTR, WDG.JOINTTL, WDG.WIDTH, WDG.HEIGHT, WDG.HEIGHT2)
end
_G.WinCreate_CreateFrame = WinCreate_CreateFrame