diff --git a/EgtInterface.vb b/EgtInterface.vb index 5d9ad62..a738015 100644 --- a/EgtInterface.vb +++ b/EgtInterface.vb @@ -6,6 +6,14 @@ Structure Point3d Dim x, y, z As Double End Structure +Structure Vector3d + Dim x, y, z As Double +End Structure + +Structure Color + Dim R, G, B, A As Integer +End Structure + #If PLATFORM = "x64" Then #If DEBUG Then Const EgtIntDll As String = "EgtInterfaceD64.dll" @@ -351,17 +359,42 @@ Public Shared Function EgtUnProjectPoint(ByVal nCtx As Integer, ByVal Curr As Po End Function -'TscExecutor +'Tsc Executor Public Shared Function EgtInitTscExec(ByVal nCtx As Integer) As Boolean End Function -Public Shared Function EgtTscFileExec(ByVal nCtx As Integer, ByVal sFilePath As String) As Boolean +Public Shared Function EgtTscExecFile(ByVal nCtx As Integer, ByVal sFilePath As String) As Boolean End Function -Public Shared Function EgtTscLineExec(ByVal nCtx As Integer, ByVal sLine As String) As Boolean +Public Shared Function EgtTscExecLine(ByVal nCtx As Integer, ByVal sLine As String) As Boolean +End Function + + +'LUA Executor + +Public Shared Function EgtLuaSetContext(ByVal nCtx As Integer) As Boolean +End Function + + +Public Shared Function EgtLuaExecFile(ByVal sFilePath As String) As Boolean +End Function + + +Public Shared Function EgtLuaExecLine(ByVal sLine As String) As Boolean +End Function + + +Private Shared Function EgtLuaGetLastError(ByRef psError As IntPtr) As Boolean +End Function +Public Shared Function EgtLuaGetLastError(ByRef sError As String) As Boolean + Dim psError As IntPtr + Dim bOk As Boolean = EgtLuaGetLastError(psError) + sError = Marshal.PtrToStringUni(psError) + EgtFreeMemory(psError) + Return bOk End Function diff --git a/Form1.vb b/Form1.vb index 27f09d2..c9b11a7 100644 --- a/Form1.vb +++ b/Form1.vb @@ -228,7 +228,7 @@ Public Class Form1 ' ripristino stato oggetto marcato Dim nIdOld As Integer = RevertOldIdInObjTree() ' eseguo comando - If EgtTscLineExec(Scene1.GetCtx, sCmd) Then + If EgtTscExecLine(Scene1.GetCtx, sCmd) Then Scene1.Invalidate() ToolStripStatusLabel3.Text = " " Else diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index fffc2e2..a2dbd9e 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -43,5 +43,5 @@ Imports System.Runtime.InteropServices ' utilizzando l'asterisco (*) come descritto di seguito: ' - - + + diff --git a/Scene.vb b/Scene.vb index 46a3007..fca971a 100644 --- a/Scene.vb +++ b/Scene.vb @@ -1,4 +1,5 @@ Imports System.Math +Imports System.IO Imports System.Globalization Imports TestEIn.EgtInterface @@ -386,22 +387,38 @@ Public Class Scene Public Function Exec() 'Scelta file con dialogo Dim OpenFileDialog As New OpenFileDialog - OpenFileDialog.Title = "Exec TSC" - OpenFileDialog.Filter = "Test commands(*.tsc)|*.tsc" - OpenFileDialog.FilterIndex = 1 + OpenFileDialog.Title = "Exec Script" + OpenFileDialog.Filter = "Lua commands(*.lua)|*.lua" & + "|Test commands(*.tsc)|*.tsc" & + "|All Files (*.*)|*.*" If OpenFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then Return True End If + 'Ne verifico il tipo + Dim sExt As String = UCase(Path.GetExtension(OpenFileDialog.FileName)) + If (sExt <> ".LUA" And sExt <> ".TSC") Then + MessageBox.Show("Script type unknow", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) + Return False + End If 'Prima dell'esecuzione RaiseEvent OnExecutingScript(Me, OpenFileDialog.FileName) 'Esecuzione Cursor = Cursors.WaitCursor - Dim bOk As Boolean = EgtTscFileExec(m_nGseContext, OpenFileDialog.FileName) + Dim bOk As Boolean = False + If (sExt = ".LUA") Then + bOk = EgtLuaExecFile(OpenFileDialog.FileName) + Else + bOk = EgtTscExecFile(m_nGseContext, OpenFileDialog.FileName) + End If EgtZoom(m_nGseContext, ZM_ALL) Cursor = Cursors.Default 'Gestione risultato If bOk Then RaiseEvent OnExecutedScript(Me) + ElseIf (sExt = ".LUA") Then + Dim sError As String = String.Empty + EgtLuaGetLastError(sError) + MessageBox.Show(sError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Else MessageBox.Show("Error executing file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End If