DIAdem Help

Content Type
Programming Language
Current manual

Create MathScript

Create MathScript

Use MathScripts to integrate MathScript functions from LabVIEW into DIAdem ANALYSIS. To execute MathScripts, you must have LabVIEW Version 8.0 or a later version, with the MathScript option, installed on your computer.

From DIAdem 2015, MathScript is no longer available in the DIAdem ANALYSIS menu. In order to create the menu item MathScript and the submenus Run and Edit in DIAdem ANALYSIS which the MathScript file Calculate3DSpiral uses in the CommonDocumentsPath folder, execute the following script in DIAdem SCRIPT.

VBScriptPython

 

Dim ProjectPath: ProjectPath = CommonDocumentsPath & "Documents\"
const ProjectFile = "Calculate3DSpiral"    ' MSC file name without filename extension
const ProjectName = "MyProject"
'-------------------------------------------------------------------------------
function CreateMathScriptMenu(sgID, sgCaption, oParentBar)
  ' Create ActionObject for menu bar
  dim oActObj  
  if (BarManager.ActionObjs.Exists(sgID)) then
    set oActObj = BarManager.ActionObjs(sgID)
  else
    set oActObj = BarManager.ActionObjs.Add(sgID, "CustomPopup")
    oActObj.BarID = sgID
    oActObj.Caption = sgCaption
  end if
  if not (oParentBar.UsedActionObjs.Exists(sgID)) then
    call oParentBar.UsedActionObjs.Add(sgID)
  end if
  
  ' Create menu bar
  dim oBar
  if (BarManager.Bars.Exists(sgID)) then
    set oBar = BarManager.Bars(sgID)
  else
    set oBar = BarManager.Bars.Add(sgID)
    oBar.Style = eBarStyleIconCaption
    oBar.ActionObjPictureWidth = 16
    oBar.ActionObjPictureHeight = 16
  end if
  
  set CreateMathScriptMenu = oBar
end function

'-------------------------------------------------------------------------------
function CreateProjectMenuItem(sgID, sgCaption, oBar) 
  dim oActObj
  if (BarManager.ActionObjs.Exists(sgID)) then
    set oActObj = BarManager.ActionObjs(sgID)
  else
    set oActObj = BarManager.ActionObjs.Add(sgID, "CustomButton")
    oActObj.Caption = sgCaption
  end if
  if (not oBar.UsedActionObjs.Exists(oActObj)) then
    call oBar.UsedActionObjs.Add(oActObj)
  end if
  set CreateProjectMenuItem = oActObj
end function

'-------------------------------------------------------------------------------
' Main
'-------------------------------------------------------------------------------

dim oMenuItem, oMathScriptBar, oProjectBar

' Create MathScript menu bar
set oMathScriptBar = CreateMathScriptMenu("MyMathScriptMenu", "MathScript", BarManager.Bars("ANAMenuMain"))

' Create menu bar for MathScript Project1
set oProjectBar = CreateMathScriptMenu("MyMathScriptProject1Menu", ProjectName, oMathScriptBar)

' Create menu item "Run" for MathScript Project1
set oMenuItem = CreateProjectMenuItem(ProjectName & "Run", "Run", oProjectBar)
oMenuItem.OnClickCode.Code = "call GetMathScript.RunMathScript(""" & ProjectPath & """,""" & ProjectFile & """)"
' Create menu item "Edit" for MathScript Project1
set oMenuItem = CreateProjectMenuItem(ProjectName & "Edit", "Edit", oProjectBar)
oMenuItem.OnClickCode.Code = "call GetMathScript.EditMathScript(""" & ProjectPath & """,""" & ProjectFile & """)"

Further Settings

Create MathScript Menu | Define MathScript | Execute MathScript

In This Section
Was this information helpful?