EgtCAM5 :
- aggiunta gestione drop dei file - aggiunto aggiornamento disegno utensile all'aggiornamento in batch dei dati utensili.
This commit is contained in:
+54
-203
@@ -1194,21 +1194,16 @@ Public Class ToolTreeViewItem
|
||||
#Region "ToolSceneUpdate"
|
||||
|
||||
' Variabili che segnalano errori nel disegno dell'utensile
|
||||
Dim m_bToolMakerError As Boolean = False
|
||||
Dim m_bDrawNameExistError As Boolean = False
|
||||
Dim m_bDrawNameError As Boolean = False
|
||||
Dim m_nDrawingError As Integer = 0
|
||||
|
||||
Private Sub UpdateSceneToolDraw()
|
||||
' Azzero errori
|
||||
m_bToolMakerError = False
|
||||
m_bDrawNameError = False
|
||||
m_bDrawNameExistError = False
|
||||
m_nDrawingError = 0
|
||||
|
||||
' Verifico proprietà draw
|
||||
' Se utensile con disegno automatico
|
||||
If String.IsNullOrEmpty(m_Draw) OrElse IsUUID(Path.GetFileNameWithoutExtension(m_Draw)) Then
|
||||
CreateToolDraw()
|
||||
' altrimenti utensile con disegno assegnato
|
||||
Else
|
||||
EgtSetCurrentContext(IniFile.m_ToolsDbSceneContext)
|
||||
If Path.GetExtension(m_Draw).ToLower = ".nge" Then
|
||||
@@ -1217,14 +1212,14 @@ Public Class ToolTreeViewItem
|
||||
EgtZoom(ZM.ALL)
|
||||
Else
|
||||
' Errore
|
||||
m_bDrawNameExistError = True
|
||||
m_nDrawingError = 6
|
||||
EgtNewFile()
|
||||
EgtSetView(VT.TOP, False)
|
||||
EgtZoom(ZM.ALL)
|
||||
End If
|
||||
Else
|
||||
' Errore
|
||||
m_bDrawNameError = True
|
||||
m_nDrawingError = 5
|
||||
EgtNewFile()
|
||||
EgtSetView(VT.TOP, False)
|
||||
EgtZoom(ZM.ALL)
|
||||
@@ -1239,184 +1234,47 @@ Public Class ToolTreeViewItem
|
||||
m_delErrorOnTool(Not IsValid)
|
||||
m_delIsEnabledBtns(IsValid And Not IsModified, IsValid And (IsModified Or NewTool), True)
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub CreateToolDraw()
|
||||
' Carico il relativo ToolHolder
|
||||
Dim ToolHolder As String = String.Empty
|
||||
ToolHolder = LoadToolHolder()
|
||||
If Not LoadToolMaker() OrElse Not CreateToolDraw(ToolHolder) Then
|
||||
EgtSetCurrentContext(IniFile.m_ToolsDbSceneContext)
|
||||
EgtNewFile()
|
||||
End If
|
||||
' Imposto dati per creazione utensile
|
||||
ToolDraw.nToolContext = IniFile.m_ToolsDbSceneContext
|
||||
ToolDraw.sHeadName = m_SelectedHead.HName
|
||||
ToolDraw.sExitName = m_SelectedExit
|
||||
ToolDraw.nType = m_Type
|
||||
StringToLen(m_TotLen, ToolDraw.dTotLen)
|
||||
StringToLen(m_Len, ToolDraw.dLen)
|
||||
StringToLen(m_TotDiam, ToolDraw.dTotDiam)
|
||||
StringToLen(m_Diam, ToolDraw.dDiam)
|
||||
StringToLen(m_Thick, ToolDraw.dThick)
|
||||
StringToLen(m_MaxMat, ToolDraw.dMaxMat)
|
||||
StringToDouble(m_SideAng, ToolDraw.dSideAng)
|
||||
StringToLen(m_CornRad, ToolDraw.dCornRad)
|
||||
' Creo il disegno dell'utensile
|
||||
ToolDraw.Create()
|
||||
m_nDrawingError = ToolDraw.nError
|
||||
EgtSetCurrentContext(IniFile.m_ToolsDbSceneContext)
|
||||
If m_nDrawingError <> 0 Then
|
||||
EgtNewFile()
|
||||
m_Draw = String.Empty
|
||||
End If
|
||||
' Aggiorno visualizzazione
|
||||
EgtSetView(VT.TOP, False)
|
||||
EgtZoom(ZM.ALL)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Mathod that load the toolholder for the current tool (based on his head), or return an empty string
|
||||
''' </summary>
|
||||
Private Function LoadToolHolder() As String
|
||||
Dim sHolder As String = String.Empty
|
||||
If Not IsNothing(m_SelectedHead) Then
|
||||
Dim TempExit As String = String.Empty
|
||||
If CInt(m_SelectedExit) > 0 Then
|
||||
TempExit = m_SelectedExit
|
||||
Else
|
||||
TempExit = "1"
|
||||
End If
|
||||
If Type = MCH_TY.SAW_STD Then
|
||||
EgtUILib.GetPrivateProfileString(S_TOOLHOLDER, SelectedHead.HName & "." & TempExit & ":SAW_STD", "", sHolder, IniFile.m_sCurrMachIniFilePath)
|
||||
ElseIf Type = MCH_TY.SAW_FLAT Then
|
||||
EgtUILib.GetPrivateProfileString(S_TOOLHOLDER, SelectedHead.HName & "." & TempExit & ":SAW_FLAT", "", sHolder, IniFile.m_sCurrMachIniFilePath)
|
||||
End If
|
||||
If String.IsNullOrEmpty(sHolder) Then
|
||||
EgtUILib.GetPrivateProfileString(S_TOOLHOLDER, SelectedHead.HName & "." & TempExit, "", sHolder, IniFile.m_sCurrMachIniFilePath)
|
||||
End If
|
||||
End If
|
||||
If String.IsNullOrWhiteSpace(sHolder) Then
|
||||
Return String.Empty
|
||||
Else
|
||||
Dim sHolderPath As String = String.Empty
|
||||
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
||||
EgtTdbGetToolHolderDir(sHolderPath)
|
||||
sHolderPath += "\" & sHolder
|
||||
Return sHolderPath
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function LoadToolMaker() As Boolean
|
||||
Dim sMaker As String = String.Empty
|
||||
EgtUILib.GetPrivateProfileString(S_TOOLS, ConvertTypeToString(Type), "", sMaker, IniFile.m_sCurrMachIniFilePath)
|
||||
If String.IsNullOrWhiteSpace(sMaker) Then m_bToolMakerError = True
|
||||
' Acquisisce solo il file lua, ma meglio impostare contesto disegno utensili (se ci sono chiamate...)
|
||||
EgtSetCurrentContext(IniFile.m_ToolsDbSceneContext)
|
||||
Return EgtLuaExecFile(IniFile.m_sToolMakersDir & "\" & sMaker)
|
||||
End Function
|
||||
|
||||
Private Function ConvertTypeToString(Type As Integer) As String
|
||||
Select Case Type
|
||||
Case MCH_TY.DRILL_STD, MCH_TY.DRILL_LONG
|
||||
Return K_DRILLMAKER
|
||||
Case MCH_TY.SAW_STD, MCH_TY.SAW_FLAT
|
||||
Return K_SAWBLADEMAKER
|
||||
Case MCH_TY.MILL_STD, MCH_TY.MILL_NOTIP
|
||||
Return K_MILLMAKER
|
||||
Case MCH_TY.MORTISE_STD
|
||||
Return K_MORTISEMAKER
|
||||
Case MCH_TY.CHISEL_STD
|
||||
Return K_CHISELMAKER
|
||||
Case MCH_TY.COMPO
|
||||
Return Nothing
|
||||
End Select
|
||||
Return Nothing
|
||||
End Function
|
||||
|
||||
Private Function CreateToolDraw(ToolHolder As String) As Boolean
|
||||
Dim dTotLen As Double = 0
|
||||
Dim dLen As Double = 0
|
||||
Dim dTotDiam As Double = 0
|
||||
Dim dDiam As Double = 0
|
||||
Dim dThick As Double = 0
|
||||
Dim dMaxMat As Double = 0
|
||||
Dim dSideAng As Double = 0
|
||||
Dim dCornRad As Double = 0
|
||||
StringToLen(m_TotLen, dTotLen)
|
||||
StringToLen(m_Len, dLen)
|
||||
StringToLen(m_TotDiam, dTotDiam)
|
||||
StringToLen(m_Diam, dDiam)
|
||||
StringToLen(m_Thick, dThick)
|
||||
StringToLen(m_MaxMat, dMaxMat)
|
||||
StringToDouble(m_SideAng, dSideAng)
|
||||
StringToLen(m_CornRad, dCornRad)
|
||||
Select Case Type
|
||||
Case MCH_TY.DRILL_STD, MCH_TY.DRILL_LONG, MCH_TY.CHISEL_STD
|
||||
' imposto dati utensile
|
||||
EgtLuaSetGlobStringVar("TOOL.TOOLHOLDER", ToolHolder)
|
||||
EgtLuaSetGlobNumVar("TOOL.TOTLEN", dTotLen)
|
||||
EgtLuaSetGlobNumVar("TOOL.LEN", dLen)
|
||||
EgtLuaSetGlobNumVar("TOOL.DIAM", dDiam)
|
||||
EgtLuaSetGlobNumVar("TOOL.MAXMAT", dMaxMat)
|
||||
Case MCH_TY.SAW_STD, MCH_TY.SAW_FLAT
|
||||
' imposto dati utensile
|
||||
EgtLuaSetGlobStringVar("TOOL.TOOLHOLDER", ToolHolder)
|
||||
EgtLuaSetGlobNumVar("TOOL.LEN", dLen)
|
||||
EgtLuaSetGlobNumVar("TOOL.DIAM", dDiam)
|
||||
Dim dCore As Double = If(dLen >= dThick, dThick - 1, 2 * dLen - dThick)
|
||||
EgtLuaSetGlobNumVar("TOOL.CORE", dCore)
|
||||
EgtLuaSetGlobNumVar("TOOL.THICK", dThick)
|
||||
EgtLuaSetGlobNumVar("TOOL.MAXMAT", dMaxMat)
|
||||
Case MCH_TY.MILL_STD, MCH_TY.MILL_NOTIP
|
||||
' imposto dati utensile
|
||||
EgtLuaSetGlobStringVar("TOOL.TOOLHOLDER", ToolHolder)
|
||||
EgtLuaSetGlobNumVar("TOOL.TOTLEN", dTotLen)
|
||||
EgtLuaSetGlobNumVar("TOOL.LEN", dLen)
|
||||
EgtLuaSetGlobNumVar("TOOL.TOTDIAM", dTotDiam)
|
||||
EgtLuaSetGlobNumVar("TOOL.DIAM", dDiam)
|
||||
EgtLuaSetGlobNumVar("TOOL.MAXMAT", dMaxMat)
|
||||
EgtLuaSetGlobNumVar("TOOL.HEIGHT", dThick)
|
||||
EgtLuaSetGlobNumVar("TOOL.SIDEANG", dSideAng)
|
||||
EgtLuaSetGlobNumVar("TOOL.CORNRAD", dCornRad)
|
||||
Case Else
|
||||
m_nDrawingError = 999
|
||||
m_Draw = String.Empty
|
||||
Return False
|
||||
End Select
|
||||
' passo all'ambiente di disegno dell'utensile
|
||||
EgtSetCurrentContext(IniFile.m_ToolsDbSceneContext)
|
||||
' eseguo creazione utensile
|
||||
EgtLuaCallFunction("CreateTool")
|
||||
' recupero errore
|
||||
Dim nErr As Integer = 999
|
||||
EgtLuaGetGlobIntVar("TOOL.ERR", nErr)
|
||||
m_nDrawingError = nErr
|
||||
If m_nDrawingError <> 0 Then m_Draw = String.Empty
|
||||
If m_nDrawingError = 0 Then m_Draw = m_Uuid & ".nge"
|
||||
Return (nErr = 0)
|
||||
End Function
|
||||
|
||||
Friend Function SaveToolDraw() As Boolean
|
||||
If m_Type = MCH_TY.DRILL_STD Or m_Type = MCH_TY.DRILL_LONG Or
|
||||
m_Type = MCH_TY.SAW_STD Or m_Type = MCH_TY.SAW_FLAT Or
|
||||
m_Type = MCH_TY.MILL_STD Or m_Type = MCH_TY.MILL_NOTIP Or
|
||||
m_Type = MCH_TY.CHISEL_STD Then
|
||||
' nome e direttorio del file da salvare
|
||||
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
||||
Dim sDrawName As String = Uuid
|
||||
sDrawName = sDrawName & ".nge"
|
||||
Dim sPath As String = String.Empty
|
||||
EgtTdbGetToolDir(sPath)
|
||||
sPath = sPath & "\" & sDrawName
|
||||
' passo all'ambiente di disegno dell'utensile
|
||||
EgtSetCurrentContext(IniFile.m_ToolsDbSceneContext)
|
||||
' nascondo layer ausiliario
|
||||
Dim nAuxId As Integer = GDB_ID.NULL
|
||||
nAuxId = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(GDB_ID.ROOT), "AUX")
|
||||
EgtSetStatus(nAuxId, GDB_ST.OFF)
|
||||
' se lama devo ruotare -90 deg attorno a Z+
|
||||
If m_Type = MCH_TY.SAW_STD Or m_Type = MCH_TY.SAW_FLAT Then
|
||||
EgtRotate(EgtGetFirstGroupInGroup(GDB_ID.ROOT), Point3d.ORIG(), Vector3d.Z_AX(), -90, GDB_RT.GLOB)
|
||||
End If
|
||||
' salvo il modello
|
||||
Dim z = EgtGetCurrentContext()
|
||||
Dim bOk As Boolean = EgtSaveFile(sPath, NGE.CMPTEXT)
|
||||
Dim e = EgtGetCurrentContext()
|
||||
' eseguo controrotazione per lama
|
||||
If m_Type = MCH_TY.SAW_STD Or m_Type = MCH_TY.SAW_FLAT Then
|
||||
EgtRotate(EgtGetFirstGroupInGroup(GDB_ID.ROOT), Point3d.ORIG(), Vector3d.Z_AX(), 90, GDB_RT.GLOB)
|
||||
End If
|
||||
' ripristino visualizzazione layer aux
|
||||
EgtSetStatus(nAuxId, GDB_ST.ON_)
|
||||
' salvo nome del disegno utensile
|
||||
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
||||
EgtTdbSetCurrToolParam(MCH_TP.DRAW, sDrawName)
|
||||
EgtTdbSaveCurrTool()
|
||||
Return bOk
|
||||
End If
|
||||
Return False
|
||||
' Imposto dati per salvataggio utensile
|
||||
ToolDraw.nToolContext = IniFile.m_ToolsDbSceneContext
|
||||
ToolDraw.nType = m_Type
|
||||
' Eseguo salvataggio
|
||||
Dim sName As String = Uuid & ".nge"
|
||||
If Not ToolDraw.Save(sName) Then Return False
|
||||
' Salvo nome del disegno utensile
|
||||
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
||||
EgtTdbSetCurrToolParam(MCH_TP.DRAW, sName)
|
||||
EgtTdbSaveCurrTool()
|
||||
Return True
|
||||
End Function
|
||||
|
||||
#End Region ' ToolSceneUpdate
|
||||
@@ -1797,46 +1655,39 @@ Public Class ToolTreeViewItem
|
||||
|
||||
Private Function ValidateDraw() As Boolean
|
||||
m_DrawError = String.Empty
|
||||
If m_bDrawNameError Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 2)
|
||||
End If
|
||||
If m_bDrawNameExistError Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 3)
|
||||
End If
|
||||
If m_bToolMakerError Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 4)
|
||||
End If
|
||||
If m_nDrawingError = 12 Then
|
||||
If m_nDrawingError = 5 Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 2) ' Il file deve essere .nge
|
||||
ElseIf m_nDrawingError = 6 Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 3) ' Il file non esiste
|
||||
ElseIf m_nDrawingError = 1 Or m_nDrawingError = 2 Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 4) ' Non esiste il ToolMaker per questo tipo di utensile
|
||||
ElseIf m_nDrawingError = 12 Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 21) ' Utensile troppo corto con il portautensile
|
||||
ElseIf m_nDrawingError = 13 Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 31)
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 31) ' Lo Spessore deve essere differente da 0
|
||||
ElseIf m_nDrawingError = 14 Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 32)
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 32) ' L'Angolo di Lato deve essere inferiore di 90
|
||||
ElseIf m_nDrawingError = 15 Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 33)
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 33) ' L'Angolo di Lato deve essere maggiore di -90
|
||||
ElseIf m_nDrawingError = 16 Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 35)
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 35) ' Raggio Corner ha un valore troppo grande
|
||||
ElseIf m_nDrawingError = 17 Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 36)
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 36) ' Lo Spessore ha un valore troppo piccolo rispetto al Raggio Corne
|
||||
ElseIf m_nDrawingError = 18 Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 37)
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 37) ' Il diametro risultante supera il Diametro Totale
|
||||
ElseIf m_nDrawingError = 19 Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 38)
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 38) ' Il diametro risultante è minore di 0
|
||||
ElseIf m_nDrawingError = 20 Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 39)
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 39) ' Il diametro stelo risultante è minore o uguale a 0
|
||||
ElseIf m_nDrawingError = 21 Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 40)
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 40) ' Il Massimo Materiale deve essere più grande del Raggio Corner
|
||||
ElseIf m_nDrawingError = 22 Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 34)
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 34) ' La Lunghezza Totale deve essere maggiore di Lunghezza + Spessore
|
||||
ElseIf m_nDrawingError <> 0 Then
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 5)
|
||||
m_DrawError = EgtMsg(MSG_TOOLSERRORS + 5) ' Impossibile creare l'utensile con questi parametri
|
||||
End If
|
||||
NotifyPropertyChanged("DrawErrorMsg")
|
||||
If String.IsNullOrEmpty(m_DrawError) Then
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
Return String.IsNullOrEmpty(m_DrawError)
|
||||
End Function
|
||||
|
||||
Private Function ValidateSelectedHead() As Boolean
|
||||
|
||||
Reference in New Issue
Block a user