Merge branch 'release/AddGitlabCiCd'

This commit is contained in:
Samuele Locatelli
2022-04-12 11:03:26 +02:00
38 changed files with 1974 additions and 88 deletions
+18
View File
@@ -0,0 +1,18 @@
# /
/revision.h
/*.aps
/*.ncb
/*.suo
/*.user
/*.sdf
/*.opensdf
/Debug32
/Release32
/Trial32
/Debug64
/Release64
/ipch
/bin
/obj
/.vs
+101
View File
@@ -0,0 +1,101 @@
variables:
VERS_MAIN: '1.0'
APP_NAME: '3dPrinting'
NEW_REL: ''
NET_SHARE_R: '\\10.74.82.50\EgtTech'
NET_USER: '10.74.82.50\Server'
NET_SHARE_Z: '\\10.74.82.201\Artifacts'
#Note compilazione LUA:
# lua53 -o 32\$FileName -s $FileName: -o = output, -s = NON include i debug symbols
# helper compilazione LUA a 32 bit
.LuaCompile32: &LuaCompile32
- |
Set-Alias lua53 C:\Tools\Lua32\luac53
echo "Copia file *.ini"
$FileList = Get-ChildItem("*.ini")
ForEach ($File in $FileList) {
$FileName = Split-Path $File -leaf
Copy-Item -Path $FileName -Destination 32\$FileName
echo "Copy-Item -Path $FileName -Destination 32\$FileName"
}
echo "Copia file *.lua"
$FileList = Get-ChildItem("*.lua")
ForEach ($File in $FileList) {
$FileName = Split-Path $File -leaf
Copy-Item -Path $FileName -Destination 32\$FileName
echo "Copy-Item -Path $FileName -Destination 32\$FileName"
}
$FileList = Get-ChildItem("LuaLibs\*.lua")
ForEach ($File in $FileList) {
$FileName = Split-Path $File -leaf
lua53 -o 32\LuaLibs\$FileName LuaLibs\$FileName
echo "lua53 -o 32\LuaLibs\$FileName LuaLibs\$FileName"
}
# helper compilazione LUA a 64 bit
.LuaCompile64: &LuaCompile64
- |
Set-Alias lua53 C:\Tools\Lua64\luac53
echo "Copia file *.ini"
$FileList = Get-ChildItem("*.ini")
ForEach ($File in $FileList) {
$FileName = Split-Path $File -leaf
Copy-Item -Path $FileName -Destination 64\$FileName
echo "Copy-Item -Path $FileName -Destination 64\$FileName"
}
echo "Copia file *.lua"
$FileList = Get-ChildItem("*.lua")
ForEach ($File in $FileList) {
$FileName = Split-Path $File -leaf
Copy-Item -Path $FileName -Destination 64\$FileName
echo "Copy-Item -Path $FileName -Destination 64\$FileName"
}
$FileList = Get-ChildItem("LuaLibs\*.lua")
ForEach ($File in $FileList) {
$FileName = Split-Path $File -leaf
lua53 -o 64\LuaLibs\$FileName LuaLibs\$FileName
echo "lua53 -o 64\LuaLibs\$FileName LuaLibs\$FileName"
}
# helper copia script verso cartella di rete R:\ delle cartelle 32 e 64
.ReplicaR: &ReplicaR
- |
net use R: /delete
net use R: $env:NET_SHARE_R /u:$env:NET_USER $RDRIVE_PASSWD
ROBOCOPY /MIR 32 R:\EgtData\$env:APP_NAME\32
ROBOCOPY /MIR 64 R:\EgtData\$env:APP_NAME\64
ROBOCOPY /MIR Images R:\EgtData\$env:APP_NAME\32\Images
ROBOCOPY /MIR Images R:\EgtData\$env:APP_NAME\64\Images
SLEEP 2
net use R: /delete
# helper copia script verso cartella di rete R:\ delle cartelle 32 e 64
.ReplicaZ: &ReplicaZ
- |
net use Z: /delete
net use Z: $env:NET_SHARE_Z
ROBOCOPY /MIR 32 Z:\EgtData\$env:APP_NAME\32
ROBOCOPY /MIR 64 Z:\EgtData\$env:APP_NAME\64
ROBOCOPY /MIR Images Z:\EgtData\$env:APP_NAME\32\Images
ROBOCOPY /MIR Images Z:\EgtData\$env:APP_NAME\64\Images
SLEEP 2
net use Z: /delete
stages:
- build
LuaCompile:build:
stage: build
only:
- main
- master
tags:
- win
script:
- *LuaCompile32
- *LuaCompile64
- *ReplicaR
- *ReplicaZ
View File
View File
+15
View File
@@ -0,0 +1,15 @@
[3dPrinting]
Enable=1
BaseDir=C:\EgtData\3dPrinting
Button1=PartPositioning.lua,Images\PartPositioning.png,Disponi pezzo sulla tavola macchina
Button2=Slicing.lua,Images\Slicing.png,Calcola lo slicing, i solidi e i percorsi utensile
Button3=MachiningParamCalc.lua,Images\MachiningParamCalc.png,Calcola parametri di lavorazione (Tempo layer, F, S)
Button4=GcodeGenerate.lua,Images\GcodeGenerate.png,Genera codice CN
Button5=ShowManager.lua,Images\ShowManager.png,Gestore visualizzazione
Button6=ViewManager.lua,Images\ViewManager.png,Nascondi Visualizza strato
Button7=SliceAdvancement.lua,Images\SliceAdvancement.png,Mostra avanzamento strato
Button8=MachiningParamEdit.lua,Images\MachiningParamEdit.png,Edita i parametri di stampa
Button9=MaterialParamEdit.lua,Images\MaterialParamEdit.png,Edita i parametri del materiale
ParamFile=C:\EgtData\3dPrinting\Machinings\Params.ini
ResultReadProg="C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE"
MachiningEditProg="C:\Windows\System32\notepad.exe"
View File
View File
Binary file not shown.
+41
View File
@@ -0,0 +1,41 @@
[Default]
StrandH=10
StrandW=5
StrandCount=1
Offset=3
StartingPoint=-300,-200
StrandOrder=in
Direction=CCW
LinkType=straight
LinkParam=5
FloorCount=0
Speed=
Feed=
ExtFeed=
IntFeed=
InfillFeed=
LeadInFeed=
LeadOutFeed=
SupportFeed=
G0Feed=10
Material=material1
[LayerX]
StrandH=1
StrandW=8
StrandCount=3
Offset=2
StartingPoint=(x,y)
StrandOrder=in/out
Direction=CW/CCW
LinkType=straight/sPath
LinkParam=5
FloorCount=2
Speed=
ExtFeed=
IntFeed=
InfillFeed=
LeadInFeed=
LeadOutFeed=
SupportFeed=
G0Feed=
+63
View File
@@ -0,0 +1,63 @@
-- GcodeGenerate.lua by Egaltech s.r.l. 2022/04/11
-- Calcoli prima fase per Stampa 3d
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
-- Imposto direttorio libreria specializzata per Stampa 3d
local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- Costanti generali
_G.package.loaded.AddManData = nil
local AMD = require( 'AddManData')
-- 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()
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 919 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

+94
View File
@@ -0,0 +1,94 @@
-- AddManData.lua by Egaltech s.r.l. 2022/03/28
-- Raccolta costanti generali per Stampa 3d
-- Tabella per definizione modulo
local AddManData = {}
-- Intestazioni
require( 'EgtBase')
EgtOutLog( ' AddManData started', 1)
---------------------------------------------------------------------
PARAMS_GRP = "PrintingParams"
SLICE_LAYER = "Slice"
CONTOUR_GRP = "Crv"
OUTER_CRV = "OuterCrv"
PATH_GRP = "Path"
SOLID_GRP = "Solid"
TOOLPATH_GRP = "ToolPath"
LAYER_SRF = "LayerSurf"
SHELL_CRV = "Shell"
INFILL_CRV = "Infill"
MIN_LEN = 1e-3
MIN_AREA = 1e-6
INFO_PARTD_ID = "PartId"
DEFAULT_SECTION = "Default"
LAYER_SECTION = ""
KEY_SLICE_Z = "SliceZ"
KEY_SLICE_NBR = "SliceNbr"
KEY_SLICE_STEP = "StrandH"
KEY_SHELLS_NBR = "StrandCount"
KEY_STRAND = "StrandW"
KEY_OFFSET_SLICE ="Offset"
KEY_START_POINT = "StartingPoint"
KEY_PRINT_ORDER = "StrandOrder"
KEY_PRINT_DIRECTION = "Direction"
KEY_TYPE = "Type"
KEY_LINK_TYPE = "LinkType"
KEY_LINK_PARAM = "LinkParam"
KEY_FLOOR_NBR = "FloorCount"
KEY_SPEED = "Speed"
KEY_FEED = "Feed"
KEY_EXT_FEED = "ExtFeed"
KEY_INT_FEED = "IntFeed"
KEY_INFILL_FEED = "InfillFeed"
KEY_LEAD_IN_FEED = "LeadInFeed"
KEY_LEAD_OUT_FEED = "LeadOutFeed"
KEY_SUPPORT_FEED = "SupportFeed"
KEY_G0_FEED = "G0Feed"
KEY_MATERIAL = "Material"
KEY_COEFF_X = "CoeffX"
KEY_COEFF_Y = "CoeffY"
TYPE = {
OUTER_SHELL = 0,
INNER_SHELL = 1,
INFILL = 2,
LINK = 3,
}
PRINT_ORDER = {
INT_EXT_INF = 0,
EXT_INT_INF = 1,
INF_EXT_INT = 2,
INF_INT_EXT = 3,
}
PRINT_DIRECTION = {
CCW = 0,
CW = 1,
}
LINK_TYPE = {
LINEAR = 0,
BIARC = 1,
}
---------------------------------------------------------------------
TABLE = "Table"
TABLE_OUTLINE = "Outline"
TABLE_SURFACE = "Surface"
PART = "Part"
ORIGINAL_SOLID = "OriginalSolid"
VIEWPARAMS = 'ViewParams'
IMPORTED_SOLID = 'ImportedSolid'
RESULT_READ_PROG = 'ResultReadProg'
---------------------------------------------------------------------
return AddManData
+70
View File
@@ -0,0 +1,70 @@
-- CalcPaths.lua by Egaltech s.r.l. 2022/03/30
-- Calcolo percorsi di lavoro per Stampa 3d
-- Tabella per definizione modulo
local CSVManager = {}
-- Intestazioni
require( 'EgtBase')
EgtOutLog( ' CSVManager started', 1)
-- Dati
local AMD = require( 'AddManData')
function toCSV (t)
local s = ""
for _,p in pairs(t) do
s = s .. "," .. escapeCSV(p)
end
return string.sub(s, 2) -- remove first comma
end
function escapeCSV (s)
if string.find(s, '[,"]') then
ns = '"' .. string.gsub(s, '"', '""') .. '"'
end
return s
end
local function fromCSV(s)
s = s .. ';' -- ending comma
local t = {} -- table to collect fields
local fieldstart = 1
repeat
-- next field is quoted? (start with `"'?)
if string.find(s, '^"', fieldstart) then
local a, c
local i = fieldstart
repeat
-- find closing quote
a, i, c = string.find(s, '"("?)', i+1)
until c ~= '"' -- quote not followed by quote?
if not i then error('unmatched "') end
local f = string.sub(s, fieldstart+1, i-1)
table.insert(t, (string.gsub(f, '""', '"')))
fieldstart = string.find(s, ';', i) + 1
else -- unquoted; find next comma
local nexti = string.find(s, ';', fieldstart)
table.insert(t, string.sub(s, fieldstart, nexti-1))
fieldstart = nexti + 1
end
until fieldstart > string.len(s)
return t
end
function read_file( path)
local file = io.open( path, "r") -- r read mode and b binary mode
if not file then return nil end
local CSVTable = {}
for line in io.lines( path) do
CSVTable[#CSVTable + 1] = fromCSV( line)
end
file:close()
return CSVTable
end
return CSVManager
+164
View File
@@ -0,0 +1,164 @@
-- CalcPaths.lua by Egaltech s.r.l. 2022/03/30
-- Calcolo percorsi di lavoro per Stampa 3d
-- Tabella per definizione modulo
local CalcPaths = {}
-- Intestazioni
require( 'EgtBase')
EgtOutLog( ' CalcPaths started', 1)
-- Dati
local AMD = require( 'AddManData')
---------------------------------------------------------------------
local function GetLayerParamsForPathCalc()
local nParamsGrp = EgtGetFirstNameInGroup( GDB_ID.ROOT, PARAMS_GRP)
local LayerParams = {}
LayerParams.nShellsNbr = EgtGetInfo( nParamsGrp, KEY_SHELLS_NBR, 'i')
LayerParams.dStrand = EgtGetInfo( nParamsGrp, KEY_STRAND, 'd')
LayerParams.dOffs = EgtGetInfo( nParamsGrp, KEY_OFFSET_SLICE, 'd')
LayerParams.nFloorNbr = EgtGetInfo( nParamsGrp, KEY_FLOOR_NBR, 'i')
return LayerParams
end
---------------------------------------------------------------------
local function GetLayerStartPoint()
local nParamsGrp = EgtGetFirstNameInGroup( GDB_ID.ROOT, PARAMS_GRP)
local ptStart = EgtGetInfo( nParamsGrp, KEY_START_POINT, 'p')
return ptStart
end
---------------------------------------------------------------------
local function GetPathsFromSurf( nSrfId, sName, nType, nGrpId, nLayId, dStrand)
local nChunks = EgtSurfFrChunkCount( nSrfId)
for nC = 0, nChunks - 1 do
-- estraggo i contorni
local nCrvId, nCrvCnt = EgtExtractSurfFrChunkLoops( nSrfId, nC, nGrpId)
for nInd = 0, nCrvCnt - 1 do
EgtSetName( nCrvId + nInd, sName)
EgtSetInfo( nCrvId + nInd, KEY_TYPE, nType)
-- se è loop interno lo inverto per averlo orientato in senso antiorario
if nInd > 0 then
EgtInvertCurve( nCrvId + nInd)
end
-- verifico soddisfi i requisiti (lunghezza e area)
local dLen = EgtCurveLength( nCrvId + nInd)
local _ , _ , dArea = EgtCurveArea( nCrvId + nInd)
if dLen < MIN_LEN or dArea < MIN_AREA then
EgtErase( nCrvId + nInd)
return
end
-- scelta start point
local ptStart = GetLayerStartPoint( nLayId)
EgtChangeClosedCurveStartPoint( nCrvId + nInd, ptStart)
end
end
end
--------------------------------------------------------------------
local function AddFloor( nSrfId, nGrpId, LayerParams, nFloorNbr)
-- local nSrfCopy = EgtCopyGlob( nSrfId, nGrpId)
-- local dOffs = 0.5 * LayerParams.dStrand - LayerParams.dOffs + LayerParams.nShellsNbr * LayerParams.dStrand
-- local dAng = 0
--
-- if EgtSurfFrOffset( nSrfCopy, - dOffs) and EgtSurfFrChunkCount( nSrfCopy) > 0 then
-- local nCrvId, nCnt = EgtGetSurfFrZigZagInfill( nSrfCopy, nGrpId, LayerParams.dStrand + 10 * GEO.EPS_SMALL, dAng, false, false)
-- for nInd = 0, nCnt - 1 do
-- local dLen = EgtCurveLength( nCrvId + nInd)
-- if dLen < MIN_LEN then
-- EgtErase( nCrvId + nInd)
-- else
-- EgtSetName( nCrvId + nInd, INFILL_CRV)
-- EgtSetInfo( nCrvId + nInd, KEY_TYPE, TYPE.INFILL)
-- end
-- end
-- EgtErase( nSrfCopy)
-- end
end
---------------------------------------------------------------------
function CalcPaths.Exec( nPartId)
local vLayIds = EgtGetNameInGroup( nPartId, SLICE_LAYER.."*")
if not vLayIds then
EgtOutBox( 'Error no slice', 'PathCalc')
return
end
-- scorro tutti i suoi layer
for nIdx = 1, #vLayIds do
-- recupero i parametri relativi al layer
local LayerParams = GetLayerParamsForPathCalc()
-- scorro tutti i gruppi di contorni
local nCrvGrpId = EgtGetFirstNameInGroup( vLayIds[nIdx], CONTOUR_GRP.."*") or GDB_ID.NULL
while nCrvGrpId ~= GDB_ID.NULL do
-- verifico se il path e il solido sono già stati calcolati
local nGrpId = EgtGetFirstNameInGroup( nCrvGrpId, PATH_GRP) or GDB_ID.NULL
if nGrpId == GDB_ID.NULL then
nGrpId = EgtGroup( nCrvGrpId)
EgtSetName( nGrpId, PATH_GRP)
else
EgtEmptyGroup( nGrpId)
EgtSetStatus( nGrpId, GDB_ST.ON)
end
local nSolidGrpId = EgtGetFirstNameInGroup( nCrvGrpId, SOLID_GRP) or GDB_ID.NULL
if nSolidGrpId ~= GDB_ID.NULL then
EgtErase( nSolidGrpId)
end
-- recupero la superficie ottenuta dallo slicing
local nSrf = EgtGetFirstNameInGroup( nCrvGrpId, LAYER_SRF)
if nSrf then
-- esterno
local nSrfId = EgtCopyGlob( nSrf, nCrvGrpId)
local dOffs = 0.5 * LayerParams.dStrand - LayerParams.dOffs
EgtSurfFrOffset( nSrfId, - dOffs)
-- estraggo i contorni (pareti esterne)
GetPathsFromSurf( nSrfId, SHELL_CRV..'0', TYPE.OUTER_SHELL, nGrpId, nLayId, LayerParams.dStrand)
EgtErase( nSrfId)
-- calcolo pareti interne
for nInd2 = 1, LayerParams.nShellsNbr - 1 do
-- offset della superficie originale
local nSrfId = EgtCopy( nSrf, nGrpId)
if EgtSurfFrOffset( nSrfId, - dOffs - nInd2 * LayerParams.dStrand) then
-- estraggo i contorni ( pareti interne)
GetPathsFromSurf( nSrfId, SHELL_CRV..tostring( nInd2), TYPE.INNER_SHELL, nGrpId, nLayId, LayerParams.dStrand)
end
EgtErase( nSrfId)
end
-- gestione eventuale floor
if nIdx <= LayerParams.nFloorNbr then
AddFloor( nSrf, nGrpId, LayerParams, nIdx)
end
end
--passo al gruppo di contorni successivo
nCrvGrpId = EgtGetNextName( nCrvGrpId, CONTOUR_GRP.."*") or GDB_ID.NULL
end
if EgtProcessEvents( nIdx / #vLayIds * 100, 0) == 1 then
EgtDraw()
return
end
end
end
---------------------------------------------------------------------
return CalcPaths
+141
View File
@@ -0,0 +1,141 @@
-- CalcSlices.lua by Egaltech s.r.l. 2022/03/30
-- Calcolo percorsi di lavoro per Stampa 3d
-- Tabella per definizione modulo
local CalcSlices = {}
-- Intestazioni
require( 'EgtBase')
EgtOutLog( ' CalcSlices started', 1)
-- Dati
local AMD = require( 'AddManData')
---------------------------------------------------------------------
local function GetSliceStep()
local nParamsGrp = EgtGetFirstNameInGroup( GDB_ID.ROOT, PARAMS_GRP)
local dStep = EgtGetInfo( nParamsGrp, KEY_SLICE_STEP, 'd')
return dStep
end
---------------------------------------------------------------------
function CalcSlices.Exec( nPartId, nStmId)
local dTol = 0.05
-- recuper il box della superficie
local b3Box = EgtGetBBoxRef( nStmId, GDB_BB.STANDARD, EgtGetGridFrame())
if not b3Box or b3Box:isEmpty() then
EgtOutText( 'La superficie selezionata è vuota')
EgtPause( 1000)
return
end
-- Parametri di slicing
local dZmin = b3Box:getMin():getZ() + 0.1 --0.1 * dStep
local dZmax = b3Box:getMax():getZ() - 0.1 -- 0.1 * dStep
-- se slicing già presente lo cancello
local nOldSliceId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .."*") or GDB_ID.NULL
while nOldSliceId ~= GDB_ID.NULL do
EgtErase( nOldSliceId)
nOldSliceId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .."*") or GDB_ID.NULL
end
EgtStartCounter()
-- Eseguo slicing
local dPosZ = dZmin
local nLayCnt = 1
while dPosZ < dZmax do
-- nuovo layer
local nLayId = EgtGroup( nPartId)
EgtSetInfo( nLayId, KEY_SLICE_Z, dPosZ)
EgtSetInfo( nLayId, KEY_SLICE_NBR, nLayCnt)
-- calcolo intersezione
nNewId, nPntCnt, nCrvCnt, nSrfCnt = EgtPlaneSurfTmInters( Point3d( 0, 0, dPosZ), Z_AX(), nStmId, nLayId, GDB_RT.GRID)
-- verifico se ricalcolare con piccolo spostamento
local bRecalc = not nNewId or ( nSrfCnt ~= 0)
if not bRecalc then
for Id = nNewId + nPntCnt, nNewId + nPntCnt + nCrvCnt - 1 do
if not EgtCurveIsClosed( Id) then
bRecalc = true
break
end
end
end
-- se richiesto, eseguo ricalcolo
if bRecalc then
local vtN = EgtSurfTmFacetNormVersor( nNewId or 0 + nPntCnt or 0 + nCrvCnt or 0, 0)
local dDeltaZ = EgtIf( vtN and vtN:getZ() < 0, 0.005, - 0.005)
EgtEmptyGroup( nLayId)
nNewId, nPntCnt, nCrvCnt, nSrfCnt = EgtPlaneSurfTmInters( Point3d( 0, 0, dPosZ + dDeltaZ), Z_AX(), nStmId, nLayId, GDB_RT.GRID)
end
-- salvo i risultati nel layer
if nNewId then
-- verifico presenza contorni aperti
local bAllClosed = true
for Id = nNewId + nPntCnt, nNewId + nPntCnt + nCrvCnt - 1 do
if not EgtCurveIsClosed( Id) then
bAllClosed = false
break
end
end
-- salvo
EgtSetName( nLayId, EgtIf( bAllClosed, '', '**') .. SLICE_LAYER .. EgtNumToString( nLayCnt))
EgtSetInfo( nLayId, 'PntCnt', nPntCnt)
EgtSetInfo( nLayId, 'CrvCnt', nCrvCnt)
EgtSetInfo( nLayId, 'SrfCnt', nSrfCnt)
EgtSetColor( EgtTableFill( nNewId, nPntCnt) or {}, 'BLUE')
EgtSetColor( EgtTableFill( nNewId + nPntCnt, nCrvCnt) or {}, 'BLACK')
EgtSetColor( EgtTableFill( nNewId + nPntCnt + nCrvCnt, nSrfCnt) or {}, 'AQUA')
-- creo flat region a partire dalle curve ottenute con lo slicing
local vCrvs = {}
for nInd = 0, nCrvCnt - 1 do
table.insert( vCrvs, nNewId + nPntCnt + nInd)
EgtApproxCurve( nNewId + nPntCnt + nInd, GDB_CA.ARCS, dTol)
end
local nSurfFR = EgtSurfFlatRegion( nLayId, vCrvs)
for nInd = 1, #vCrvs do
EgtErase( vCrvs[nInd])
end
if nSurfFR then
-- analizzo i singoli chunks
local nSfrId, nSrfCnt = EgtExplodeSurf( nSurfFR)
for nInd = 0, nSrfCnt - 1 do
-- per ogni chunk creo un gruppo di percorsi
local nGrpCrv = EgtGroup( nLayId)
EgtSetName( nGrpCrv, CONTOUR_GRP .. EgtNumToString( nInd + 1, 1))
EgtRelocateGlob( nSfrId + nInd, nGrpCrv)
EgtSetName( nSfrId + nInd, LAYER_SRF)
EgtSetStatus( nSfrId + nInd, GDB_ST.OFF)
-- estraggo i contorni della superficie
local nCrvId, nCrvCnt = EgtExtractSurfFrChunkLoops( nSfrId + nInd, 0, nGrpCrv)
for nInd2 = 0, nCrvCnt - 1 do
EgtSetName( nCrvId + nInd2, OUTER_CRV)
EgtSetColor( nCrvId + nInd2, 'BLACK')
end
end
else
-- errore
EgtSetName( nLayId, EgtIf( bAllClosed, '', '**') .. SLICE_LAYER .. EgtNumToString( nLayCnt))
end
-- errore
else
EgtSetName( nLayId, EgtIf( bAllClosed, '', '**') .. SLICE_LAYER .. EgtNumToString( nLayCnt))
end
local dStep = GetSliceStep( dPosZ, dStep)
dPosZ = dPosZ + dStep
nLayCnt = nLayCnt + 1
end
end
---------------------------------------------------------------------
return CalcSlices
+242
View File
@@ -0,0 +1,242 @@
-- CalcSolids.lua by Egaltech s.r.l. 2022/03/30
-- Calcolo percorsi di lavoro per Stampa 3d
-- Tabella per definizione modulo
local CalcSolids = {}
-- Intestazioni
require( 'EgtBase')
EgtOutLog( ' CalcSolids started', 1)
-- Dati
local AMD = require( 'AddManData')
---------------------------------------------------------------------
local function GetLayerParamsForSolidCalc()
local nParamsGrp = EgtGetFirstNameInGroup( GDB_ID.ROOT, PARAMS_GRP)
local LayerParams = {}
LayerParams.bInvert = EgtGetInfo( nParamsGrp, KEY_PRINT_DIRECTION, 'b')
LayerParams.dLayHeight = EgtGetInfo( nParamsGrp, KEY_SLICE_STEP, 'd')
LayerParams.dStrand = EgtGetInfo( nParamsGrp, KEY_STRAND, 'd')
LayerParams.nOrder = EgtGetInfo( nParamsGrp, KEY_PRINT_ORDER, 'i')
return LayerParams
end
---------------------------------------------------------------------
local function CreateSection( ptS, vtDir, dStrand, dH, nSolidGrp)
ptS = ptS - dH * Z_AX()
local dD1 = 0.5 * dStrand - dStrand / 10
local dD2 = 0.5 * dStrand - dD1
local dD3 = dH / 6
local dD4 = dH - 2 * dD3
vtDir:rotate( Z_AX(), 90)
local ptA = ptS + dD1 * vtDir
local ptB = ptA + dD2 * vtDir + dD3 * Z_AX()
local ptC = ptB + dD4 * Z_AX()
local ptD = ptA + dH * Z_AX()
local ptE = ptD - 2 * dD1 * vtDir
local ptF = ptC - 2 * ( dD1 + dD2) * vtDir
local ptG = ptB - 2 * ( dD1 + dD2) * vtDir
local ptH = ptA - 2 * dD1 * vtDir
local nId = EgtCurveCompoFromPoints( nSolidGrp, {ptA, ptB, ptC, ptD, ptE, ptF, ptG, ptH, ptA})
return nId
end
--------------------------------------------------------------------
local function CloseSolid( nCrvId, nSrfId, nSolidGrp, LayerParams)
local ptS = EgtSP( nCrvId)
local vtS = EgtSV( nCrvId)
local nSectS = CreateSection( ptS, vtS, LayerParams.dStrand, LayerParams.dLayHeight, nSolidGrp)
local nSrfS = EgtSurfTmByRevolve( nSolidGrp, nSectS, ptS, Z_AX(), false, 0.1)
EgtCutSurfTmPlane( nSrfS, ptS, EgtSV( nCrvId), true)
local ptE = EgtEP( nCrvId)
local vtE = EgtEV( nCrvId)
local nSectE = CreateSection( ptE, vtE, LayerParams.dStrand, LayerParams.dLayHeight, nSolidGrp)
local nSrfE = EgtSurfTmByRevolve( nSolidGrp, nSectE, ptE, Z_AX(), false, 0.1)
EgtCutSurfTmPlane( nSrfE, ptE, - EgtEV( nCrvId), true)
EgtErase( nSectS)
EgtErase( nSectE)
return EgtSurfTmBySewing( nSolidGrp, { nSrfId, nSrfS, nSrfE})
end
---------------------------------------------------------------------
local function CreateSolidFromCurve( nCrvId, nSolidGrp, LayerParams, nParts)
local nCopyId = EgtCopyGlob( nCrvId, nSolidGrp)
-- scelta del colore
local nType = EgtGetInfo( nCrvId, KEY_TYPE, 'i')
local Color = EgtStdColor( 'GRAY')
if nType == TYPE.OUTER_SHELL then
Color = EgtStdColor( 'ORANGE')
elseif nType == TYPE.INNER_SHELL or nType == TYPE.LINK then
Color = EgtStdColor( 'TEAL')
elseif nType == TYPE.INFILL then
Color = EgtStdColor( 'YELLOW')
end
local nDefaultParts = EgtIf( nType == TYPE.LINK, 1, 10)
if not nParts then
nParts = nDefaultParts
elseif nParts == nDefaultParts then
nParts = nDefaultParts + 1
end
local nId = EgtSplitCurve( nCopyId, nParts)
local vIdStm = {}
for nInd = 0, nParts - 1 do
if nType == TYPE.INFILL and nInd == 0 then
EgtInvertCurve( nId + nInd)
end
local ptS = EgtSP( nId + nInd)
local vtS = EgtSV( nId + nInd)
local nSectId = CreateSection( ptS, vtS, LayerParams.dStrand, LayerParams.dLayHeight, nSolidGrp)
EgtInvertCurve( nSectId)
local nSrfId = EgtSurfTmSwept( nSolidGrp, nSectId, nId + nInd, false, 0.1)
if nSrfId then
table.insert( vIdStm, nSrfId)
else
if nParts < 100 then
-- cancello quando appena fatto e provo a spezzare la curva in un diverso numero di parti
EgtErase( nSectId)
for nInd3 = 0, nParts - 1 do
EgtErase( nId + nInd3)
end
for nInd3 = 0, nInd - 1 do
local nId2 = EgtGetLastInGroup( nSolidGrp)
EgtErase( nId2)
end
local nNewParts = EgtIf( nParts == nDefaultParts, 5, nParts + 1)
CreateSolidFromCurve( nCrvId, nSolidGrp, LayerParams, nNewParts)
return
else
EgtOutBox( 'CalcSolid error', '')
EgtErase( nSectId)
for nInd3 = 0, nParts - 1 do
EgtErase( nId + nInd3)
end
for nInd3 = 0, nInd - 1 do
local nId2 = EgtGetLastInGroup( nSolidGrp)
EgtErase( nId2)
end
return
end
end
EgtErase( nSectId)
end
-- se ho creato troppe parts unisco le superfici per ridurne il numero
local vCrvIds = {}
if nParts > nDefaultParts then
local nGroups1 = nParts % nDefaultParts
local nGroups2 = nDefaultParts - nGroups1
local nElements1 = ceil( nParts / nDefaultParts)
local nElements2 = floor( nParts / nDefaultParts)
local nCnt = 0
local nInd = 1
while nInd <= #vIdStm do
local nElements = EgtIf( nCnt < nGroups1, nElements1, nElements2)
local vIds = { vIdStm[nInd]}
local nFirstId = nId + nInd - 1
for nId2 = 1, nElements - 1 do
nInd = nInd + 1
table.insert( vIds, vIdStm[nInd])
EgtAddCurveCompoCurve( nFirstId, nId + nInd - 1)
end
local nNewSrf = EgtSurfTmByTriangles( nSolidGrp, vIds)
nInd = nInd + 1
nCnt = nCnt + 1
table.insert( vCrvIds, nFirstId)
vIdStm[nCnt] = nNewSrf
end
nParts = nDefaultParts
else
for nInd = 0, nParts - 1 do
table.insert( vCrvIds, nId + nInd)
end
end
for nInd = 1, nParts do
vIdStm[nInd] = CloseSolid( vCrvIds[nInd], vIdStm[nInd], nSolidGrp, LayerParams)
EgtSetColor( vIdStm[nInd], Color)
EgtSetInfo( vIdStm[nInd], KEY_TYPE, nType)
EgtErase( vCrvIds[nInd])
end
end
---------------------------------------------------------------------
function CalcSolids.Exec( nPartId)
local vLayIds = EgtGetNameInGroup( nPartId, SLICE_LAYER.."*")
if not vLayIds then
EgtOutBox( 'Error no slice', 'SolidCalc')
return
end
for nIdx = 1, #vLayIds do
-- recupero i parametri relativi al layer
local LayerParams = GetLayerParamsForSolidCalc()
-- scorro tutti i gruppi di contorni
local nCrvGrpId = EgtGetFirstNameInGroup( vLayIds[ nIdx], CONTOUR_GRP.."*") or GDB_ID.NULL
while nCrvGrpId ~= GDB_ID.NULL do
-- recupero il gruppo dei percorsi utensile
local nTPathGrpId = EgtGetFirstNameInGroup( nCrvGrpId, TOOLPATH_GRP) or GDB_ID.NULL
if nTPathGrpId == GDB_ID.NULL then
EgtOutBox( 'Error no tool paths', 'SolidCalc')
return
end
-- recupero il gruppo dei soldi
local nSolidGrpId = EgtGetFirstNameInGroup( nCrvGrpId, SOLID_GRP) or GDB_ID.NULL
if nSolidGrpId == GDB_ID.NULL then
nSolidGrpId = EgtGroup( nCrvGrpId)
EgtSetName( nSolidGrpId, SOLID_GRP)
else
EgtEmptyGroup( nSolidGrpId)
end
-- scorro le curve
local nId = EgtGetFirstInGroup( nTPathGrpId)
while nId do
CreateSolidFromCurve( nId, nSolidGrpId, LayerParams)
nId = EgtGetNext( nId)
end
-- nascondo ExternCurve del gruppo
local vExtCrvs = EgtGetNameInGroup( nCrvGrpId, OUTER_CRV)
for nInd = 1, #vExtCrvs do
EgtSetStatus( vExtCrvs[nInd], GDB_ST.OFF)
end
--passo al gruppo di contorni successivo
nCrvGrpId = EgtGetNextName( nCrvGrpId, CONTOUR_GRP.."*") or GDB_ID.NULL
end
if EgtProcessEvents( nIdx / #vLayIds * 100, 0) == 1 then
EgtDraw()
return
end
end
end
---------------------------------------------------------------------
return CalcSolids
+105
View File
@@ -0,0 +1,105 @@
-- CalcToolPath.lua by Egaltech s.r.l. 2022/03/29
-- Calcolo percorsi di lavoro per Stampa 3d
-- Tabella per definizione modulo
local CalcToolPath = {}
-- Intestazioni
require( 'EgtBase')
EgtOutLog( ' CalcToolPath started', 1)
-- Dati
local AMD = require( 'AddManData')
---------------------------------------------------------------------
local function GetLayerParamsForToolPathCalc()
local nParamsGrp = EgtGetFirstNameInGroup( GDB_ID.ROOT, PARAMS_GRP)
local LayerParams = {}
LayerParams.dLayHeight = EgtGetInfo( nParamsGrp, KEY_SLICE_STEP, 'd')
LayerParams.bInvert = EgtGetInfo( nParamsGrp, KEY_PRINT_DIRECTION, 'b')
LayerParams.nOrder = EgtGetInfo( nParamsGrp, KEY_PRINT_ORDER, 'i')
LayerParams.LinkType = EgtGetInfo( nParamsGrp, KEY_LINK_TYPE, 'i')
LayerParams.LinkParam = EgtGetInfo( nParamsGrp, KEY_LINK_PARAM, 'd')
return LayerParams
end
---------------------------------------------------------------------
function CalcToolPath.Exec( nPartId)
-- Verifico il pezzo
if not nPartId then
EgtOutBox( 'Error missing part', 'ToolPathCalc')
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
for nIdx = 1, #vLayIds do
-- recupero i parametri relativi al layer
local LayerParams = GetLayerParamsForToolPathCalc()
-- scorro tutti i gruppi di contorni
local nCrvGrpId = EgtGetFirstNameInGroup( vLayIds[ nIdx], CONTOUR_GRP.."*")
while nCrvGrpId do
-- recupero il gruppo dei percorsi
local nPathGrpId = EgtGetFirstNameInGroup( nCrvGrpId, PATH_GRP)
if not nPathGrpId then
EgtOutBox( 'Error missing paths', 'ToolPathCalc')
return
else
EgtSetStatus( nPathGrpId, GDB_ST.OFF)
end
-- recupero il gruppo dei percorsi utensile
local nTpathGrpId = EgtGetFirstNameInGroup( nCrvGrpId, TOOLPATH_GRP)
if not nTpathGrpId then
nTpathGrpId = EgtGroup( nCrvGrpId)
EgtSetName( nTpathGrpId, TOOLPATH_GRP)
else
EgtEmptyGroup( nTpathGrpId)
end
-- creo il percorso di lavoro :
-- copio le curve, le ordino, le oriento e le muovo in Z
local nEntId = EgtGetFirstInGroup( nPathGrpId)
while nEntId do
local nNewEntId = EgtCopyGlob( nEntId, nTpathGrpId, EgtIf( LayerParams.nOrder == PRINT_ORDER.INT_EXT_INF, GDB_IN.FIRST_SON, GDB_IN.LAST_SON))
EgtMove( nNewEntId, Vector3d( 0, 0, LayerParams.dLayHeight), GDB_RT.GLOB)
if LayerParams.bInvert then
EgtInvertCurve( nNewEntId)
end
nEntId = EgtGetNext( nEntId)
end
-- aggiungo gli opportuni raccordi
local nPrevId = EgtGetFirstInGroup( nTpathGrpId)
local nCurrId = EgtGetNext( nPrevId or GDB_ID.NULL)
while nCurrId do
local nLinkId
if LayerParams.LinkType == LINK_TYPE.LINEAR then
nLinkId = EgtLine( nTpathGrpId, EgtEP( nPrevId), EgtSP( nCurrId))
else
EgtTrimCurveEndAtLen( nPrevId, EgtCurveLength( nPrevId) - LayerParams.LinkParam / 2)
EgtTrimCurveStartAtLen( nCurrId, LayerParams.LinkParam / 2)
local _, _, dAngIni = SphericalFromVector( EgtEV( nPrevId))
local _, _, dAngFin = SphericalFromVector( EgtSV( nCurrId))
nLinkId = EgtBiArc( nTpathGrpId, EgtEP( nPrevId), EgtSP( nCurrId), dAngIni, dAngFin, 0.5)
end
EgtRelocate( nLinkId, nCurrId, GDB_IN.BEFORE)
local nType = EgtGetInfo( nCurrId, KEY_TYPE, 'i')
EgtSetInfo( nLinkId, KEY_TYPE, TYPE.LINK)
nPrevId = nCurrId
nCurrId = EgtGetNext( nCurrId)
end
--passo al gruppo di contorni successivo
nCrvGrpId = EgtGetNextName( nCrvGrpId, CONTOUR_GRP.."*")
end
end
end
---------------------------------------------------------------------
return CalcToolPath
+177
View File
@@ -0,0 +1,177 @@
-- MachiningParamCalc.lua by Egaltech s.r.l. 2022/04/05
-- Gestione visualizzazione per Stampa 3d
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
-- Imposto direttorio libreria specializzata per Stampa 3d
local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- Costanti generali
local AMD = require( 'AddManData')
local CSV = require( 'CSVManager')
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 --------------------------------------
+53
View File
@@ -0,0 +1,53 @@
-- MachiningParamCalc.lua by Egaltech s.r.l. 2022/04/05
-- Gestione visualizzazione per Stampa 3d
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
-- Imposto direttorio libreria specializzata per Stampa 3d
local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- Costanti generali
local AMD = require( 'AddManData')
-- 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 --------------------------------------
+17
View File
@@ -0,0 +1,17 @@
[Default]
StrandH=2.0
StrandW=6.0
StrandCount=2
Offset=2.0
StartingPoint=0,-300
StrandOrder=in
Direction=CCW
LinkType=sPath
LinkParam=10.0
FloorCount=2
Speed=
Feed=4500
G0Feed=10000
Material=B461
CoeffX=-8.68
CoeffY=12.4865
+37
View File
@@ -0,0 +1,37 @@
[Default]
StrandH=40.0
StrandW=6.0
StrandCount=3
Offset=2.0
StartingPoint=0,-300
StrandOrder=in
Direction=CCW
LinkType=sPath
LinkParam=10.0
FloorCount=2
Speed=
Feed=4500
G0Feed=10000
Material=B461
CoeffX=-8.68
CoeffY=12.4865
[LayerX]
StrandH=1
StrandW=8
StrandCount=3
Offset=2
StartingPoint=(x,y)
StrandOrder=in/out
Direction=CW/CCW
LinkType=straight/sPath
LinkParam=5
FloorCount=2
Speed=
ExtFeed=
IntFeed=
InfillFeed=
LeadInFeed=
LeadOutFeed=
SupportFeed=
G0Feed=
+52
View File
@@ -0,0 +1,52 @@
-- MachiningParamCalc.lua by Egaltech s.r.l. 2022/04/09
-- Gestione edit parametri materiali per Stampa 3d
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
-- Imposto direttorio libreria specializzata per Stampa 3d
local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- Costanti generali
local AMD = require( 'AddManData')
-- 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 --------------------------------------
+26
View File
@@ -0,0 +1,26 @@
Larghezza strand W [mm];Passo Z [mm];Tempo minimo [sec] ;Tempo massimo [sec]
1;"1";"10";"25"
2;"1";"14";"28"
3;"1";"16";"30"
4;"1";"18";"40"
5;"1";"20";"50"
6;"1";"25";"52"
7;"1";"30";"55"
8;"1";"32";"60"
9;"1";"36";"65"
10;"1";"38";"70"
11;"1";"40";"75"
12;"1";"44";"80"
1;"1.2";"11";"26"
2;"1.2";"15";"29"
3;"1.2";"17";"31"
4;"1.2";"19";"41"
5;"1.2";"21";"51"
6;"1.2";"26";"53"
7;"1.2";"31";"56"
8;"1.2";"33";"61"
9;"1.2";"37";"66"
10;"1.2";"39";"71"
11;"1.2";"41";"76"
12;"1.2";"45";"81"
6;"2";"60";"100"
1 Larghezza strand W [mm] Passo Z [mm] Tempo minimo [sec] Tempo massimo [sec]
2 1 1 10 25
3 2 1 14 28
4 3 1 16 30
5 4 1 18 40
6 5 1 20 50
7 6 1 25 52
8 7 1 30 55
9 8 1 32 60
10 9 1 36 65
11 10 1 38 70
12 11 1 40 75
13 12 1 44 80
14 1 1.2 11 26
15 2 1.2 15 29
16 3 1.2 17 31
17 4 1.2 19 41
18 5 1.2 21 51
19 6 1.2 26 53
20 7 1.2 31 56
21 8 1.2 33 61
22 9 1.2 37 66
23 10 1.2 39 71
24 11 1.2 41 76
25 12 1.2 45 81
26 6 2 60 100
+105
View File
@@ -0,0 +1,105 @@
-- PlacePart.lua by Egaltech s.r.l. 2022/04/11
-- Gestione calcolo disposizione e lavorazioni per stampa 3d
-- 2022/03/21 Creazione file
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
-- Imposto direttorio libreria specializzata per Stampa 3d
local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- Costanti generali
local AMD = require( 'AddManData')
-- Recupero ultimo oggetto selezionato
local nPartId = EgtGetParent(EgtGetParent( EgtGetLastSelectedObj()))
-- verifico sia un pezzo valido
if nPartId then
local nParentId = EgtGetParent( nPartId)
while nParentId ~= GDB_ID.ROOT do
nPartId = nParentId
nParentId = EgtGetParent( nPartId)
end
if EgtIsPart( nPartId) then
local sName = EgtGetName( nPartId)
if sName == TABLE then
EgtOutBox( 'No selected part. Please select a part before moving it on the table.', 'Warning', 'WARNING')
return
end
else
EgtOutBox( 'No selected part. Please select a part before moving it on the table.', 'Warning', 'WARNING')
return
end
else
EgtOutBox( 'No selected part. Please select a part before moving it on the table.', 'Warning', 'WARNING')
return
end
-- gli assegno nome pezzo e layer
if not EgtGetName( nPartId) then
local nPartIndex = 1
while EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex) do
nPartIndex = nPartIndex + 1
end
EgtSetName( nPartId, PART .. nPartIndex)
local nLayerId = EgtGetFirstInGroup( nPartId)
EgtSetName( nLayerId, ORIGINAL_SOLID)
end
-- Recupero dati tavola (creando gruppo di lavoro temporaneo)
local nQqqId = EgtAddMachGroup( 'qqq')
EgtSetTable( 'Tab')
local b3Tab = EgtGetTableArea()
dTabX = b3Tab:getDimX()
dTabY = b3Tab:getDimY()
EgtRemoveMachGroup( nQqqId or GDB_ID.NULL)
-- Richiedo coordinata posizionamento pezzo
local b3Part = EgtGetBBoxGlob( nPartId, GDB_BB.EXACT)
local dPosX = b3Tab:getDimX() / 2
local dPosY = b3Tab:getDimY() / 2
local Positions = EgtDialogBox( 'Part position on table:', { 'X', EgtNumToString( EgtToUiUnits(dPosX), 1)}, { 'Y', EgtNumToString( EgtToUiUnits(dPosY), 1)})
if not Positions then return end
dPosX = EgtFromUiUnits( tonumber( Positions[1])) - b3Part:getDimX() / 2
dPosY = EgtFromUiUnits( tonumber( Positions[2])) - b3Part:getDimY() / 2
-- Creo disegno tavola
local nTabPart = EgtGetFirstNameInGroup( GDB_ID.ROOT, TABLE)
if not nTabPart then
-- Disegno tavola
nTabPart = EgtGroup( GDB_ID.ROOT)
--EgtSetLevel( nTabPart, GDB_LV.SYSTEM)
EgtSetName( nTabPart, TABLE)
local nTabLayer = EgtGroup( nTabPart)
EgtSetName( nTabLayer, TABLE)
local nTabOutlineId = EgtRectangle2P( nTabLayer, Point3d( 0, 0, 0), Point3d( dTabX, dTabY, 0))
EgtSetName( nTabOutlineId, TABLE_OUTLINE)
local nTabSurfId = EgtSurfFlatRegion( nTabLayer, nTabOutlineId)
EgtSetName( nTabSurfId, TABLE_SURFACE)
EgtSetColor( nTabSurfId, 'ORANGE')
EgtSetAlpha( nTabSurfId, 70)
end
-- Posiziono il pezzo
EgtMove( nPartId, Point3d( dPosX, dPosY, 0) - b3Part:getMin())
local nMchGrpId = EgtGetMachGroupId( '3dPrint')
EgtRemoveMachGroup( nMchGrpId or GDB_ID.NULL)
EgtAddMachGroup( '3dPrint')
EgtSetTable( 'Tab')
local nRawId = EgtAddRawPartWithPart( nPartId, GDB_ID.NULL, 0, Color3d( 128, 128, 128, 30))
EgtMoveToCornerRawPart( nRawId, Point3d( dPosX, dPosY, 0), MCH_CR.BL)
EgtResetCurrMachGroup()
EgtSetView( SCE_VD.ISO_SW, false)
EgtZoom( SCE_ZM.ALL)
EgtOutLog( ' +++ PlacePart completed')
+3 -88
View File
@@ -1,92 +1,7 @@
# 3dPrinting
Script LUA x progetto 3DPrinting
Script LUA x progetto 3DPrinting (CMS Kreator)
## Getting started
# Automazioni
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://gitlab.steamware.net/egalware/3dprinting.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.steamware.net/egalware/3dprinting/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
Come per i progetti EgtBeamWall, alla pubblicazione di ogni push nel ramo principale (MAIN), gli script LUA verranno compilati e resi disponibili in area R:\ e Artifacts per essere impiegati ad esempio negli installers.
BIN
View File
Binary file not shown.
+107
View File
@@ -0,0 +1,107 @@
-- ShowManager.lua by Egaltech s.r.l. 2022/04/05
-- Gestione visualizzazione per Stampa 3d
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
-- Imposto direttorio libreria specializzata per Stampa 3d
local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- 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
-- 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 --------------------------------------
+93
View File
@@ -0,0 +1,93 @@
-- SliceAdvancement.lua by Egaltech s.r.l. 2022/04/05
-- Gestione visualizzazione per Stampa 3d
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
-- Imposto direttorio libreria specializzata per Stampa 3d
local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- Costanti generali
local AMD = require( 'AddManData')
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 --------------------------------------
+136
View File
@@ -0,0 +1,136 @@
-- Slicing.lua by Egaltech s.r.l. 2022/03/30
-- Calcoli prima fase per Stampa 3d
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
-- Imposto direttorio libreria specializzata per Stampa 3d
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')
---------------------------------------------------------------------
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()
+114
View File
@@ -0,0 +1,114 @@
-- ViewManager.lua by Egaltech s.r.l. 2022/04/05
-- Gestione visualizzazione per Stampa 3d
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
-- Imposto direttorio libreria specializzata per Stampa 3d
local sBaseDir = EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
-- Costanti generali
local AMD = require( 'AddManData')
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 --------------------------------------