- Modificate tutti i lua dei bottoni per portarli in libreria

This commit is contained in:
Emmanuele Sassi
2022-04-12 13:10:05 +02:00
parent 39db4c9e37
commit a066ea8f9a
18 changed files with 871 additions and 697 deletions
+5 -50
View File
@@ -10,54 +10,9 @@ EgtEnableDebug( false)
local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- Costanti generali
_G.package.loaded.AddManData = nil
local AMD = require( 'AddManData')
-- Librerie
_G.package.loaded.RunGcodeGenerate = nil
local RGCG = require( 'RunGcodeGenerate')
-- Recupero il pezzo (per ora primo e unico)
local nPartIndex = 1
local nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
if not nPartId then
EgtOutBox( 'Error missing part', 'GcodeGenerate')
return
end
-- Recupero i layer da processare
local vLayIds = EgtGetNameInGroup( nPartId, SLICE_LAYER.."*")
if not vLayIds then
EgtOutBox( 'Error missing slices', 'ToolPathCalc')
return
end
-- Ciclo sui layer
local vEntId = {}
for nIdx = 1, #vLayIds do
-- scorro tutti i gruppi di contorni
local nCrvGrpId = EgtGetFirstNameInGroup( vLayIds[ nIdx], CONTOUR_GRP.."*")
while nCrvGrpId do
-- recupero il gruppo dei percorsi utensile
local nTpathGrpId = EgtGetFirstNameInGroup( nCrvGrpId, TOOLPATH_GRP)
if not nTpathGrpId then
EgtOutBox( 'Error missing toolpaths', 'ToolPathCalc')
return
end
-- recupero le entità nel gruppo
local nEntId = EgtGetFirstInGroup( nTpathGrpId)
while nEntId do
table.insert( vEntId, nEntId)
nEntId = EgtGetNext( nEntId)
end
--passo al gruppo di contorni successivo
nCrvGrpId = EgtGetNextName( nCrvGrpId, CONTOUR_GRP.."*")
end
end
if #vEntId == 0 then
EgtOutBox( 'Error missing entities', 'ToolPathCalc')
return
end
-- Aggiungo la lavorazione
EgtSetCurrMachGroup()
EgtAddMachining( 'Extrusion 1', 'ExtrusionA')
EgtSetMachiningGeometry( vEntId)
EgtApplyMachining()
-- Calcolo
RGCG.Exec()
+67
View File
@@ -0,0 +1,67 @@
-- RunGcodeGenerate.lua by Egaltech s.r.l. 2022/04/11
-- Calcoli prima fase per Stampa 3d
-- Tabella per definizione modulo
local RunGcodeGenerate = {}
-- Intestazioni
require( 'EgtBase')
EgtOutLog( ' RunGcodeGenerate started', 1)
-- Costanti generali
_G.package.loaded.AddManData = nil
local AMD = require( 'AddManData')
function RunGcodeGenerate.Exec()
-- Recupero il pezzo (per ora primo e unico)
local nPartIndex = 1
local nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
if not nPartId then
EgtOutBox( 'Error missing part', 'GcodeGenerate')
return
end
-- Recupero i layer da processare
local vLayIds = EgtGetNameInGroup( nPartId, SLICE_LAYER.."*")
if not vLayIds then
EgtOutBox( 'Error missing slices', 'ToolPathCalc')
return
end
-- Ciclo sui layer
local vEntId = {}
for nIdx = 1, #vLayIds do
-- scorro tutti i gruppi di contorni
local nCrvGrpId = EgtGetFirstNameInGroup( vLayIds[ nIdx], CONTOUR_GRP.."*")
while nCrvGrpId do
-- recupero il gruppo dei percorsi utensile
local nTpathGrpId = EgtGetFirstNameInGroup( nCrvGrpId, TOOLPATH_GRP)
if not nTpathGrpId then
EgtOutBox( 'Error missing toolpaths', 'ToolPathCalc')
return
end
-- recupero le entità nel gruppo
local nEntId = EgtGetFirstInGroup( nTpathGrpId)
while nEntId do
table.insert( vEntId, nEntId)
nEntId = EgtGetNext( nEntId)
end
--passo al gruppo di contorni successivo
nCrvGrpId = EgtGetNextName( nCrvGrpId, CONTOUR_GRP.."*")
end
end
if #vEntId == 0 then
EgtOutBox( 'Error missing entities', 'ToolPathCalc')
return
end
-- Aggiungo la lavorazione
EgtSetCurrMachGroup()
EgtAddMachining( 'Extrusion 1', 'ExtrusionA')
EgtSetMachiningGeometry( vEntId)
EgtApplyMachining()
end
---------------------------------------------------------------------
return RunGcodeGenerate
+181
View File
@@ -0,0 +1,181 @@
-- RunMachiningParamCalc.lua by Egaltech s.r.l. 2022/04/05
-- Gestione visualizzazione per Stampa 3d
-- Tabella per definizione modulo
local RunMachiningParamCalc = {}
-- Intestazioni
require( 'EgtBase')
EgtOutLog( ' RunMachiningParamCalc started', 1)
-- Costanti generali
local AMD = require( 'AddManData')
local CSV = require( 'CSVManager')
function RunMachiningParamCalc.Exec()
nParamsGrp = EgtGetFirstNameInGroup( GDB_ID.ROOT, PARAMS_GRP) or GDB_ID.NULL
if nParamsGrp == GDB_ID.NULL then
EgtOutBox( 'Impossible calculating before applying a machining.', 'Error', 'ERROR')
return
end
local dMachiningFeed = EgtGetInfo( nParamsGrp, KEY_FEED, 'd')
local dSliceStep = EgtGetInfo( nParamsGrp, KEY_SLICE_STEP, 'd')
local dStrand = EgtGetInfo( nParamsGrp, KEY_STRAND, 'd')
local sMaterial = EgtGetInfo( nParamsGrp, KEY_MATERIAL)
local sMachiningPath = EgtGetStringFromIni( '3dPrinting', 'ParamFile', "", EgtGetIniFile())
local dCoeffX = tonumber( EgtGetStringFromIni( DEFAULT_SECTION, KEY_COEFF_X, 0, sMachiningPath))
local dCoeffY = tonumber( EgtGetStringFromIni( DEFAULT_SECTION, KEY_COEFF_Y, 0, sMachiningPath))
local sCalcBaseDir = EgtGetStringFromIni( '3dPrinting', 'BaseDir', 'C:\\ProgramData\\Egaltech\\EgtCam5\\3dPrinting', EgtGetIniFile())
local sCurrProjectPath = EgtGetCurrFilePath()
local _, sCurrProjectName = EgtSplitPath( sCurrProjectPath)
local sResultFile = sCalcBaseDir .. '\\Results\\' .. sCurrProjectName .. '.csv'
local bResultFile = EgtExistsFile( sResultFile)
-- calcolo intervallo tempi consentito
local sMaterialPath = sCalcBaseDir .. '\\Materials\\' .. sMaterial .. '.csv'
local MaterialCSV = read_file( sMaterialPath)
local dMinTime = 0
local dMaxTime = 0
if not MaterialCSV then
EgtOutBox( 'Material csv file not found.', 'Error', 'ERROR')
return
end
local bSectionFound = false
for nSectionIndex = 1, #MaterialCSV do
local Section = MaterialCSV[nSectionIndex]
if tonumber( Section[1]) == dStrand and tonumber( Section[2]) == dSliceStep then
dMinTime = tonumber(Section[3])
dMaxTime = tonumber(Section[4])
bSectionFound = true
break
end
end
if not bSectionFound then
EgtOutBox( 'Section not found in Material csv file.', 'Error', 'ERROR')
return
end
-- carico eventuale file dei risultati
local CSVOldResult
if bResultFile then
CSVOldResult = read_file( sResultFile)
end
-- tabella del csv del risultato
local CSVNewResult = {}
-- ciclo sui pezzi
local nPartIndex = 1
local nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
while nPartId do
-- ciclo sui layer
local nLayerIndex = 1
local nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
while nLayerId do
local sLayerName = EgtGetName( nLayerId)
local nLayerIndex = tonumber( sLayerName:sub( #SLICE_LAYER + 1))
-- calcolo lunghezza totale del layer
local dTotLayerLength = 0
local nCrvId = EgtGetFirstGroupInGroup( nLayerId)
while nCrvId do
local nToolPathId = EgtGetFirstNameInGroup( nCrvId, TOOLPATH_GRP)
-- sommo lunghezze percorsi
local dTotCrvLength = 0
nShellId = EgtGetFirstInGroup( nToolPathId)
while nShellId do
--local nType = EgtGetInfo( nShellId, KEY_TYPE, 'i')
dTotCrvLength = dTotCrvLength + EgtCurveLength( nShellId)
nShellId = EgtGetNext( nShellId)
end
dTotLayerLength = dTotLayerLength + dTotCrvLength
nCrvId = EgtGetNext( nCrvId)
end
-- recupero feed del layer
local dLayerFeed = 0
if bResultFile then
-- leggo il valore dal file
local bResultFound = false
for nResultIndex = 1, #CSVOldResult do
local OldResult = CSVOldResult[nResultIndex]
if tonumber( OldResult[1]) == nLayerIndex then
dLayerFeed = tonumber( OldResult[5])
bResultFound = true
break
end
end
if not bResultFound then
-- uso valore di default
dLayerFeed = dMachiningFeed
end
else
-- uso valore di default
dLayerFeed = dMachiningFeed
end
-- calcolo tempo stimato del layer
local dEsteemedTime = dTotLayerLength / dLayerFeed * 60
-- calcolo speed
local dSpeed = ((( dLayerFeed * dSliceStep * dStrand ) / 60) - dCoeffX) / dCoeffY
-- scrivo info feed e speed in group toolpath
nCrvId = EgtGetFirstGroupInGroup( nLayerId)
while nCrvId do
local nToolPathId = EgtGetFirstNameInGroup( nCrvId, TOOLPATH_GRP)
EgtSetInfo( nToolPathId, KEY_FEED, dLayerFeed)
EgtSetInfo( nToolPathId, KEY_SPEED, dSpeed)
nCrvId = EgtGetNext( nCrvId)
end
-- riporto valori calcolati in tabella per csv
local sStatus = ''
if dEsteemedTime < dMinTime then
sStatus = 'KO(-)'
elseif dEsteemedTime > dMinTime and dEsteemedTime < dMaxTime then
sStatus = 'OK'
elseif dEsteemedTime > dMaxTime then
sStatus = 'KO(+)'
end
--table.insert( CSVOutTable, { Index = nLayerIndex, EsteemedTime = dEsteemedTime, Feed = dLayerFeed, Speed = dSpeed})
table.insert( CSVNewResult, { nLayerIndex, dTotLayerLength, dEsteemedTime, sStatus, dLayerFeed, dSpeed})
nLayerIndex = nLayerIndex + 1
nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
end
nPartIndex = nPartIndex + 1
nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
end
-- scrivo nuovo file csv di risultato
local file = io.open( sResultFile, "w")
if file then
file:write('LayerIndex; Len; Time; Status; Feed; Speed')
file:write('\n')
for NewResultIndex = 1, #CSVNewResult do
local CSVOutLine = CSVNewResult[NewResultIndex]
local sParams = ''
for ParamIndex = 1, #CSVOutLine do
if ParamIndex > 1 then
sParams = sParams .. ";"
end
if ParamIndex == 4 then
sParams = sParams .. CSVOutLine[ParamIndex]
else
sParams = sParams .. EgtNumToString( CSVOutLine[ParamIndex], 1)
end
end
file:write(sParams)
file:write('\n')
end
file:close()
local sReadProgPath = EgtGetStringFromIni( '3dPrinting', RESULT_READ_PROG, "", EgtGetIniFile())
if not sReadProgPath or not EgtWinExec( sReadProgPath .. ' ' .. sResultFile) then
EgtOutBox( 'Impossible opening software to show results. You can find them in ' .. sResultFile, 'Error', 'ERROR')
end
else
EgtOutBox( 'Impossible writing results file in ' .. sResultFile, 'Error', 'ERROR')
end
end
---------------------------------------------------------------------
return RunMachiningParamCalc
+56
View File
@@ -0,0 +1,56 @@
-- RunMachiningParamEdit.lua by Egaltech s.r.l. 2022/04/05
-- Gestione visualizzazione per Stampa 3d
-- Tabella per definizione modulo
local RunMachiningParamEdit = {}
-- Intestazioni
require( 'EgtBase')
EgtOutLog( ' RunMachiningParamEdit started', 1)
-- Costanti generali
local AMD = require( 'AddManData')
function RunMachiningParamEdit.Exec()
-- recupero cartella delle lavorazioni
local sCalcBaseDir = EgtGetStringFromIni( '3dPrinting', 'BaseDir', 'C:\\ProgramData\\Egaltech\\EgtCam5\\3dPrinting', EgtGetIniFile())
local sMachiningDirPath = sCalcBaseDir .. '\\Machinings\\'
-- recupero file delle lavorazioni
--local Machinings = {}
local sMachinings = ''
local f = io.popen("dir " .. sMachiningDirPath .. " /B", "r")
for entry in f:lines() do
--Machinings[#Machinings + 1] = entry
local sDir, sFile, sExt = EgtSplitPath(entry)
if sExt == '.ini' then
if sMachinings ~= "" then
sMachinings = sMachinings .. ','
end
sMachinings = sMachinings .. sFile
end
end
-- chiedo quale file aprire
MachiningValues = EgtDialogBox( 'Machinings edit', { 'Machining', 'CB:' .. sMachinings})
if not MachiningValues or #MachiningValues < 1 then return end
-- verifico esistenza file
local sSelMachiningPath = sMachiningDirPath .. MachiningValues[1] .. '.ini'
if not EgtExistsFile( sSelMachiningPath) then
EgtOutBox( 'Machining file not found', 'Error', 'ERROR')
return
end
-- apro programma di edit
local sEditProgPath = EgtGetStringFromIni( '3dPrinting', 'MachiningEditProg', "", EgtGetIniFile())
if not sEditProgPath or not EgtWinExec( sEditProgPath .. ' ' .. sSelMachiningPath) then
EgtOutBox( 'Impossible opening software to show Machining. You can find it in ' .. sSelMachiningPath, 'Error', 'ERROR')
end
end
---------------------------------------------------------------------
return RunMachiningParamEdit
+55
View File
@@ -0,0 +1,55 @@
-- RunMaterialParamEdit.lua by Egaltech s.r.l. 2022/04/09
-- Gestione edit parametri materiali per Stampa 3d
-- Tabella per definizione modulo
local RunMaterialParamEdit = {}
-- Intestazioni
require( 'EgtBase')
EgtOutLog( ' RunMaterialParamEdit started', 1)
-- Costanti generali
local AMD = require( 'AddManData')
function RunMaterialParamEdit.Exec()
-- recupero cartella dei materiali
local sCalcBaseDir = EgtGetStringFromIni( '3dPrinting', 'BaseDir', 'C:\\ProgramData\\Egaltech\\EgtCam5\\3dPrinting', EgtGetIniFile())
local sMaterialDirPath = sCalcBaseDir .. '\\Materials\\'
-- recupero elenco file dei materiali
local Files = EgtFindAllFiles( sMaterialDirPath..'*.csv')
if not Files then
EgtOutBox( 'Material files not found', 'Error', 'ERROR')
return
end
local sMaterials = ''
for i = 1, #Files do
local sDir, sFile, sExt = EgtSplitPath( Files[i])
if sMaterials ~= "" then
sMaterials = sMaterials .. ','
end
sMaterials = sMaterials .. sFile
end
-- chiedo quale file aprire
MaterialValues = EgtDialogBox( 'Materials edit', { 'Material', 'CB:' .. sMaterials})
if not MaterialValues or #MaterialValues < 1 then return end
-- verifico esistenza file
local sSelMaterialPath = sMaterialDirPath .. MaterialValues[1] .. '.csv'
if not EgtExistsFile( sSelMaterialPath) then
EgtOutBox( 'Material file not found', 'Error', 'ERROR')
return
end
-- apro programma di edit
local sEditProgPath = EgtGetStringFromIni( '3dPrinting', RESULT_READ_PROG, "", EgtGetIniFile())
if not sEditProgPath or not EgtWinExec( sEditProgPath .. ' ' .. sSelMaterialPath) then
EgtOutBox( 'Impossible opening software to show Material. You can find them it in ' .. sSelMaterialPath, 'Error', 'ERROR')
end
end
---------------------------------------------------------------------
return RunMaterialParamEdit
@@ -1,17 +1,19 @@
-- CalcPartPositioning.lua by Egaltech s.r.l. 2022/04/11
-- RunPartPositioning.lua by Egaltech s.r.l. 2022/04/11
-- Gestione calcolo disposizione e lavorazioni per stampa 3d
-- 2022/03/21 Creazione file
-- Tabella per definizione modulo
local CalcPartPositioning = {}
local RunPartPositioning = {}
-- Intestazioni
require( 'EgtBase')
EgtOutLog( ' RunPartPositioning started', 1)
-- Costanti generali
local AMD = require( 'AddManData')
function CalcPartPositioning.Exec()
function RunPartPositioning.Exec()
-- Recupero ultimo oggetto selezionato
local nPartId = EgtGetParent(EgtGetParent( EgtGetLastSelectedObj()))
-- verifico sia un pezzo valido
@@ -104,4 +106,4 @@ function CalcPartPositioning.Exec()
end
---------------------------------------------------------------------
return CalcPartPositioning
return RunPartPositioning
+110
View File
@@ -0,0 +1,110 @@
-- RunShowManager.lua by Egaltech s.r.l. 2022/04/05
-- Gestione visualizzazione per Stampa 3d
-- Tabella per definizione modulo
local RunShowManager = {}
-- Intestazioni
require( 'EgtBase')
EgtOutLog( ' RunShowManager started', 1)
-- Costanti generali
local AMD = require( 'AddManData')
local function ShowImportedSolid( nPartId, bShow)
local nLayerId = EgtGetFirstNameInGroup( nPartId, ORIGINAL_SOLID)
local nItemId = EgtGetFirstInGroup( nLayerId)
while nItemId do
if EgtGetType( nItemId) == GDB_TY.SRF_MESH then
EgtSetStatus( nItemId, EgtIf( bShow, GDB_ST.ON, GDB_ST.OFF))
end
nItemId = EgtGetNext(nItemId)
end
end
function RunShowManager.Exec()
-- Verifico esistenza gruppo stato visualizzazione progetto
local nViewId = EgtGetFirstNameInGroup( GDB_ID.ROOT, VIEWPARAMS)
local bImportedSolid = false
local bOuterCrv = false
local bPath = false
local bSolid = true
local bToolPath = true
if not nViewId then
nViewId = EgtGroup( GDB_ID.ROOT)
EgtSetName( nViewId, VIEWPARAMS)
else
bImportedSolid = EgtGetInfo( nViewId, IMPORTED_SOLID, 'b')
bOuterCrv = EgtGetInfo( nViewId, OUTER_CRV, 'b')
bPath = EgtGetInfo( nViewId, PATH_GRP, 'b')
bSolid = EgtGetInfo( nViewId, SOLID_GRP, 'b')
bToolPath = EgtGetInfo( nViewId, TOOLPATH_GRP, 'b')
end
ViewValues = EgtDialogBox( 'Show Manager', { 'Imported Solid', 'CK:' .. EgtIf( bImportedSolid, '1', '0')},
{ 'OuterCrv', 'CK:' .. EgtIf( bOuterCrv, '1', '0')},
{ 'Path', 'CK:' .. EgtIf( bPath, '1', '0')},
{ 'Solid', 'CK:' .. EgtIf( bSolid, '1', '0')},
{ 'ToolPath', 'CK:' .. EgtIf( bToolPath, '1', '0')})
if not ViewValues or #ViewValues < 5 then return end
-- dis/attivo solidi originali
local bCurrImportedSolid = ( ViewValues[1] == '1')
local bCurrOuterCrv = ( ViewValues[2] == '1')
local bCurrPath = ( ViewValues[3] == '1')
local bCurrSolid = ( ViewValues[4] == '1')
local bCurrToolPath = ( ViewValues[5] == '1')
-- ciclo sui pezzi
local nPartIndex = 1
local nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
while nPartId do
if bImportedSolid ~= bCurrImportedSolid then
ShowImportedSolid( nPartId, bCurrImportedSolid)
end
-- ciclo sui layer per dis/attivare il resto
local nLayerIndex = 1
local nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
while nLayerId do
local nCrvId = EgtGetFirstGroupInGroup( nLayerId)
while nCrvId do
if bOuterCrv ~= bCurrOuterCrv then
local nOuterCrvId = EgtGetFirstNameInGroup( nCrvId, OUTER_CRV)
EgtSetStatus( nOuterCrvId, EgtIf( bCurrOuterCrv, GDB_ST.ON, GDB_ST.OFF))
end
if bPath ~= bCurrPath then
local nPathId = EgtGetFirstNameInGroup( nCrvId, PATH_GRP)
EgtSetStatus( nPathId, EgtIf( bCurrPath, GDB_ST.ON, GDB_ST.OFF))
end
if bSolid ~= bCurrSolid then
local nSolidId = EgtGetFirstNameInGroup( nCrvId, SOLID_GRP)
EgtSetStatus( nSolidId, EgtIf( bCurrSolid, GDB_ST.ON, GDB_ST.OFF))
end
if bToolPath ~= bCurrToolPath then
local nToolPathId = EgtGetFirstNameInGroup( nCrvId, TOOLPATH_GRP)
EgtSetStatus( nToolPathId, EgtIf( bCurrToolPath, GDB_ST.ON, GDB_ST.OFF))
end
nCrvId = EgtGetNext( nCrvId)
end
nLayerIndex = nLayerIndex + 1
nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
end
nPartIndex = nPartIndex + 1
nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
end
-- riporto impostazioni in gruppo apposito
EgtSetInfo( nViewId, IMPORTED_SOLID, bCurrImportedSolid)
EgtSetInfo( nViewId, OUTER_CRV, bCurrOuterCrv)
EgtSetInfo( nViewId, PATH_GRP, bCurrPath)
EgtSetInfo( nViewId, SOLID_GRP, bCurrSolid)
EgtSetInfo( nViewId, TOOLPATH_GRP, bCurrToolPath)
EgtDraw()
end
---------------------------------------------------------------------
return RunShowManager
+96
View File
@@ -0,0 +1,96 @@
-- RunSliceAdvancement.lua by Egaltech s.r.l. 2022/04/05
-- Gestione visualizzazione per Stampa 3d
-- Tabella per definizione modulo
local RunSliceAdvancement = {}
-- Intestazioni
require( 'EgtBase')
EgtOutLog( ' RunSliceAdvancement started', 1)
-- Costanti generali
local AMD = require( 'AddManData')
local function ManageSegmentVisibility( SegmentList, nLastActiveIndex, ToHideList)
for Index = 1, #SegmentList do
EgtSetStatus( SegmentList[Index], EgtIf( Index <= nLastActiveIndex, GDB_ST.ON, GDB_ST.OFF))
end
if ToHideList and #ToHideList > 0 then
for Index = 1, #ToHideList do
EgtSetStatus( ToHideList[Index], GDB_ST.OFF)
end
end
end
function RunSliceAdvancement.Exec()
ViewValues = EgtDialogBox( 'Slice advancement', { 'Type', 'CB:*All,Only Outer,Only Inner,Only Infill'},
{ 'Percentage (0-100)', '30'})
if not ViewValues or #ViewValues < 1 then return end
local nAdvancementType = 1 -- 1 = All, 2 = Only Outer, 3 = Only Inner, 4 = Only Infill
if ViewValues[1] == 'All' then
nAdvancementType = 1
elseif ViewValues[1] == 'Only Outer' then
nAdvancementType = 2
elseif ViewValues[1] == 'Only Inner' then
nAdvancementType = 3
elseif ViewValues[1] == 'Only Infill' then
nAdvancementType = 4
end
local nPercentage = tonumber( ViewValues[2])
-- ciclo sui pezzi
local nPartIndex = 1
local nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
while nPartId do
-- ciclo sui layer per dis/attivare il resto
local nLayerIndex = 1
local nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
while nLayerId do
local nCrvId = EgtGetFirstGroupInGroup( nLayerId)
while nCrvId do
local nSolidId = EgtGetFirstNameInGroup( nCrvId, SOLID_GRP)
local ShellList = { {}, {}}
local nSurfId = EgtGetFirstInGroup( nSolidId)
while nSurfId do
local nType = EgtGetInfo( nSurfId, KEY_TYPE, 'i')
table.insert( ShellList[nType + 1], nSurfId)
nSurfId = EgtGetNext( nSurfId)
end
local nSegmentQty = 1
local SegmentList
local ToHideList
if nAdvancementType == 1 then
nSegmentQty = #ShellList[1] + #ShellList[2]
SegmentList = ShellList[1]
for i = 1, #ShellList[2] do
SegmentList[#SegmentList + 1] = ShellList[2][i]
end
elseif nAdvancementType == 2 then
nSegmentQty = #ShellList[1]
SegmentList = ShellList[1]
ToHideList = ShellList[2]
elseif nAdvancementType == 3 then
nSegmentQty = #ShellList[2]
SegmentList = ShellList[2]
ToHideList = ShellList[1]
end
local nLastActiveIndex = ceil( nSegmentQty * nPercentage / 100)
ManageSegmentVisibility( SegmentList, nLastActiveIndex, ToHideList)
nCrvId = EgtGetNext( nCrvId)
end
nLayerIndex = nLayerIndex + 1
nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
end
nPartIndex = nPartIndex + 1
nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
end
EgtDraw()
end
---------------------------------------------------------------------
return RunSliceAdvancement
+141
View File
@@ -0,0 +1,141 @@
-- RunSlicing.lua by Egaltech s.r.l. 2022/03/30
-- Calcoli prima fase per Stampa 3d
-- Tabella per definizione modulo
local RunSlicing = {}
-- Intestazioni
require( 'EgtBase')
EgtOutLog( ' RunSlicing started', 1)
-- Costanti generali
_G.package.loaded.AddManData = nil
local AMD = require( 'AddManData')
-- Librerie
_G.package.loaded.CalcSlices = nil
local CSLICES = require( 'CalcSlices')
_G.package.loaded.CalcPaths = nil
local CPATHS = require( 'CalcPaths')
_G.package.loaded.CalcSolids = nil
local CSOLIDS = require( 'CalcSolids')
_G.package.loaded.CalcToolPath = nil
local CTP = require( 'CalcToolPath')
---------------------------------------------------------------------
local function SetParamInfo( sFile, nParamsGrp, sSection, sKey, sDefaultVal)
local sVal = EgtGetStringFromIni( sSection, sKey, sDefaultVal, sFile)
EgtSetInfo( nParamsGrp, sKey, sVal)
end
---------------------------------------------------------------------
local function LoadParams( sFile, nPartId)
-- creo gruppo dove salvare parametri
local nParamsGrp = EgtGetFirstNameInGroup( GDB_ID.ROOT, PARAMS_GRP) or GDB_ID.NULL
if nParamsGrp == GDB_ID.NULL then
nParamsGrp = EgtGroup( GDB_ID.ROOT)
EgtRelocate( nParamsGrp, GDB_ID.ROOT, GDB_IN.FIRST_SON)
EgtSetName( nParamsGrp, PARAMS_GRP)
EgtSetLevel( nParamsGrp, GDB_LV.SYSTEM)
end
EgtSetInfo( nParamsGrp, INFO_PARTD_ID, nPartId)
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_SLICE_STEP, '1.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_STRAND, '6.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_SHELLS_NBR, '3')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_OFFSET_SLICE, '0.0')
local sStartPoint = EgtGetStringFromIni( DEFAULT_SECTION, KEY_START_POINT, '0,0', sFile)
local ptStart = EgtGetVal( 'P='..sStartPoint..',0', 'P', 'p')
EgtSetInfo( nParamsGrp, KEY_START_POINT, ptStart)
local sStrandOrder = EgtGetStringFromIni( DEFAULT_SECTION, KEY_PRINT_ORDER, 'in', sFile)
if sStrandOrder == 'out' then
EgtSetInfo( nParamsGrp, KEY_PRINT_ORDER, PRINT_ORDER.EXT_INT_INF)
else -- sStrandOrder == 'in'
EgtSetInfo( nParamsGrp, KEY_PRINT_ORDER, PRINT_ORDER.INT_EXT_INF)
end
local sStrandDirection = EgtGetStringFromIni( DEFAULT_SECTION, KEY_PRINT_DIRECTION, 'CCW', sFile)
if sStrandDirection == 'CW' then
EgtSetInfo( nParamsGrp, KEY_PRINT_DIRECTION, PRINT_DIRECTION.CW)
else -- CCW
EgtSetInfo( nParamsGrp, KEY_PRINT_DIRECTION, PRINT_DIRECTION.CCW)
end
local sLinkType = EgtGetStringFromIni( DEFAULT_SECTION, KEY_LINK_TYPE, 'straight', sFile)
if sLinkType == 'sPath' then
EgtSetInfo( nParamsGrp, KEY_LINK_TYPE, LINK_TYPE.BIARC)
else -- sStrandOrder == 'sPath'
EgtSetInfo( nParamsGrp, KEY_LINK_TYPE, LINK_TYPE.LINEAR)
end
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_LINK_PARAM, '0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_FLOOR_NBR, '0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_SPEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_FEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_EXT_FEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_INT_FEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_INFILL_FEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_LEAD_IN_FEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_LEAD_OUT_FEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_SUPPORT_FEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_G0_FEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_MATERIAL, '')
end
function RunSlicing.Exec()
-- Recupero ultimo oggetto selezionato
local nStmId = EgtGetLastSelectedObj()
-- Verifico sia una superficie
if not nStmId or EgtGetType( nStmId) ~= GDB_TY.SRF_MESH then
EgtOutText( "L'oggetto selezionato non è una superficie")
EgtPause( 1000)
return
end
local nPartId = EgtGetParent( EgtGetParent( nStmId))
-- Scelta del file dei parametri
local sLastParamFile = EgtGetStringFromIni( '3dPrinting', 'ParamFile', 'C:\\ProgramData\\Egaltech\\EgtCam5\\3dPrinting\\Machinings\\aaa.ini', EgtGetIniFile())
local sDir = EgtSplitPath( sLastParamFile)
local sParamFile = EgtFileDialog( true, sDir..'*.ini', '*.ini||')
if not sParamFile then
EgtOutBox('Error no file', '')
return
end
EgtWriteStringToIni( '3dPrinting', 'ParamFile', sParamFile, EgtGetIniFile())
-- Elimino eventuale precedente file dei risultati
local sCalcBaseDir = EgtGetStringFromIni( '3dPrinting', 'BaseDir', 'C:\\ProgramData\\Egaltech\\EgtCam5\\3dPrinting', EgtGetIniFile())
local sCurrProjectPath = EgtGetCurrFilePath()
local _, sCurrProjectName = EgtSplitPath( sCurrProjectPath)
local sResultFile = sCalcBaseDir .. '\\Results\\' .. sCurrProjectName .. '.csv'
EgtEraseFile( sResultFile)
-- Lettura dei parametri
LoadParams( sParamFile, nPartId)
-- Calcolo delle fette
CSLICES.Exec( nPartId, nStmId)
EgtDraw()
-- Calcolo dei percorsi sul centro strand in basso
CPATHS.Exec( nPartId)
EgtDraw()
-- Calcolo dei percorsi di lavoro
CTP.Exec( nPartId)
EgtDraw()
-- Calcolo dei solidi degli strand a partire dai percorsi di lavoro
CSOLIDS.Exec( nPartId)
EgtSetStatus( nStmId, GDB_ST.OFF)
EgtDraw()
end
---------------------------------------------------------------------
return RunSlicing
+117
View File
@@ -0,0 +1,117 @@
-- RunViewManager.lua by Egaltech s.r.l. 2022/04/05
-- Gestione visualizzazione per Stampa 3d
-- Tabella per definizione modulo
local RunViewManager = {}
-- Intestazioni
require( 'EgtBase')
EgtOutLog( ' RunViewManager started', 1)
-- Costanti generali
local AMD = require( 'AddManData')
function RunViewManager.Exec()
ViewValues = EgtDialogBox( 'Slicing visibility manager', { 'Visibility Mode', 'CB:*All,Till Selected,Only Selected'},
{ 'Shell type', 'CB:*All,Outer,Inner,Infill'},
{ 'Inner Number', '1'})
if not ViewValues or #ViewValues < 2 then return end
local nVisibilityMode = 1 -- 1 = All, 2 = Till Selected, 3 = Only Selected
if ViewValues[1] == 'All' then
nVisibilityMode = 1
elseif ViewValues[1] == 'Till Selected' then
nVisibilityMode = 2
elseif ViewValues[1] == 'Only Selected' then
nVisibilityMode = 3
end
local nShellType = 0 -- 1 = All, 2 = Outer, 3 = Inner, 4 = infill
if ViewValues[2] == 'All' then
nShellType = 1
elseif ViewValues[2] == 'Outer' then
nShellType = 2
elseif ViewValues[2] == 'Inner' then
nShellType = 3
elseif ViewValues[2] == 'Infill' then
nShellType = 4
end
local nInnerNumber = tonumber(ViewValues[3])
-- Recupero ultimo layer selezionato
-- verifico sia un pezzo valido
local sSelLayerName = ''
local bFound = false
local nSelLayerId = EgtGetLastSelectedObj()
while nSelLayerId do
local sSelLayerName = EgtGetName( nSelLayerId)
if sSelLayerName and sSelLayerName:sub(1, 5) == SLICE_LAYER then
bFound = true
break
end
nSelLayerId = EgtGetParent( nSelLayerId)
end
if not bFound then
if nVisibilityMode ~= 1 then
EgtOutBox( 'No selected element!', 'Warning', 'WARNING')
return
else
nSelLayerId = GDB_ID.NULL
sSelLayerName = ''
end
end
-- ciclo sui pezzi
local nPartIndex = 1
local nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
while nPartId do
-- ciclo sui layer per dis/attivare il resto
local nLayerIndex = 1
local nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
while nLayerId do
if nVisibilityMode == 1 then -- All
EgtSetStatus( nLayerId, GDB_ST.ON)
elseif nVisibilityMode == 2 then -- Till Selected
EgtSetStatus( nLayerId, EgtIf( nLayerId <= nSelLayerId, GDB_ST.ON, GDB_ST.OFF))
elseif nVisibilityMode == 3 then -- Only Selected
EgtSetStatus( nLayerId, EgtIf( nLayerId == nSelLayerId, GDB_ST.ON, GDB_ST.OFF))
end
local nCrvId = EgtGetFirstGroupInGroup( nLayerId)
while nCrvId do
local nPathId = EgtGetFirstNameInGroup( nCrvId, PATH_GRP)
local nShellId = EgtGetFirstInGroup( nPathId)
while nShellId do
local nType = EgtGetInfo( nShellId, KEY_TYPE, 'i')
EgtSetStatus( nShellId, EgtIf( nShellType == 1 or ( nShellType == 2 and nType == 0) or (nShellType == 3 and nType == nInnerNumber), GDB_ST.ON, GDB_ST.OFF))
nShellId = EgtGetNext( nShellId)
end
local nSolidId = EgtGetFirstNameInGroup( nCrvId, SOLID_GRP)
local nSurfId = EgtGetFirstInGroup( nSolidId)
while nSurfId do
local nType = EgtGetInfo( nSurfId, KEY_TYPE, 'i')
EgtSetStatus( nSurfId, EgtIf( nShellType == 1 or ( nShellType == 2 and nType == 0) or (nShellType == 3 and nType == nInnerNumber), GDB_ST.ON, GDB_ST.OFF))
nSurfId = EgtGetNext( nSurfId)
end
local nToolPathId = EgtGetFirstNameInGroup( nCrvId, TOOLPATH_GRP)
nShellId = EgtGetFirstInGroup( nToolPathId)
while nShellId do
local nType = EgtGetInfo( nShellId, KEY_TYPE, 'i')
EgtSetStatus( nShellId, EgtIf( nType and ( nShellType == 1 or ( nShellType == 2 and nType == 0) or (nShellType == 3 and nType == nInnerNumber)), GDB_ST.ON, GDB_ST.OFF))
nShellId = EgtGetNext( nShellId)
end
nCrvId = EgtGetNext( nCrvId)
end
nLayerIndex = nLayerIndex + 1
nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
end
nPartIndex = nPartIndex + 1
nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
end
EgtDraw()
end
---------------------------------------------------------------------
return RunViewManager
+5 -164
View File
@@ -10,168 +10,9 @@ EgtEnableDebug( false)
local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- Costanti generali
local AMD = require( 'AddManData')
local CSV = require( 'CSVManager')
-- Librerie
_G.package.loaded.RunMachiningParamCalc = nil
local RMPC = require( 'RunMachiningParamCalc')
nParamsGrp = EgtGetFirstNameInGroup( GDB_ID.ROOT, PARAMS_GRP) or GDB_ID.NULL
if nParamsGrp == GDB_ID.NULL then
EgtOutBox( 'Impossible calculating before applying a machining.', 'Error', 'ERROR')
return
end
local dMachiningFeed = EgtGetInfo( nParamsGrp, KEY_FEED, 'd')
local dSliceStep = EgtGetInfo( nParamsGrp, KEY_SLICE_STEP, 'd')
local dStrand = EgtGetInfo( nParamsGrp, KEY_STRAND, 'd')
local sMaterial = EgtGetInfo( nParamsGrp, KEY_MATERIAL)
local sMachiningPath = EgtGetStringFromIni( '3dPrinting', 'ParamFile', "", EgtGetIniFile())
local dCoeffX = tonumber( EgtGetStringFromIni( DEFAULT_SECTION, KEY_COEFF_X, 0, sMachiningPath))
local dCoeffY = tonumber( EgtGetStringFromIni( DEFAULT_SECTION, KEY_COEFF_Y, 0, sMachiningPath))
local sCalcBaseDir = EgtGetStringFromIni( '3dPrinting', 'BaseDir', 'C:\\ProgramData\\Egaltech\\EgtCam5\\3dPrinting', EgtGetIniFile())
local sCurrProjectPath = EgtGetCurrFilePath()
local _, sCurrProjectName = EgtSplitPath( sCurrProjectPath)
local sResultFile = sCalcBaseDir .. '\\Results\\' .. sCurrProjectName .. '.csv'
local bResultFile = EgtExistsFile( sResultFile)
-- calcolo intervallo tempi consentito
local sMaterialPath = sCalcBaseDir .. '\\Materials\\' .. sMaterial .. '.csv'
local MaterialCSV = read_file( sMaterialPath)
local dMinTime = 0
local dMaxTime = 0
if not MaterialCSV then
EgtOutBox( 'Material csv file not found.', 'Error', 'ERROR')
return
end
local bSectionFound = false
for nSectionIndex = 1, #MaterialCSV do
local Section = MaterialCSV[nSectionIndex]
if tonumber( Section[1]) == dStrand and tonumber( Section[2]) == dSliceStep then
dMinTime = tonumber(Section[3])
dMaxTime = tonumber(Section[4])
bSectionFound = true
break
end
end
if not bSectionFound then
EgtOutBox( 'Section not found in Material csv file.', 'Error', 'ERROR')
return
end
-- carico eventuale file dei risultati
local CSVOldResult
if bResultFile then
CSVOldResult = read_file( sResultFile)
end
-- tabella del csv del risultato
local CSVNewResult = {}
-- ciclo sui pezzi
local nPartIndex = 1
local nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
while nPartId do
-- ciclo sui layer
local nLayerIndex = 1
local nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
while nLayerId do
local sLayerName = EgtGetName( nLayerId)
local nLayerIndex = tonumber( sLayerName:sub( #SLICE_LAYER + 1))
-- calcolo lunghezza totale del layer
local dTotLayerLength = 0
local nCrvId = EgtGetFirstGroupInGroup( nLayerId)
while nCrvId do
local nToolPathId = EgtGetFirstNameInGroup( nCrvId, TOOLPATH_GRP)
-- sommo lunghezze percorsi
local dTotCrvLength = 0
nShellId = EgtGetFirstInGroup( nToolPathId)
while nShellId do
--local nType = EgtGetInfo( nShellId, KEY_TYPE, 'i')
dTotCrvLength = dTotCrvLength + EgtCurveLength( nShellId)
nShellId = EgtGetNext( nShellId)
end
dTotLayerLength = dTotLayerLength + dTotCrvLength
nCrvId = EgtGetNext( nCrvId)
end
-- recupero feed del layer
local dLayerFeed = 0
if bResultFile then
-- leggo il valore dal file
local bResultFound = false
for nResultIndex = 1, #CSVOldResult do
local OldResult = CSVOldResult[nResultIndex]
if tonumber( OldResult[1]) == nLayerIndex then
dLayerFeed = tonumber( OldResult[5])
bResultFound = true
break
end
end
if not bResultFound then
-- uso valore di default
dLayerFeed = dMachiningFeed
end
else
-- uso valore di default
dLayerFeed = dMachiningFeed
end
-- calcolo tempo stimato del layer
local dEsteemedTime = dTotLayerLength / dLayerFeed * 60
-- calcolo speed
local dSpeed = ((( dLayerFeed * dSliceStep * dStrand ) / 60) - dCoeffX) / dCoeffY
-- scrivo info feed e speed in group toolpath
nCrvId = EgtGetFirstGroupInGroup( nLayerId)
while nCrvId do
local nToolPathId = EgtGetFirstNameInGroup( nCrvId, TOOLPATH_GRP)
EgtSetInfo( nToolPathId, KEY_FEED, dLayerFeed)
EgtSetInfo( nToolPathId, KEY_SPEED, dSpeed)
nCrvId = EgtGetNext( nCrvId)
end
-- riporto valori calcolati in tabella per csv
local sStatus = ''
if dEsteemedTime < dMinTime then
sStatus = 'KO(-)'
elseif dEsteemedTime > dMinTime and dEsteemedTime < dMaxTime then
sStatus = 'OK'
elseif dEsteemedTime > dMaxTime then
sStatus = 'KO(+)'
end
--table.insert( CSVOutTable, { Index = nLayerIndex, EsteemedTime = dEsteemedTime, Feed = dLayerFeed, Speed = dSpeed})
table.insert( CSVNewResult, { nLayerIndex, dTotLayerLength, dEsteemedTime, sStatus, dLayerFeed, dSpeed})
nLayerIndex = nLayerIndex + 1
nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
end
nPartIndex = nPartIndex + 1
nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
end
-- scrivo nuovo file csv di risultato
local file = io.open( sResultFile, "w")
if file then
file:write('LayerIndex; Len; Time; Status; Feed; Speed')
file:write('\n')
for NewResultIndex = 1, #CSVNewResult do
local CSVOutLine = CSVNewResult[NewResultIndex]
local sParams = ''
for ParamIndex = 1, #CSVOutLine do
if ParamIndex > 1 then
sParams = sParams .. ";"
end
if ParamIndex == 4 then
sParams = sParams .. CSVOutLine[ParamIndex]
else
sParams = sParams .. EgtNumToString( CSVOutLine[ParamIndex], 1)
end
end
file:write(sParams)
file:write('\n')
end
file:close()
local sReadProgPath = EgtGetStringFromIni( '3dPrinting', RESULT_READ_PROG, "", EgtGetIniFile())
if not sReadProgPath or not EgtWinExec( sReadProgPath .. ' ' .. sResultFile) then
EgtOutBox( 'Impossible opening software to show results. You can find them in ' .. sResultFile, 'Error', 'ERROR')
end
else
EgtOutBox( 'Impossible writing results file in ' .. sResultFile, 'Error', 'ERROR')
end
------------------------- MAIN --------------------------------------
-- Calcolo
RMPC.Exec()
+5 -40
View File
@@ -10,44 +10,9 @@ EgtEnableDebug( false)
local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- Costanti generali
local AMD = require( 'AddManData')
-- Librerie
_G.package.loaded.RunMachiningParamEdit = nil
local RMPE = require( 'RunMachiningParamEdit')
-- recupero cartella delle lavorazioni
local sCalcBaseDir = EgtGetStringFromIni( '3dPrinting', 'BaseDir', 'C:\\ProgramData\\Egaltech\\EgtCam5\\3dPrinting', EgtGetIniFile())
local sMachiningDirPath = sCalcBaseDir .. '\\Machinings\\'
-- recupero file delle lavorazioni
--local Machinings = {}
local sMachinings = ''
local f = io.popen("dir " .. sMachiningDirPath .. " /B", "r")
for entry in f:lines() do
--Machinings[#Machinings + 1] = entry
local sDir, sFile, sExt = EgtSplitPath(entry)
if sExt == '.ini' then
if sMachinings ~= "" then
sMachinings = sMachinings .. ','
end
sMachinings = sMachinings .. sFile
end
end
-- chiedo quale file aprire
MachiningValues = EgtDialogBox( 'Machinings edit', { 'Machining', 'CB:' .. sMachinings})
if not MachiningValues or #MachiningValues < 1 then return end
-- verifico esistenza file
local sSelMachiningPath = sMachiningDirPath .. MachiningValues[1] .. '.ini'
if not EgtExistsFile( sSelMachiningPath) then
EgtOutBox( 'Machining file not found', 'Error', 'ERROR')
return
end
-- apro programma di edit
local sEditProgPath = EgtGetStringFromIni( '3dPrinting', 'MachiningEditProg', "", EgtGetIniFile())
if not sEditProgPath or not EgtWinExec( sEditProgPath .. ' ' .. sSelMachiningPath) then
EgtOutBox( 'Impossible opening software to show Machining. You can find it in ' .. sSelMachiningPath, 'Error', 'ERROR')
end
------------------------- MAIN --------------------------------------
-- Calcolo
RMPE.Exec()
+5 -39
View File
@@ -10,43 +10,9 @@ EgtEnableDebug( false)
local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- Costanti generali
local AMD = require( 'AddManData')
-- Librerie
_G.package.loaded.RunMaterialParamEdit = nil
local RMPE = require( 'RunMaterialParamEdit')
-- recupero cartella dei materiali
local sCalcBaseDir = EgtGetStringFromIni( '3dPrinting', 'BaseDir', 'C:\\ProgramData\\Egaltech\\EgtCam5\\3dPrinting', EgtGetIniFile())
local sMaterialDirPath = sCalcBaseDir .. '\\Materials\\'
-- recupero elenco file dei materiali
local Files = EgtFindAllFiles( sMaterialDirPath..'*.csv')
if not Files then
EgtOutBox( 'Material files not found', 'Error', 'ERROR')
return
end
local sMaterials = ''
for i = 1, #Files do
local sDir, sFile, sExt = EgtSplitPath( Files[i])
if sMaterials ~= "" then
sMaterials = sMaterials .. ','
end
sMaterials = sMaterials .. sFile
end
-- chiedo quale file aprire
MaterialValues = EgtDialogBox( 'Materials edit', { 'Material', 'CB:' .. sMaterials})
if not MaterialValues or #MaterialValues < 1 then return end
-- verifico esistenza file
local sSelMaterialPath = sMaterialDirPath .. MaterialValues[1] .. '.csv'
if not EgtExistsFile( sSelMaterialPath) then
EgtOutBox( 'Material file not found', 'Error', 'ERROR')
return
end
-- apro programma di edit
local sEditProgPath = EgtGetStringFromIni( '3dPrinting', RESULT_READ_PROG, "", EgtGetIniFile())
if not sEditProgPath or not EgtWinExec( sEditProgPath .. ' ' .. sSelMaterialPath) then
EgtOutBox( 'Impossible opening software to show Material. You can find them it in ' .. sSelMaterialPath, 'Error', 'ERROR')
end
------------------------- MAIN --------------------------------------
-- Calcolo
RMPE.Exec()
+3 -3
View File
@@ -13,8 +13,8 @@ local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- Librerie
_G.package.loaded.CalcPartPositioning = nil
local CPP = require( 'CalcPartPositioning')
_G.package.loaded.RunPartPositioning = nil
local RPP = require( 'RunPartPositioning')
-- Calcolo
CPP.Exec()
RPP.Exec()
+5 -94
View File
@@ -10,98 +10,9 @@ EgtEnableDebug( false)
local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- Costanti generali
local AMD = require( 'AddManData')
-- Librerie
_G.package.loaded.RunShowManager = nil
local RSM = require( 'RunShowManager')
local function ShowImportedSolid( nPartId, bShow)
local nLayerId = EgtGetFirstNameInGroup( nPartId, ORIGINAL_SOLID)
local nItemId = EgtGetFirstInGroup( nLayerId)
while nItemId do
if EgtGetType( nItemId) == GDB_TY.SRF_MESH then
EgtSetStatus( nItemId, EgtIf( bShow, GDB_ST.ON, GDB_ST.OFF))
end
nItemId = EgtGetNext(nItemId)
end
end
-- Verifico esistenza gruppo stato visualizzazione progetto
local nViewId = EgtGetFirstNameInGroup( GDB_ID.ROOT, VIEWPARAMS)
local bImportedSolid = false
local bOuterCrv = false
local bPath = false
local bSolid = true
local bToolPath = true
if not nViewId then
nViewId = EgtGroup( GDB_ID.ROOT)
EgtSetName( nViewId, VIEWPARAMS)
else
bImportedSolid = EgtGetInfo( nViewId, IMPORTED_SOLID, 'b')
bOuterCrv = EgtGetInfo( nViewId, OUTER_CRV, 'b')
bPath = EgtGetInfo( nViewId, PATH_GRP, 'b')
bSolid = EgtGetInfo( nViewId, SOLID_GRP, 'b')
bToolPath = EgtGetInfo( nViewId, TOOLPATH_GRP, 'b')
end
ViewValues = EgtDialogBox( 'Show Manager', { 'Imported Solid', 'CK:' .. EgtIf( bImportedSolid, '1', '0')},
{ 'OuterCrv', 'CK:' .. EgtIf( bOuterCrv, '1', '0')},
{ 'Path', 'CK:' .. EgtIf( bPath, '1', '0')},
{ 'Solid', 'CK:' .. EgtIf( bSolid, '1', '0')},
{ 'ToolPath', 'CK:' .. EgtIf( bToolPath, '1', '0')})
if not ViewValues or #ViewValues < 5 then return end
-- dis/attivo solidi originali
local bCurrImportedSolid = ( ViewValues[1] == '1')
local bCurrOuterCrv = ( ViewValues[2] == '1')
local bCurrPath = ( ViewValues[3] == '1')
local bCurrSolid = ( ViewValues[4] == '1')
local bCurrToolPath = ( ViewValues[5] == '1')
-- ciclo sui pezzi
local nPartIndex = 1
local nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
while nPartId do
if bImportedSolid ~= bCurrImportedSolid then
ShowImportedSolid( nPartId, bCurrImportedSolid)
end
-- ciclo sui layer per dis/attivare il resto
local nLayerIndex = 1
local nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
while nLayerId do
local nCrvId = EgtGetFirstGroupInGroup( nLayerId)
while nCrvId do
if bOuterCrv ~= bCurrOuterCrv then
local nOuterCrvId = EgtGetFirstNameInGroup( nCrvId, OUTER_CRV)
EgtSetStatus( nOuterCrvId, EgtIf( bCurrOuterCrv, GDB_ST.ON, GDB_ST.OFF))
end
if bPath ~= bCurrPath then
local nPathId = EgtGetFirstNameInGroup( nCrvId, PATH_GRP)
EgtSetStatus( nPathId, EgtIf( bCurrPath, GDB_ST.ON, GDB_ST.OFF))
end
if bSolid ~= bCurrSolid then
local nSolidId = EgtGetFirstNameInGroup( nCrvId, SOLID_GRP)
EgtSetStatus( nSolidId, EgtIf( bCurrSolid, GDB_ST.ON, GDB_ST.OFF))
end
if bToolPath ~= bCurrToolPath then
local nToolPathId = EgtGetFirstNameInGroup( nCrvId, TOOLPATH_GRP)
EgtSetStatus( nToolPathId, EgtIf( bCurrToolPath, GDB_ST.ON, GDB_ST.OFF))
end
nCrvId = EgtGetNext( nCrvId)
end
nLayerIndex = nLayerIndex + 1
nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
end
nPartIndex = nPartIndex + 1
nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
end
-- riporto impostazioni in gruppo apposito
EgtSetInfo( nViewId, IMPORTED_SOLID, bCurrImportedSolid)
EgtSetInfo( nViewId, OUTER_CRV, bCurrOuterCrv)
EgtSetInfo( nViewId, PATH_GRP, bCurrPath)
EgtSetInfo( nViewId, SOLID_GRP, bCurrSolid)
EgtSetInfo( nViewId, TOOLPATH_GRP, bCurrToolPath)
EgtDraw()
------------------------- MAIN --------------------------------------
-- Calcolo
RSM.Exec()
+5 -80
View File
@@ -10,84 +10,9 @@ EgtEnableDebug( false)
local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- Costanti generali
local AMD = require( 'AddManData')
-- Librerie
_G.package.loaded.RunSliceAdvancement = nil
local RSA = require( 'RunSliceAdvancement')
ViewValues = EgtDialogBox( 'Slice advancement', { 'Type', 'CB:*All,Only Outer,Only Inner,Only Infill'},
{ 'Percentage (0-100)', '30'})
if not ViewValues or #ViewValues < 1 then return end
local nAdvancementType = 1 -- 1 = All, 2 = Only Outer, 3 = Only Inner, 4 = Only Infill
if ViewValues[1] == 'All' then
nAdvancementType = 1
elseif ViewValues[1] == 'Only Outer' then
nAdvancementType = 2
elseif ViewValues[1] == 'Only Inner' then
nAdvancementType = 3
elseif ViewValues[1] == 'Only Infill' then
nAdvancementType = 4
end
local nPercentage = tonumber( ViewValues[2])
local function ManageSegmentVisibility( SegmentList, nLastActiveIndex, ToHideList)
for Index = 1, #SegmentList do
EgtSetStatus( SegmentList[Index], EgtIf( Index <= nLastActiveIndex, GDB_ST.ON, GDB_ST.OFF))
end
if ToHideList and #ToHideList > 0 then
for Index = 1, #ToHideList do
EgtSetStatus( ToHideList[Index], GDB_ST.OFF)
end
end
end
-- ciclo sui pezzi
local nPartIndex = 1
local nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
while nPartId do
-- ciclo sui layer per dis/attivare il resto
local nLayerIndex = 1
local nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
while nLayerId do
local nCrvId = EgtGetFirstGroupInGroup( nLayerId)
while nCrvId do
local nSolidId = EgtGetFirstNameInGroup( nCrvId, SOLID_GRP)
local ShellList = { {}, {}}
local nSurfId = EgtGetFirstInGroup( nSolidId)
while nSurfId do
local nType = EgtGetInfo( nSurfId, KEY_TYPE, 'i')
table.insert( ShellList[nType + 1], nSurfId)
nSurfId = EgtGetNext( nSurfId)
end
local nSegmentQty = 1
local SegmentList
local ToHideList
if nAdvancementType == 1 then
nSegmentQty = #ShellList[1] + #ShellList[2]
SegmentList = ShellList[1]
for i = 1, #ShellList[2] do
SegmentList[#SegmentList + 1] = ShellList[2][i]
end
elseif nAdvancementType == 2 then
nSegmentQty = #ShellList[1]
SegmentList = ShellList[1]
ToHideList = ShellList[2]
elseif nAdvancementType == 3 then
nSegmentQty = #ShellList[2]
SegmentList = ShellList[2]
ToHideList = ShellList[1]
end
local nLastActiveIndex = ceil( nSegmentQty * nPercentage / 100)
ManageSegmentVisibility( SegmentList, nLastActiveIndex, ToHideList)
nCrvId = EgtGetNext( nCrvId)
end
nLayerIndex = nLayerIndex + 1
nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
end
nPartIndex = nPartIndex + 1
nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
end
EgtDraw()
------------------------- MAIN --------------------------------------
-- Calcolo
RSA.Exec()
+4 -122
View File
@@ -10,127 +10,9 @@ EgtEnableDebug( false)
local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- Costanti generali
_G.package.loaded.AddManData = nil
local AMD = require( 'AddManData')
-- Librerie
_G.package.loaded.CalcSlices = nil
local CSLICES = require( 'CalcSlices')
_G.package.loaded.CalcPaths = nil
local CPATHS = require( 'CalcPaths')
_G.package.loaded.CalcSolids = nil
local CSOLIDS = require( 'CalcSolids')
_G.package.loaded.CalcToolPath = nil
local CTP = require( 'CalcToolPath')
_G.package.loaded.RunSlicing = nil
local RS = require( 'RunSlicing')
---------------------------------------------------------------------
local function SetParamInfo( sFile, nParamsGrp, sSection, sKey, sDefaultVal)
local sVal = EgtGetStringFromIni( sSection, sKey, sDefaultVal, sFile)
EgtSetInfo( nParamsGrp, sKey, sVal)
end
---------------------------------------------------------------------
local function LoadParams( sFile, nPartId)
-- creo gruppo dove salvare parametri
local nParamsGrp = EgtGetFirstNameInGroup( GDB_ID.ROOT, PARAMS_GRP) or GDB_ID.NULL
if nParamsGrp == GDB_ID.NULL then
nParamsGrp = EgtGroup( GDB_ID.ROOT)
EgtRelocate( nParamsGrp, GDB_ID.ROOT, GDB_IN.FIRST_SON)
EgtSetName( nParamsGrp, PARAMS_GRP)
EgtSetLevel( nParamsGrp, GDB_LV.SYSTEM)
end
EgtSetInfo( nParamsGrp, INFO_PARTD_ID, nPartId)
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_SLICE_STEP, '1.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_STRAND, '6.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_SHELLS_NBR, '3')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_OFFSET_SLICE, '0.0')
local sStartPoint = EgtGetStringFromIni( DEFAULT_SECTION, KEY_START_POINT, '0,0', sFile)
local ptStart = EgtGetVal( 'P='..sStartPoint..',0', 'P', 'p')
EgtSetInfo( nParamsGrp, KEY_START_POINT, ptStart)
local sStrandOrder = EgtGetStringFromIni( DEFAULT_SECTION, KEY_PRINT_ORDER, 'in', sFile)
if sStrandOrder == 'out' then
EgtSetInfo( nParamsGrp, KEY_PRINT_ORDER, PRINT_ORDER.EXT_INT_INF)
else -- sStrandOrder == 'in'
EgtSetInfo( nParamsGrp, KEY_PRINT_ORDER, PRINT_ORDER.INT_EXT_INF)
end
local sStrandDirection = EgtGetStringFromIni( DEFAULT_SECTION, KEY_PRINT_DIRECTION, 'CCW', sFile)
if sStrandDirection == 'CW' then
EgtSetInfo( nParamsGrp, KEY_PRINT_DIRECTION, PRINT_DIRECTION.CW)
else -- CCW
EgtSetInfo( nParamsGrp, KEY_PRINT_DIRECTION, PRINT_DIRECTION.CCW)
end
local sLinkType = EgtGetStringFromIni( DEFAULT_SECTION, KEY_LINK_TYPE, 'straight', sFile)
if sLinkType == 'sPath' then
EgtSetInfo( nParamsGrp, KEY_LINK_TYPE, LINK_TYPE.BIARC)
else -- sStrandOrder == 'sPath'
EgtSetInfo( nParamsGrp, KEY_LINK_TYPE, LINK_TYPE.LINEAR)
end
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_LINK_PARAM, '0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_FLOOR_NBR, '0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_SPEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_FEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_EXT_FEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_INT_FEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_INFILL_FEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_LEAD_IN_FEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_LEAD_OUT_FEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_SUPPORT_FEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_G0_FEED, '0.0')
SetParamInfo( sFile, nParamsGrp, DEFAULT_SECTION, KEY_MATERIAL, '')
end
------------------------- MAIN --------------------------------------
-- Recupero ultimo oggetto selezionato
local nStmId = EgtGetLastSelectedObj()
-- Verifico sia una superficie
if not nStmId or EgtGetType( nStmId) ~= GDB_TY.SRF_MESH then
EgtOutText( "L'oggetto selezionato non è una superficie")
EgtPause( 1000)
return
end
local nPartId = EgtGetParent( EgtGetParent( nStmId))
-- Scelta del file dei parametri
local sLastParamFile = EgtGetStringFromIni( '3dPrinting', 'ParamFile', 'C:\\ProgramData\\Egaltech\\EgtCam5\\3dPrinting\\Machinings\\aaa.ini', EgtGetIniFile())
local sDir = EgtSplitPath( sLastParamFile)
local sParamFile = EgtFileDialog( true, sDir..'*.ini', '*.ini||')
if not sParamFile then
EgtOutBox('Error no file', '')
return
end
EgtWriteStringToIni( '3dPrinting', 'ParamFile', sParamFile, EgtGetIniFile())
-- Elimino eventuale precedente file dei risultati
local sCalcBaseDir = EgtGetStringFromIni( '3dPrinting', 'BaseDir', 'C:\\ProgramData\\Egaltech\\EgtCam5\\3dPrinting', EgtGetIniFile())
local sCurrProjectPath = EgtGetCurrFilePath()
local _, sCurrProjectName = EgtSplitPath( sCurrProjectPath)
local sResultFile = sCalcBaseDir .. '\\Results\\' .. sCurrProjectName .. '.csv'
EgtEraseFile( sResultFile)
-- Lettura dei parametri
LoadParams( sParamFile, nPartId)
-- Calcolo delle fette
CSLICES.Exec( nPartId, nStmId)
EgtDraw()
-- Calcolo dei percorsi sul centro strand in basso
CPATHS.Exec( nPartId)
EgtDraw()
-- Calcolo dei percorsi di lavoro
CTP.Exec( nPartId)
EgtDraw()
-- Calcolo dei solidi degli strand a partire dai percorsi di lavoro
CSOLIDS.Exec( nPartId)
EgtSetStatus( nStmId, GDB_ST.OFF)
EgtDraw()
-- Calcolo
RS.Exec()
+5 -101
View File
@@ -10,105 +10,9 @@ EgtEnableDebug( false)
local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- Costanti generali
local AMD = require( 'AddManData')
-- Librerie
_G.package.loaded.RunViewManager = nil
local RVM = require( 'RunViewManager')
ViewValues = EgtDialogBox( 'Slicing visibility manager', { 'Visibility Mode', 'CB:*All,Till Selected,Only Selected'},
{ 'Shell type', 'CB:*All,Outer,Inner,Infill'},
{ 'Inner Number', '1'})
if not ViewValues or #ViewValues < 2 then return end
local nVisibilityMode = 1 -- 1 = All, 2 = Till Selected, 3 = Only Selected
if ViewValues[1] == 'All' then
nVisibilityMode = 1
elseif ViewValues[1] == 'Till Selected' then
nVisibilityMode = 2
elseif ViewValues[1] == 'Only Selected' then
nVisibilityMode = 3
end
local nShellType = 0 -- 1 = All, 2 = Outer, 3 = Inner, 4 = infill
if ViewValues[2] == 'All' then
nShellType = 1
elseif ViewValues[2] == 'Outer' then
nShellType = 2
elseif ViewValues[2] == 'Inner' then
nShellType = 3
elseif ViewValues[2] == 'Infill' then
nShellType = 4
end
local nInnerNumber = tonumber(ViewValues[3])
-- Recupero ultimo layer selezionato
-- verifico sia un pezzo valido
local sSelLayerName = ''
local bFound = false
local nSelLayerId = EgtGetLastSelectedObj()
while nSelLayerId do
local sSelLayerName = EgtGetName( nSelLayerId)
if sSelLayerName and sSelLayerName:sub(1, 5) == SLICE_LAYER then
bFound = true
break
end
nSelLayerId = EgtGetParent( nSelLayerId)
end
if not bFound then
if nVisibilityMode ~= 1 then
EgtOutBox( 'No selected element!', 'Warning', 'WARNING')
return
else
nSelLayerId = GDB_ID.NULL
sSelLayerName = ''
end
end
-- ciclo sui pezzi
local nPartIndex = 1
local nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
while nPartId do
-- ciclo sui layer per dis/attivare il resto
local nLayerIndex = 1
local nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
while nLayerId do
if nVisibilityMode == 1 then -- All
EgtSetStatus( nLayerId, GDB_ST.ON)
elseif nVisibilityMode == 2 then -- Till Selected
EgtSetStatus( nLayerId, EgtIf( nLayerId <= nSelLayerId, GDB_ST.ON, GDB_ST.OFF))
elseif nVisibilityMode == 3 then -- Only Selected
EgtSetStatus( nLayerId, EgtIf( nLayerId == nSelLayerId, GDB_ST.ON, GDB_ST.OFF))
end
local nCrvId = EgtGetFirstGroupInGroup( nLayerId)
while nCrvId do
local nPathId = EgtGetFirstNameInGroup( nCrvId, PATH_GRP)
local nShellId = EgtGetFirstInGroup( nPathId)
while nShellId do
local nType = EgtGetInfo( nShellId, KEY_TYPE, 'i')
EgtSetStatus( nShellId, EgtIf( nShellType == 1 or ( nShellType == 2 and nType == 0) or (nShellType == 3 and nType == nInnerNumber), GDB_ST.ON, GDB_ST.OFF))
nShellId = EgtGetNext( nShellId)
end
local nSolidId = EgtGetFirstNameInGroup( nCrvId, SOLID_GRP)
local nSurfId = EgtGetFirstInGroup( nSolidId)
while nSurfId do
local nType = EgtGetInfo( nSurfId, KEY_TYPE, 'i')
EgtSetStatus( nSurfId, EgtIf( nShellType == 1 or ( nShellType == 2 and nType == 0) or (nShellType == 3 and nType == nInnerNumber), GDB_ST.ON, GDB_ST.OFF))
nSurfId = EgtGetNext( nSurfId)
end
local nToolPathId = EgtGetFirstNameInGroup( nCrvId, TOOLPATH_GRP)
nShellId = EgtGetFirstInGroup( nToolPathId)
while nShellId do
local nType = EgtGetInfo( nShellId, KEY_TYPE, 'i')
EgtSetStatus( nShellId, EgtIf( nType and ( nShellType == 1 or ( nShellType == 2 and nType == 0) or (nShellType == 3 and nType == nInnerNumber)), GDB_ST.ON, GDB_ST.OFF))
nShellId = EgtGetNext( nShellId)
end
nCrvId = EgtGetNext( nCrvId)
end
nLayerIndex = nLayerIndex + 1
nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
end
nPartIndex = nPartIndex + 1
nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
end
EgtDraw()
------------------------- MAIN --------------------------------------
-- Calcolo
RVM.Exec()