0c7849263c
- per decorazioni da disegno aggiunta gestione trim differenziati sui 4 lati tramite nota da info TrimLTHB nel layer.
211 lines
8.3 KiB
Lua
211 lines
8.3 KiB
Lua
--
|
|
-- EEEEEEEEEE GGGGGG wwww wwww
|
|
-- EEEEEEEEEE GGGGGGGGGG wwww wwww
|
|
-- EEEE GGGG GGGG wwww wwww wwww
|
|
-- EEEE GGGG wwww wwww wwww
|
|
-- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww
|
|
-- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww
|
|
-- EEEE GGGG GGGG wwww wwwwwwww wwww
|
|
-- EEEE GGGG GGGG wwww wwww wwww wwww
|
|
-- EEEEEEEEEE GGGGGGGGGG wwwwwwww wwwwwwww
|
|
-- EEEEEEEEEE GGGGGG wwwwwww wwwwwww
|
|
--
|
|
-- ImportNgeFile.lua by EgalWare s.r.l. 2016.06.14
|
|
-- Autore: Filippo Monchi
|
|
-- importazione file .nge
|
|
|
|
-- 2017.06.16 V1.011 FM Check bore thickness when its color is not green or red
|
|
-- 2019.04.19 V1.012 FM Fix import hinges as nge file; fix on import DeltaPos note from geometry and let it to a new layer
|
|
-- 2019.10.18 V2.000 FM Manage use Materials
|
|
-- 2021.04.23 V2.001 FM Manage info about hatching
|
|
-- 2021.11.24 V2.002 FM Manage side probe option if variable DGC.Pms > 2
|
|
-- 2022.07.27 V2.003 FM Modification to use compiled code
|
|
-- 2023.05.08 V2.004 FM Manage scale factor if length and width are <= than 10 (max scale factor)
|
|
|
|
-- Tavola per definizione modulo (serve ma non usata)
|
|
local ImportNgeFile = {}
|
|
|
|
-- Intestazioni
|
|
require( 'EgtBase')
|
|
EgtEnableDebug( false)
|
|
|
|
-- per messaggi
|
|
-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua')
|
|
EgtAddToPackagePath( DGD.BASEDIR .. '?.lua')
|
|
|
|
|
|
-- Funzione di disegno
|
|
function ImportNgeFile.Draw( CustGeomPath, CustGeomFile )
|
|
|
|
-- Messaggi codice errori
|
|
local EM = ' '
|
|
local EC = 0
|
|
local ErrorBase = 1050
|
|
|
|
local EgtDoorsMsg = require( 'EgtDoorsMsg')
|
|
|
|
-- Pezzo e Layer
|
|
local Pz = EgtGetCurrPart() -- pezzo corrente
|
|
local Lg
|
|
|
|
-- Gestione file custom
|
|
local MakeFaceGeom = true
|
|
local sCompoName
|
|
-- nota presenza hatching
|
|
local bHatch
|
|
|
|
-- caricamento del file custom
|
|
if CustGeomFile and string.find( string.lower(CustGeomFile), '.nge') then
|
|
|
|
-- sostituisco il carattere '\' con '_' nel nome file
|
|
CustGeomFile = string.gsub(CustGeomFile, '\\', '_')
|
|
CustGeomFile = string.gsub(CustGeomFile, '/', '_')
|
|
_,sCompoName,_ = EgtSplitPath( CustGeomFile)
|
|
|
|
-- concateno il file alla path
|
|
local sCustomPathFile = CustGeomPath..CustGeomFile
|
|
local nNewPart
|
|
local nNewLayer
|
|
local nNewEnt
|
|
local nTypeEnt
|
|
local sTypeInfo
|
|
local cColor
|
|
local sDeltaPos
|
|
|
|
-- provo ad inserire
|
|
MakeFaceGeom = not EgtInsertFile( sCustomPathFile)
|
|
|
|
-- se fallito inserimento file do un messaggio di errore
|
|
if MakeFaceGeom then
|
|
EC = 1
|
|
EM = string.format( EgtDoorsMsg[412], sCustomPathFile)
|
|
return (ErrorBase+EC), EM
|
|
end
|
|
|
|
Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer principale
|
|
EgtSetName(Lg,sCompoName)
|
|
|
|
nNewPart = EgtGetNext(Pz) -- nome nuovo pezzo
|
|
nNewLayer = EgtGetFirstInGroup( nNewPart) -- ottengo nuovo layer
|
|
|
|
-- applico la scala
|
|
if nNewLayer then
|
|
-- se ha la nota che permette di scalare
|
|
local bScale = EgtGetInfo( nNewPart, 'AllowScale', 'b') or false
|
|
if bScale then
|
|
local dLength = abs( DGD.LENGTH) / EgtIf( DGD.bMM, 1, GEO.ONE_INCH)
|
|
local dWidth = abs( DGD.WIDTH) / EgtIf( DGD.bMM, 1, GEO.ONE_INCH)
|
|
-- se inferiore a 10 (come numero indipendente da unità di misura)
|
|
if bScale and dLength <= 10 and dWidth <= 10 then
|
|
EgtScale(nNewPart,{{0,0,0},{1,0,0},{0,1,0},{0,0,1}}, dWidth, dLength, 1, GDB_RT.GLOB)
|
|
end
|
|
end
|
|
end
|
|
|
|
-- recupero eventuale flag di mirror
|
|
local sMirr = EgtGetInfo( nNewLayer, 'Mirror')
|
|
if sMirr then
|
|
EgtSetInfo( Lg, 'Mirror', sMirr)
|
|
end
|
|
-- recupero eventuale flag di rotazione (positivo verso le cerniere)
|
|
local sRot = EgtGetInfo( nNewLayer, 'Rotate')
|
|
if sRot then
|
|
EgtSetInfo( Lg, 'Rotate', sRot)
|
|
end
|
|
-- recupero eventuali parametri di trim sui lati (lock, top, hinge, bottom)
|
|
local sTrim = EgtGetInfo( nNewLayer, 'TrimLTHB')
|
|
if sTrim then
|
|
EgtSetInfo( Lg, 'TrimLTHB', sTrim)
|
|
end
|
|
|
|
-- riloco tutti i nuovi layer dal nuovo pezzo al pezzo corrente
|
|
while nNewLayer do
|
|
-- verifico se esiste la nota hatch
|
|
bHatch = EgtGetInfo( nNewLayer, 'hatch', 'b')
|
|
nNewEnt = EgtGetFirstInGroup( nNewLayer) -- ottengo nuova entità
|
|
|
|
while nNewEnt do
|
|
|
|
-- controllo se ha dei colori e le note giuste per cambiare lo spessore
|
|
nTypeEnt = EgtGetType( nNewEnt)
|
|
sTypeInfo = EgtGetInfo( nNewEnt, 'SideDoor')
|
|
if not sDeltaPos then
|
|
sDeltaPos = EgtGetInfo( nNewEnt, 'DeltaPos')
|
|
end
|
|
cColor = EgtGetCalcColor( nNewEnt)
|
|
local sNoteKeepBs = EgtGetInfo( nNewEnt, 'KeepBackSet')
|
|
local sNoteProbes = EgtGetInfo( nNewEnt, 'ProbeSide')
|
|
|
|
if sTypeInfo and cColor and DGD.dT then
|
|
if string.lower(sTypeInfo) == 'keyway' or string.lower(sTypeInfo) == 'secure' then
|
|
if AreSameColor(cColor,RED(),30) then -- se colore rosso allora spessore completo
|
|
EgtModifyCurveThickness( nNewEnt, -DGD.dT)
|
|
elseif AreSameColor(cColor,LIME(),30) then -- se colore verde allora metà spessore
|
|
EgtModifyCurveThickness( nNewEnt, -(DGD.dT/2))
|
|
if sNoteKeepBs then -- se ho assegnato la nota la ritrascrivo modificata
|
|
EgtSetInfo( nNewEnt, 'KeepBackSet', 'x') -- setto 'x' provvisoriamente
|
|
end
|
|
if sNoteProbes then
|
|
EgtSetInfo( nNewEnt, 'ProbeSide', '1')
|
|
end
|
|
else -- altrimenti controllo che lo spessore non supera quello della porta, se lo supera lo setto = spessore porta
|
|
local dTh = EgtCurveThickness( nNewEnt)
|
|
if abs(dTh) > DGD.dT then
|
|
EgtModifyCurveThickness( nNewEnt, EgtIf( dTh > 0, DGD.dT, -DGD.dT))
|
|
elseif abs(dTh) < DGD.dT then
|
|
if sNoteKeepBs then -- se ho assegnato la nota la ritrascrivo modificata
|
|
EgtSetInfo( nNewEnt, 'KeepBackSet', 'x') -- setto 'x' provvisoriamente
|
|
end
|
|
if sNoteProbes then
|
|
EgtSetInfo( nNewEnt, 'ProbeSide', '1')
|
|
end
|
|
end
|
|
end
|
|
end
|
|
elseif sTypeInfo and ( string.lower(sTypeInfo) == 'keyway' or string.lower(sTypeInfo) == 'secure') then
|
|
-- controllo che lo spessore non supera quello della porta, se lo supera lo setto = spessore porta
|
|
local dTh = EgtCurveThickness( nNewEnt)
|
|
if abs(dTh) > DGD.dT then
|
|
EgtModifyCurveThickness( nNewEnt, EgtIf( dTh > 0, DGD.dT, -DGD.dT))
|
|
elseif abs(dTh) < DGD.dT then
|
|
if sNoteKeepBs then -- se ho assegnato la nota la ritrascrivo modificata
|
|
EgtSetInfo( nNewEnt, 'KeepBackSet', 'x') -- setto 'x' provvisoriamente
|
|
end
|
|
if sNoteProbes then
|
|
EgtSetInfo( nNewEnt, 'ProbeSide', '1')
|
|
end
|
|
end
|
|
end
|
|
|
|
EgtRelocateGlob( nNewEnt, Lg) -- riloco nel layer corrente
|
|
nNewEnt = EgtGetFirstInGroup(nNewLayer)
|
|
end
|
|
nNewLayer = EgtGetNext(nNewLayer)
|
|
end
|
|
|
|
-- cancello il nuovo pezzo
|
|
EgtErase(nNewPart)
|
|
-- assegno la nota sulla posizione locale
|
|
if sDeltaPos then
|
|
EgtSetInfo( Lg, 'DeltaPos', sDeltaPos)
|
|
end
|
|
else
|
|
EC = ErrorBase + 2
|
|
EM = string.format( EgtDoorsMsg[411], CustGeomFile, DGD.FILE)
|
|
end
|
|
|
|
-- se non ho caricato il file geom esco
|
|
if not MakeFaceGeom then
|
|
-- (NOTA : se ci sono errori il componente non viene eseguito dal programma di gestione dei componenti)
|
|
-- scrivo note nel layer
|
|
EgtSetInfo( Lg, 'Type' , 'ImportNgeFile')
|
|
EgtSetInfo( Lg, 'CustGeomFile' ,CustGeomFile)
|
|
EgtSetInfo( Lg, 'CustGeomPath' ,CustGeomPath)
|
|
EgtSetInfo( Lg, 'hatch' ,bHatch)
|
|
end
|
|
|
|
return EC, EM, Lg
|
|
end
|
|
|
|
return ImportNgeFile
|