### DIAdem Installation Guide Source: https://www.ni.com/docs/en-US/bundle/diadem/page/reportapi/properties/report_property_axissystem_irepcustomscalingaxissystem2dscaledcontextint.htm Instructions for installing DIAdem. ```APIDOC ## Installing DIAdem ### Description This section provides guidance on the installation process for DIAdem. ### Installation Steps - Refer to the official DIAdem installation documentation for detailed steps. ``` -------------------------------- ### Installation Guide Source: https://www.ni.com/docs/en-US/bundle/diadem/page/reportapi/properties/report_property_fromchannel_irepd3labeladditionalint.htm Information regarding the installation process for DIAdem. ```APIDOC ## Installing DIAdem ### Description Provides guidance on how to install DIAdem. ### Content - **Installing DIAdem**: Steps and information for installation. ``` -------------------------------- ### Load 2D Table with Channel Transformation Example Files Source: https://www.ni.com/docs/en-US/bundle/diadem/page/exploff/examples/2d_tabchanneltransformation_2.htm The example consists of a main script, user commands, a layout, and data. Note that starting this example will overwrite current DIAdem data and layouts. ```VBScript 2D_TabChannelTransformation_Main.vbs ``` ```VBScript 2D_TabChannelTransformation_UCMD.vbs ``` -------------------------------- ### Creating a video area and assigning a channel Source: https://www.ni.com/docs/en-US/bundle/diadem/page/scriptview/properties/view_property_channelname_itovideoint.htm Example demonstrating how to initialize a video area and configure it to use a specific video channel. ```VBScript Dim oMySheet, oMyObj Call View.NewLayout() Set oMySheet = View.ActiveSheet oMySheet.ActiveArea.DisplayObjType = "Video" Set oMyObj = oMySheet.ActiveArea.DisplayObj oMyObj.VideoSourceMode = eVideoChannel oMyObj.ChannelName = "[1]/Video_Channel" oMyObj.FrameRate = 50 oMyObj.Sound = True ``` ```Python dd.View.NewLayout() oMySheet = dd.View.ActiveSheet oMySheet.ActiveArea.DisplayObjType = "Video" oMyObj = oMySheet.ActiveArea.DisplayObj oMyObj.VideoSourceMode = dd.eVideoChannel oMyObj.ChannelName = "[1]/Video_Channel" oMyObj.FrameRate = 50 oMyObj.Sound = True ``` -------------------------------- ### Creating and Executing a Search Query Source: https://www.ni.com/docs/en-US/bundle/diadem/page/scriptnavi/properties/navigator_property_logic_itdmdatastoreconditions.htm Example demonstrating how to connect to a DataStore, define search conditions, set the logic, and execute the search. ```VBScript Dim oMyConditions, oMyDataStore, oMyQuery, oMyResults Set oMyDataStore = Navigator.ConnectDataStore("ASAM Browse Settings Example") Set oMyQuery = oMyDataStore.CreateQuery() oMyQuery.ReturnType = "Measurement" Set oMyConditions = oMyQuery.Conditions Call oMyConditions.Add("Measurement","Name","=","Test Data") oMyConditions.Logic = "C1" Call oMyDataStore.SearchElements(oMyQuery) Set oMyResults = oMyDataStore.ResultsElements ``` ```Python oMyDataStore = dd.Navigator.ConnectDataStore("ASAM Browse Settings Example") oMyQuery = oMyDataStore.CreateQuery() oMyQuery.ReturnType = "Measurement" oMyConditions = oMyQuery.Conditions oMyConditions.Add("Measurement","Name","=","Test Data") oMyConditions.Logic = "C1" oMyDataStore.SearchElements(oMyQuery) oMyResults = oMyDataStore.ResultsElements ``` -------------------------------- ### Creating a Video Area and Assigning a Video Channel Source: https://www.ni.com/docs/en-US/bundle/diadem/page/scriptview/properties/view_property_videosourcemode_itovideoint.htm Example demonstrating how to initialize a video area and configure its source mode using VBScript and Python. ```VBScript Dim oMySheet, oMyObj Call View.NewLayout() Set oMySheet = View.ActiveSheet oMySheet.ActiveArea.DisplayObjType = "Video" Set oMyObj = oMySheet.ActiveArea.DisplayObj oMyObj.VideoSourceMode = eVideoFile oMyObj.FileName = ProgramDrv & "Examples\Documents\Plate.avi" oMyObj.FrameRate = 50 oMyObj.Sound = True ``` ```Python dd.View.NewLayout() oMySheet = dd.View.ActiveSheet oMySheet.ActiveArea.DisplayObjType = "Video" oMyObj = oMySheet.ActiveArea.DisplayObj oMyObj.VideoSourceMode = dd.eVideoFile oMyObj.FileName = dd.ProgramDrv + "Examples\\Documents\\Plate.avi" oMyObj.FrameRate = 50 oMyObj.Sound = True ``` -------------------------------- ### DIAdem Installation Guide Source: https://www.ni.com/docs/en-US/bundle/diadem/page/reportapi/properties/report_property_extensions_irepd3shapeobjvectorint.htm Information regarding the installation process for DIAdem. ```APIDOC ## Installing DIAdem ### Description Information regarding the installation process for DIAdem. ``` -------------------------------- ### Example: Setting up ToolTip Events for 2D Axis Systems Source: https://www.ni.com/docs/en-US/bundle/diadem/page/reportapi/properties/report_property_position_ireptooltip2daxiscontextint.htm This example demonstrates how to create a 2D axis system, assign data to it, and set up a user command to handle tooltip events when the shift key is pressed and the mouse moves over the axis system. ```APIDOC ## Example: Setting up ToolTip Events for 2D Axis Systems ### Description This script creates a 2D axis system, loads data, configures the axis limits, adds a curve, and assigns a user-defined event handler ('MyToolTipEvent') to the `OnAxisSystem2D` property for `ToolTipEvents`. This allows custom tooltip behavior when interacting with the 2D axis system. ### Method N/A (Script Execution) ### Endpoint N/A (Script Execution) ### Parameters None ### Request Example ```vb.net Dim oMy2DAxisSystem, oMyPos, oMy2DCurve Call Report.NewLayout() Call Data.Root.Clear() Call DataFileLoad(DataReadPath & "Report_Data.tdm","TDM","") Set oMy2DAxisSystem = Report.ActiveSheet.Objects.Add(eReportObject2DAxisSystem, "My2DAxisSystem") Set oMyPos = oMy2DAxisSystem.Position.ByCoordinate oMyPos.X1 = 20 oMyPos.X2 = 80 oMyPos.Y1 = 20 oMyPos.Y2 = 80 Set oMy2DCurve = oMy2DaxisSystem.Curves2D.Add(e2DShapeLine, "My2DCurve") oMy2DCurve.Shape.XChannel.Reference = "[6]/[1]" oMy2DCurve.Shape.YChannel.Reference = "[6]/[4]" 'This event will be raised if the mouse is moved AND the shift key pressed Report.Events.ToolTip.OnAxisSystem2D = "MyToolTipEvent" Call Report.Refresh() ``` ### Response N/A (Script Execution) ### Error Handling Ensure the `Report_Data.tdm` file exists and the specified channels are valid. Register `MyToolTipEvent` as a user command. ``` -------------------------------- ### Check and Start Excel Application Source: https://www.ni.com/docs/en-US/bundle/diadem/page/vbs/methods/vbs_method_getobject_globalobj.htm Example demonstrating how to check if Excel is running and start it if it is not, using GetObject. ```VBS Dim MyObj On Error Resume Next Set MyObj = GetObject(,"Excel.Application") If Err.Number = 0 Then Call MsgBox("Excel is running") Else Err.Clear() Call MsgBox("Excel is not running. Excel will be started.") Set MyObj = GetObject("","Excel.Application") End If On Error Goto 0 MyObj.Visible = True Call MyObj.Workbooks.Open(ProgramDrv & "Examples\Data\DIADEM.XLS") ``` -------------------------------- ### Get Channel Number using FCNo in VBScript Source: https://www.ni.com/docs/en-US/bundle/diadem/page/functions/functions/fcno.htm Use this VBScript snippet to load an external file header and determine the channel number of a specific data channel using the FCNo function. The second example shows how FCNo returns 0 if the channel is not found after a specified starting point. ```VBScript Dim intMyResult Call HdLoad ("Auto1.dat") intMyResult = FCNo("Frequency") 'intMyResult = 3 intMyResult = FCNo("Frequency",4) 'intMyResult = 0 ``` -------------------------------- ### Load Example Files into DIAdem Source: https://www.ni.com/docs/en-US/bundle/diadem/page/exploff/examples/datafinderusedinsud_2.htm Lists the primary files required to run the search and evaluation example in DIAdem. ```text DataFinderUsedInSUD.vbs | Script file ``` ```text DataFinderUsedInSUD.sud | Dialog box file ``` ```text DataFinderUsedInSUD.tdr | Layout file ``` -------------------------------- ### Set Folder Attributes Example Source: https://www.ni.com/docs/en-US/bundle/diadem-api-ref/page/comoff/folderattrset.htm Examples showing how to enable read-only protection for subfolders starting with 'L' in the script path. ```VBScript Call FolderAttrSet(ScriptReadPath & "L*", "faReadOnly") ``` ```Python dd.FolderAttrSet(dd.ScriptReadPath + "L*", "faReadOnly") ``` -------------------------------- ### Creating an Orbit Axis System with Decorations Source: https://www.ni.com/docs/en-US/bundle/diadem/page/scriptview/properties/view_property_decorations_itoorbitchartint.htm Examples demonstrating how to initialize an orbit axis system and add a text decoration. ```VBScript Dim oMyCurve, oMyChart, oMyDecoration View.Sheets(1).Areas(1).DisplayObjType = "Orbit" Set oMyChart = View.Sheets(1).Areas(1).DisplayObj Set oMyCurve = oMyChart.CurvesOrbit.Add("[1]/[1]","[1]/[2]") Set oMyDecoration = oMyChart.Decorations.Add(eVIEWDecorationTypeText,"Decoration") oMyDecoration.Text = "DecorationText" oMyDecoration.PositionHorizontal = eVIEWDecorationPosHorizontalLeft oMyDecoration.PositionVertical = eVIEWDecorationPosVerticalTop ``` ```Python View.Sheets(1).Areas(1).DisplayObjType = "Orbit" oMyChart = dd.View.Sheets(1).Areas(1).DisplayObj oMyCurve = oMyChart.CurvesOrbit.Add("[1]/[1]","[1]/[2]") oMyDecoration = oMyChart.Decorations.Add(dd.eVIEWDecorationTypeText,"Decoration") oMyDecoration.Text = "DecorationText" oMyDecoration.PositionHorizontal = dd.eVIEWDecorationPosHorizontalLeft oMyDecoration.PositionVertical = dd.eVIEWDecorationPosVerticalTop ``` -------------------------------- ### Creating and Populating a Channel Source: https://www.ni.com/docs/en-US/bundle/diadem/page/dataplugin/properties/dataplugin_property_values_ichannel.htm Example demonstrating how to create a new channel group and channel, then populate it with 100 values using a loop. ```VBScript Dim oGrp : Set oGrp = Root.ChannelGroups.Add("MyChnGroup") Dim oMyChn : Set oMyChn = oGrp.Channels.Add("MyChannel", eR32) Dim i For i = 1 to 100 oMyChn.Values(i) = CDbl(i/100000) Next ``` -------------------------------- ### Get 3DCurve Names in DIAdem REPORT (VBScript) Source: https://www.ni.com/docs/en-US/bundle/diadem/page/reportapi/properties/report_property_name_irepd3curveint.htm This VBScript example iterates through all objects on the active report sheet, identifies 3D axis systems, and then retrieves and displays the names of all curves associated with each 3D axis system. It requires no special setup beyond having a report sheet with 3D axis systems and curves. ```VBScript Dim oMyReportObj, oMyReportObjects, oMyCurve, sOutput sOutput = "" Set oMyReportObjects = Report.ActiveSheet.Objects For Each oMyReportObj in oMyReportObjects If oMyReportObj.ObjectType = eReportObject3DAxisSystem Then For Each oMyCurve in oMyReportObj.Curves3D sOutput = sOutput & "Object " & oMyCurve.Name & vbCrLf Next End If Next Call MsgBoxDisp(sOutput) ``` -------------------------------- ### Replace Method Usage Examples Source: https://www.ni.com/docs/en-US/bundle/diadem/page/vbs/methods/vbs_method_replace_globalobj.htm Examples demonstrating text replacement with different parameters, including case-insensitive comparisons and start position offsets. ```VBS MyResult = Replace("ABC123abc", "abc", "def") Call MsgBox(MyResult) ' Returns ABC123def MyResult = Replace("ABC123abc", "abc", "def", 1, -1, vbTextCompare) Call MsgBox(MyResult) ' Returns def123def MyResult = Replace("ABC123abc", "abc", "def",4) Call MsgBox(MyResult) ' Returns 123def ``` -------------------------------- ### Create a FileSystemObject Source: https://www.ni.com/docs/en-US/bundle/diadem/page/vbs/methods/vbs_method_createobject_globalobj.htm Example demonstrating how to instantiate a FileSystemObject to access the local file system. ```VBS Dim fso Set fso = CreateObject("Scripting.FileSystemObject") ``` -------------------------------- ### Creating a Square Frame with Shadow Source: https://www.ni.com/docs/en-US/bundle/diadem/page/reportapi/properties/report_property_forcesquare_irepfreeframeint.htm Example demonstrating how to create a frame, set it to square, and apply styling properties like color, border, and shadow. ```VBScript Dim oMyFrame, oMyBackgroundColor, oMyPosition, oMyBorderLine, oMyShadow Call Report.NewLayout() Set oMyFrame = Report.ActiveSheet.Objects.Add(eReportObjectFrame,"MyFrame") oMyFrame.ForceSquare = True Set oMyBackgroundColor = oMyFrame.BackgroundColor Call oMyBackgroundColor.SetPredefinedColor(eColorIndexRed ) Set oMyPosition = oMyFrame.Position.ByCoordinate oMyPosition.X1 = 10 oMyPosition.X2 = 40 oMyPosition.Y1 = 50 oMyPosition.Y2 = 80 Set oMyBorderLine = oMyFrame.BorderLine Call oMyBorderLine.Color.SetPredefinedColor(eColorIndexGreen) oMyBorderLine.LineType = eLineTypeDotted oMyBorderLine.Width = eLineWidth0140 Set oMyShadow = oMyFrame.Shadow Call oMyShadow.Color.SetPredefinedColor(eColorIndexBlue) oMyShadow.Direction = eShadowDirectionLeftBottom oMyShadow.OffsetX = 1 oMyShadow.OffsetY = 2 Call Report.Refresh() ``` ```Python dd.Report.NewLayout() oMyFrame = dd.Report.ActiveSheet.Objects.Add(dd.eReportObjectFrame,"MyFrame") oMyFrame.ForceSquare = True oMyBackgroundColor = oMyFrame.BackgroundColor oMyBackgroundColor.SetPredefinedColor(dd.eColorIndexRed ) oMyPosition = oMyFrame.Position.ByCoordinate oMyPosition.X1 = 10 oMyPosition.X2 = 40 oMyPosition.Y1 = 50 oMyPosition.Y2 = 80 oMyBorderLine = oMyFrame.BorderLine oMyBorderLine.Color.SetPredefinedColor(dd.eColorIndexGreen) oMyBorderLine.LineType = dd.eLineTypeDotted oMyBorderLine.Width = dd.eLineWidth0140 oMyShadow = oMyFrame.Shadow oMyShadow.Color.SetPredefinedColor(dd.eColorIndexBlue) oMyShadow.Direction = dd.eShadowDirectionLeftBottom oMyShadow.OffsetX = 1 oMyShadow.OffsetY = 2 dd.Report.Refresh() ``` -------------------------------- ### Empty Script Example Source: https://www.ni.com/docs/en-US/bundle/diadem/page/sudref/events/sud_event_eventdrop_tree.htm This is an empty script example provided in the documentation. It serves as a placeholder or a starting point for custom scripting related to the EventDrop event. ```Visual Basic   ``` -------------------------------- ### Example: Create Temporary Folder and Import Data Source: https://www.ni.com/docs/en-US/bundle/diadem/page/dataplugin/methods/dataplugin_method_createfolder_iautoremove.htm This example demonstrates creating a temporary folder using AutoRemove.CreateFolder(), unzipping a file into it using Unzip(), and then importing data from the first file in the archive using Root.ImportStore(). ```DIAdem Script Sub ReadStore(FileName) Dim TempFolder TempFolder = AutoRemove.CreateFolder() Dim FileList FileList = Unzip(FileName, TempFolder) Call Root.ImportStore(TempFolder & FileList(0), "ATFX") End Sub ``` -------------------------------- ### Worker Management and Execution Example Source: https://www.ni.com/docs/en-US/bundle/diadem/page/parallelprocesscontrol/methods/parallelprocesscontrol_method_remove_iworkers.htm Example script demonstrating how to start multiple Worker objects, set their arguments, and manage their removal based on their running status. ```APIDOC ## Worker Management and Execution Example ### Description This script demonstrates starting multiple Worker objects, assigning them tasks, and then removing workers that are no longer running. It also sets up callbacks for state changes. ### Method N/A (Script Example) ### Endpoint N/A (Script Example) ### Request Example ```javascript Dim i, oMyWorker, MyArgArray(2) Call Data.Root.Clear() Call DataFileLoad("Example.tdm","TDM","") Call ScriptCmdAdd(CurrentScriptPath & "Callback.vbs") ParallelProcessControl.OnWorkerStateChange = "CheckState" For i= 1 to Data.Root.ChannelGroups(2).Channels.Count Set oMyWorker = ParallelProcessControl.Workers.Add(i,true,"") MyArgArray(0) = ChannelsToArray("[2]/[" & i & "]") MyArgArray(1) = i MyArgArray(2) = 50 oMyWorker.SetArgument(MyArgArray) Call oMyWorker.Run(CurrentScriptPath & "WorkerScript.vbs","CallbackFct") Next For i = 1 to ParallelProcessControl.Workers.Count If Not ParallelProcessControl.Workers.Item(i).IsRunning Then ParallelProcessControl.Workers.Remove(i) End If Call Pause(0.1) Next ``` ``` -------------------------------- ### Using AddExisting for Temporary Folder Cleanup Source: https://www.ni.com/docs/en-US/bundle/diadem/page/dataplugin/methods/dataplugin_method_addexisting_iautoremove.htm Example demonstrating the creation of a temporary folder, unzipping files, importing data, and scheduling the folder for deletion. ```Visual Basic Sub ReadStore(FileName) Dim TempFolder TempFolder = AutoRemove.CreateFolder() Dim FileList FileList = Unzip(FileName, TempFolder) Call Root.ImportStore(TempFolder & FileList(0), "ATFX") 'further instructions Call AutoRemove.AddExisting("C:\Temp\") End Sub ``` -------------------------------- ### Collection: Elements - Python Example Source: https://www.ni.com/docs/en-US/bundle/diadem/page/scriptnavi/objects/navigator_objects_itdmstoreelements_5.htm This Python example shows how to connect to a data store, get the children of the first root element, and print their names. ```APIDOC ## Python Example for Collection: Elements ### Description This Python script connects to a data store, retrieves the children of the first root element, and then prints the name of each child element. ### Method ```python oMyDataStore = dd.NAVIGATOR.ConnectDataStore("ASAM Browse Settings Example") oMyRootElement = oMyDataStore.RootElements(1) oMyElements = oMyRootElement.Children for Element in oMyElements: Output = Output + "\r\n" + Element.Name dd.MsgBoxDisp("Name of children elements: " + Output) ``` ### Endpoint Not applicable (this is a script example for an object model). ``` -------------------------------- ### Object: Cell - VBScript Example Source: https://www.ni.com/docs/en-US/bundle/diadem/page/scriptnavi/objects/navigator_objects_itdmcell_1.htm This VBScript example demonstrates how to get the focused cell from the DataFinder's results list and output the name of its related element. ```APIDOC ## VBScript Example for Object: Cell ### Description Assigns the cell of the search results list, which currently has the focus, to the oMyCell object and then outputs the name of the related element. ### Method Not Applicable (Scripting) ### Endpoint Not Applicable (Scripting) ### Request Body Not Applicable ### Response Outputs the element name via MsgBoxDisp. ### Request Example ```vbscript Dim oMyResultsList, oMyCell, oMyElementVal, oMyText Set oMyResultsList = Navigator.Display.CurrDataFinder.ResultsList Set oMyCell = oMyResultsList.FocusedCell Call MsgBoxDisp(oMyCell.Element.Name) ``` ``` -------------------------------- ### Example: Running Worker Scripts Source: https://www.ni.com/docs/en-US/bundle/diadem/page/parallelprocesscontrol/properties/parallelprocesscontrol_property_id_ilocalworker.htm This example demonstrates how to start multiple Worker objects, execute a script on each, and handle callbacks and state changes. It utilizes the LocalWorker.ID to differentiate workers. ```APIDOC ## Example Script: Running Worker Scripts ### Description This script starts five Worker objects, each executing `WorkerScript.vbs`. It sets up callbacks and state change handling. The `LocalWorker.ID` is implicitly used by the system to manage these workers. ### Request Example ```vbscript Dim i, oMyWorker, MyArgArray(2) Call Data.Root.Clear() Call DataFileLoad("Example.tdm","TDM","") Call ScriptCmdAdd(CurrentScriptPath & "Callback.vbs") ParallelProcessControl.OnWorkerStateChange = "CheckState" For i= 1 to Data.Root.ChannelGroups(2).Channels.Count Set oMyWorker = ParallelProcessControl.Workers.Add(i,true,"") MyArgArray(0) = ChannelsToArray("[2]/[" & i & "]") MyArgArray(1) = i MyArgArray(2) = 50 oMyWorker.SetArgument(MyArgArray) Call oMyWorker.Run(CurrentScriptPath & "WorkerScript.vbs","CallbackFct") Next Do Call Pause(0.1) Loop Until ParallelProcessControl.Workers.RunningWorkersCount < 1 Call ParallelProcessControl.Workers.RemoveAll() ``` ``` -------------------------------- ### Example: Creating a Map Display (Python) Source: https://www.ni.com/docs/en-US/bundle/diadem/page/scriptview/objects/view_objects_itomapdisplayint_1.htm This Python example demonstrates how to create and configure a map display in DIAdem VIEW. ```APIDOC ## Python Example: Creating a Map Display ### Description This Python script creates a new layout in DIAdem VIEW, sets the active area's display object type to 'Map', and configures various properties of the Map object, including map type, zoom level, and synchronization channels. ### Code ```python dd.Data.Root.Clear() dd.DataFileLoad(dd.ProgramDrv + "Examples\\Data\\VIEW_MapDisplay.tdm") dd.View.Sheets.RemoveAll() dd.View.NewLayout() oMySheet = dd.View.ActiveSheet oMySheet.ActiveArea.DisplayObjType = "Map" oMyObj = oMySheet.ActiveArea.DisplayObj oMyObj.MapType = "OSM Mapnik" oMyObj.ZoomLevel = 14 oMyObj.SynchronisationChannelName = "[1]/TimeStamp" oMyObj.LongitudeChannelName = "[1]/Longitude" oMyObj.LatitudeChannelName = "[1]/Latitude" ``` ### Parameters Used - **dd.ProgramDrv**: DIAdem's program directory path. - **dd.DataFileLoad**: Function to load a data file. - **dd.View.Sheets.RemoveAll**: Removes all existing sheets. - **dd.View.NewLayout**: Creates a new layout. - **dd.View.ActiveSheet**: Gets the currently active sheet. - **ActiveArea.DisplayObjType**: Sets the display object type for the active area. - **ActiveArea.DisplayObj**: Gets the display object for the active area. - **MapType**: Sets the type of map to display. - **ZoomLevel**: Sets the zoom level of the map. - **SynchronisationChannelName**: Sets the channel for time synchronization. - **LongitudeChannelName**: Sets the channel for longitude data. - **LatitudeChannelName**: Sets the channel for latitude data. ``` -------------------------------- ### Change Text Control Color Example Source: https://www.ni.com/docs/en-US/bundle/diadem/page/sudref/methods/sud_method_getcontrol_tosudviewob.htm This example demonstrates how to get a specific text control from a dialog box and change its foreground color. Ensure the 'Text1' control exists in your dialog. ```VBScript Dim oElement oElement = Dialog.GetControl("Text1") oElement.ForeColor = RGB(255, 0, 0) ``` -------------------------------- ### Accessing Procedure Information Source: https://www.ni.com/docs/en-US/bundle/diadem/page/tdmcontext/properties/tdmcontext_property_procedure_ivbscontextasdeinit.htm This section explains how to get the Procedure object and provides an example of its usage. ```APIDOC ## Procedure: Procedure for ContextFinalize ### Description Returns an object that provides information on the procedure currently being executed. ### Method ``` Set _oProcedure_ = _Object_.**Procedure** ``` ### Object _Object_| ContextFinalize ### Returned Object _oProcedure_| Procedure ### Example Usage The following example writes the result path from the transfer parameters into the result notifications of current and completed analysis automation tasks: #### VBScript Example ```vbscript Sub On_Finalize(oContext) Dim ResultsPath ResultsPath = oContext.Procedure.Arguments.Item("ResultsPath").Value Call oContext.LogResult("Results path: " & ResultsPath) End Sub ``` #### Python Example ```python def On_Finalize(oContext): ResultsPath = oContext.Procedure.Arguments.Item("ResultsPath").Value oContext.LogResult("Results path: " + ResultsPath) ``` ``` -------------------------------- ### Example: Setting up ToolTip Event for 3D Axis System Source: https://www.ni.com/docs/en-US/bundle/diadem/page/reportapi/properties/report_property_position_ireptooltip3daxiscontextint.htm This script demonstrates how to create a 3D axis system, assign data to it, and set up a user command ('MyToolTipEvent') to handle tooltip events when the mouse hovers over the 3D axis system while the shift key is pressed. ```APIDOC ## Example: Setting up ToolTip Event for 3D Axis System ### Description This script creates a 3D axis system, configures its data channels, and assigns a custom event handler ('MyToolTipEvent') to the `OnAxisSystem3D` property for `ToolTipEvents`. This allows capturing mouse position and sub-object information when interacting with the 3D axis system under specific conditions (shift key + mouse movement). ### Method Script Execution ### Endpoint N/A (Client-side scripting) ### Parameters None ### Request Example ```vb.net Dim oMy3DAxisSystem, oMy3DCurve Call Data.Root.Clear() Call DataFileLoad(DataReadPath & "Report_Data.tdm","TDM","") Call Report.NewLayout() Set oMy3DAxisSystem = Report.ActiveSheet.Objects.Add(eReportObject3DAxisSystem,"My3DAxisSystem") Set oMy3DCurve = oMy3DAxisSystem.Curves3D.Add(e3DShapeSurface, "MyNew3DCurve") oMy3DCurve.Shape.XChannel.Reference = "[2]/[1]" oMy3DCurve.Shape.YChannel.Reference = "[2]/[2]" oMy3DCurve.Shape.ZChannel.Reference = "[2]/[3]" oMy3DCurve.Shape.DataStructure = e3DDataStructureMatrix 'This event will be raised if the mouse is moved AND the shift key pressed Report.Events.ToolTip.OnAxisSystem3D = "MyToolTipEvent" Call Report.Refresh() ``` ### Response None (This script configures an event handler and refreshes the report.) ``` -------------------------------- ### Implement Tree Initialization and Click Handling Source: https://www.ni.com/docs/en-US/bundle/diadem/page/sudref/events/sud_event_eventnodeclick.htm Example demonstrating how to initialize a tree structure and handle node click events to display the clicked node's text. ```VBScript Sub Tree1_EventInitialize(ByRef This) Call CreateDefaultTree(This) End Sub Sub Tree1_EventNodeClick(ByRef This, ByRef Node) Call MsgBox(Node.Text & " clicked") End Sub Sub CreateDefaultTree(ByRef This) Dim oRoot, oMainNode Set oRoot = This.Nodes.Add("Tools") oRoot.Key = "tools" oRoot.Expanded = true Set oMainNode = oRoot.Nodes.Add("Electric Tools") oMainNode.Key = "electric" oMainNode.Nodes.Add("Drill").Key = "drill" oMainNode.Nodes.Add("Saw").Key = "saw" Set oMainNode = oRoot.Nodes.Add("Hand Tools") oMainNode.Key = "handtool" oMainNode.Nodes.Add("Hammer").Key = "hammer" oMainNode.Nodes.Add("Screwdriver").Key = "screwdriver" oMainNode.Nodes.Add("Tongs").Key = "tongs" End Sub ``` -------------------------------- ### Get Dialog Box Layer for XTable1 Source: https://www.ni.com/docs/en-US/bundle/diadem/page/sudref/methods/sud_method_layername_tovirtgridctrl.htm This example shows how to get the dialog box layer associated with the XTable1 selection list. Ensure the XTable1 control is present in your dialog box. ```DIAdem Script Dialog.Layers(XTable1.LayerName) = TRUE ``` -------------------------------- ### Get Dialog Box Layer for Text Control Source: https://www.ni.com/docs/en-US/bundle/diadem/page/sudref/methods/sud_method_layername_tostaticctrlrt.htm Use this example to get the dialog box layer associated with a specific text control. Ensure the text control name is correctly referenced. ```VBScript Dialog.Layers(Text1.LayerName) = TRUE ``` -------------------------------- ### Example: Setting up and Handling ToolTip3DTableContext Events Source: https://www.ni.com/docs/en-US/bundle/diadem/page/reportapi/properties/report_property_position_ireptooltip3dtablecontextint.htm Demonstrates how to create a 3D table, assign a user command to handle ToolTip events, and the VBScript for the user command itself. ```APIDOC ## Example: ToolTip3DTableContext Event Handling ### Description This example script demonstrates how to create a 3D table in DIAdem REPORT, configure its properties, and assign a user command (`MyToolTipEvent`) to the `OnTable3D` event for `ToolTipEvents`. The `MyToolTipEvent` subroutine is also provided, showing how to access the `ToolTip3DTableContext` and format a tooltip string with information about the mouse position and the subobject under the cursor. ### Method N/A (Scripting example) ### Endpoint N/A (Scripting example) ### Parameters None ### Request Example (Script Setup) ```vbscript Dim oMy3DTable, oMyPosition, oMyX, oMyY, oMyZ, oMySettings Call Data.Root.Clear() Call DataFileLoad(DataReadPath & "Report_Data.tdm","TDM","") Call Report.NewLayout() Set oMy3DTable = Report.ActiveSheet.Objects.Add(eReportObject3DTable,"My2DTable") Set oMyPosition = oMy3DTable.Position.ByBorder oMyPosition.Top = 20 oMyPosition.Bottom = 20 oMyPosition.Left = 20 oMyPosition.Right = 20 Set oMyX = oMy3DTable.X Set oMyY = oMy3DTable.Y Set oMyZ = oMy3DTable.Z Set oMySettings = oMy3DTable.Settings oMySettings.UseAutoFontSize = False oMyX.Channel.Reference = "[2]/[1]" oMyX.Font.Size = 2 oMyX.Format = "d.dd" oMyY.Channel.Reference = "[2]/[2]" oMyY.Font.Size = 2 oMyY.Format = "d.dd" oMyZ.Channel.Reference = "[2]/[3]" oMyZ.Font.Size = 2 oMyZ.Format = "d.dd" 'This event will be raised if the mouse is moved AND the shift key pressed Report.Events.ToolTip.OnTable3D = "MyToolTipEvent" Call Report.Refresh() ``` ### Request Example (User Command - MyToolTipEvent) ```vbscript Sub MyToolTipEvent(Context,ToolTipText) Dim oSubObject Set oSubObject = Context.SubObject ToolTipText = "Sheet: " & Context.Sheet.Name & VBCrLf & "Sub object" & VBCrLf & "Name: " & oSubObject.Name & VBCrLf & "Type: " & GetConstNameForREPORTSubObj(oSubObject, oSubObject.Type) ToolTipText = ToolTipText & VBCrLf & "X position: " & Context.Position.X & VBCrLf & "Y position: " & Context.Position.Y End Sub ``` ### Response #### Success Response (Tooltip Display) When the shift key is pressed and the mouse is moved over the 3D table, the tooltip will display: - Sheet Name - Sub object Name and Type - X and Y position of the mouse cursor #### Response Example (Tooltip Content) ``` Sheet: MyReportSheet Sub object Name: My2DTable Type: REPORT_OBJECT_3D_TABLE X position: 150 Y position: 220 ``` ``` -------------------------------- ### Get Character from ASCII Code (Python) Source: https://www.ni.com/docs/en-US/bundle/diadem-api-ref/page/functions/functions/char.htm Use the Char function in Python to convert an ASCII code (1-255) into its corresponding character. The example shows how to get the character for ASCII code 65. ```Python strMyResult = Char(65) #strMyResult = A ``` -------------------------------- ### Configuring a Map Display with ShowTrack Source: https://www.ni.com/docs/en-US/bundle/diadem/page/scriptview/properties/view_property_showtrack_itomapdisplayint.htm Examples demonstrating how to initialize a map display and enable the track line using VBScript and Python. ```VBScript Dim oMyObj View.ActiveSheet.ActiveArea.DisplayObjType = "Map" Set oMyObj = View.ActiveSheet.ActiveArea.DisplayObj oMyObj.MapType = "OSM Mapnik" oMyObj.SynchronisationChannelName = "[1]/TimeStamp" oMyObj.LongitudeChannelName = "[1]/Longitude" oMyObj.LatitudeChannelName = "[1]/Latitude" oMyObj.ShowTrack = TRUE ``` ```Python View.ActiveSheet.ActiveArea.DisplayObjType = "Map" oMyObj = dd.View.ActiveSheet.ActiveArea.DisplayObj oMyObj.MapType = "OSM Mapnik" oMyObj.SynchronisationChannelName = "[1]/TimeStamp" oMyObj.LongitudeChannelName = "[1]/Longitude" oMyObj.LatitudeChannelName = "[1]/Latitude" oMyObj.ShowTrack = True ``` -------------------------------- ### Method: RunInitialize for Frame Example Source: https://www.ni.com/docs/en-US/bundle/diadem/page/sudref/methods/sud_method_runinitialize_toframert.htm Example script demonstrating how to trigger the EventInitialize for a Frame control. ```APIDOC ## Method: RunInitialize for Frame ### Description Triggers the EventInitialize event for a control in user dialog boxes. ### Method POST (or equivalent action-based method) ### Endpoint `/websites/ni_en-us_bundle_diadem/frame/RunInitialize` ### Parameters (No specific parameters defined in the provided text) ### Request Body (No specific request body defined in the provided text) ### Response (No specific response defined in the provided text) ### Example Script ```vbscript Sub Frame1_EventInitialize(ByRef This) 'Do something End Sub Sub ComboBox1_EventChange(ByRef This) Call Frame1.RunInitialize End Sub ``` ### See Also Objects Overview ``` -------------------------------- ### Get Character from ASCII Code (VBScript) Source: https://www.ni.com/docs/en-US/bundle/diadem-api-ref/page/functions/functions/char.htm Use the Char function in VBScript to convert an ASCII code (1-255) into its corresponding character. The example shows how to get the character for ASCII code 65. ```VBScript Dim strMyResult strMyResult = Char(65) 'strMyResult = A ``` -------------------------------- ### SchemeMeasStart Command Source: https://www.ni.com/docs/en-US/bundle/diadem/page/comonl/opcseterraction.htm Starts a measurement with data storage and visualizes the data in DIAdem VISUAL. ```APIDOC ## SchemeMeasStart ### Description Starts a measurement with data storage and visualizes the data in DIAdem VISUAL. ### Method Command ### Endpoint SchemeMeasStart ``` -------------------------------- ### Get Condition Type in DataStore (Python) Source: https://www.ni.com/docs/en-US/bundle/diadem/page/scriptnavi/properties/navigator_property_type_itdmdatastorecondition.htm This Python example shows how to achieve the same functionality as the VBScript example: connecting to a DataStore, adding a search condition, and displaying its type using the 'dd' object. ```Python oMyStoreQuery = dd.Navigator.ConnectDataStore("ASAM Browse Settings Example").CreateQuery() oMyStoreQuery.Conditions.Add("Measurement","name","=","Car*") dd.MsgBoxDisp(oMyStoreQuery.Conditions(1).Type) ``` -------------------------------- ### DIAdem VBScript: Get Current Year Source: https://www.ni.com/docs/en-US/bundle/diadem/page/vbs/methods/vbs_method_year_globalobj.htm This example demonstrates how to use the Year function with the Now function to get the current year and display it in a message box. Ensure VBS is the active scripting language. ```Visual Basic Dim iMyYear iMyYear = Year(Now) Call MsgBox(iMyYear) ``` -------------------------------- ### Object: Video - Python Example Source: https://www.ni.com/docs/en-US/bundle/diadem/page/scriptview/objects/view_objects_itovideoint.htm This Python script example demonstrates how to load and configure a video file within a DIAdem VIEW layout. ```APIDOC ## Object: Video ### Description The Video object provides access to a video in DIAdem VIEW. You use the Video object to specify the properties of the video to be displayed. ### Method This example uses Python to display a video. ### Endpoint N/A (Scripting Object) ### Parameters N/A ### Request Example ```python dd.View.NewLayout() oMySheet = dd.View.ActiveSheet oMySheet.ActiveArea.DisplayObjType = "Video" oMyObj = oMySheet.ActiveArea.DisplayObj oMyObj.FileName = dd.ProgramDrv + "\\Examples\\Documents\\Plate.avi" oMyObj.FrameRate = 50 oMyObj.Sound = True ``` ### Response N/A (Scripting) ### Properties - **Area** (Object) - Description not available - **ChannelName** (String) - Description not available - **CursorReference** (Object) - Description not available - **FileName** (String) - The path to the video file. - **FrameRate** (Number) - The frame rate of the video playback. - **KeepRatio** (Boolean) - Description not available - **NoOfFrames** (Number) - Description not available - **OverlayObjects** (Object) - Description not available - **Sound** (Boolean) - Specifies whether the video sound is enabled. - **StartTime** (Number) - Description not available - **ToolbarVisible** (Boolean) - Description not available - **Transparency** (Number) - Description not available - **VideoSourceMode** (Enum) - Description not available - **XBegin** (Number) - Description not available - **XEnd** (Number) - Description not available - **YBegin** (Number) - Description not available - **YEnd** (Number) - Description not available - **ZoomCursor** (Boolean) - Description not available ### Methods - **IsZoomed** () - Description not available - **SetVideo** (FileName, [StartTime], [EndTime]) - Description not available - **ShowVideoDlg** () - Description not available ### See Also - Objects Overview ``` -------------------------------- ### Initialize Example Script for DIAdem VIEW Source: https://www.ni.com/docs/en-US/bundle/diadem/page/exploff/examples/expl_viewdisplaychnparts_2.htm This Visual Basic script initializes the example by loading necessary files into DIAdem. Note that running this script may overwrite existing data and layouts. ```Visual Basic VIEWDisplayChnParts_Init.vbs ``` -------------------------------- ### Get Length of String in Bytes (VBScript) Source: https://www.ni.com/docs/en-US/bundle/diadem/page/vbs/methods/vbs_method_lenb_globalobj.htm Use the LenB method to determine the number of bytes a string occupies. This is useful for character encoding considerations. The example shows how to get the byte length of 'DIAdem' and display it. ```VBScript Dim MyInt MyInt = LenB("DIAdem") Call MsgBox(MyInt) ' Returns 12 ``` -------------------------------- ### Path and Installation Parameters Source: https://www.ni.com/docs/en-US/bundle/diadem/page/varoff/audiohandle.htm Parameters for suggesting paths and checking installation details. ```APIDOC ## Path and Installation Parameters ### Description Parameters for managing file paths and checking software installation status. ### Parameters #### InputPath - **InputPath** (string) - Suggests a path. #### InstallationKeyword - **InstallationKeyword** (string) - Specifies the type of installation information that you request. #### IsAvailLabVIEW - **IsAvailLabVIEW** (boolean) - Specifies whether LabVIEW is installed on your computer. #### IsAvailMicrosoftPDFPrinter - **IsAvailMicrosoftPDFPrinter** (boolean) - Specifies whether a Microsoft PDF printer is installed on your computer. #### IsAvailOPCUA - **IsAvailOPCUA** (boolean) - Specifies whether the OPC-UA driver is part of a DIAdem installation. ``` -------------------------------- ### Get CurrColumn Property Source: https://www.ni.com/docs/en-US/bundle/diadem/page/scriptview/properties/view_property_currcolumn_itochanneltableint.htm Retrieves the column object from a ChannelTable that contains a specific formula expression. No setup is required. ```VBScript Set _oColumn_ = _Object_.**CurrColumn** ``` -------------------------------- ### Example: Creating a 3D Axis System with Additional Spikes Source: https://www.ni.com/docs/en-US/bundle/diadem/page/reportapi/properties/report_property_width_irepd3spikesadditionalint.htm Demonstrates how to create a 3D axis system with a surface display and configure additional spikes using VBScript and Python. ```APIDOC ## Example: Creating a 3D Axis System with Additional Spikes ### Description This example generates a 3D axis system with a surface display and configures additional spikes, including setting their width. ### Method Scripting (VBScript and Python) ### Endpoint N/A (Scripting example) ### Parameters None ### Request Example #### VBScript ```vbscript Dim oMy3DAxisSystem, oMy3DCurve, oMyPos, oMyShape, oMySpike Call Report.NewLayout() Call Data.Root.Clear() Call DataFileLoad(DataReadPath & "Report_Data.tdm","TDM","") Set oMy3DAxisSystem = Report.ActiveSheet.Objects.Add(eReportObject3DAxisSystem,"My3DAxisSystem") Set oMyPos = oMy3DAxisSystem.Position.ByCoordinate oMyPos.X1 = 20 oMyPos.X2 = 80 oMyPos.Y1 = 20 oMyPos.Y2 = 80 Set oMy3DCurve = oMy3DAxisSystem.Curves3D.Add(e3DShapeSurface, "MyNew3DCurve") Set oMyShape = oMy3DCurve.Shape oMyShape.DataStructure = e3DDataStructureTriplet oMyShape.XChannel.Reference = "[2]/[1]" oMyShape.YChannel.Reference = "[2]/[2]" oMyShape.ZChannel.Reference = "[2]/[3]" Set oMySpike = oMyShape.Extensions.Spike oMySpike.Visible = True Call oMySpike.Color.SetPredefinedColor(eColorIndexBlue) oMySpike.Width = eLineWidth0100 Call Report.Refresh() ``` #### Python ```python dd.Report.NewLayout() dd.Data.Root.Clear() dd.DataFileLoad(dd.DataReadPath + "Report_Data.tdm","TDM","") oMy3DAxisSystem = dd.Report.ActiveSheet.Objects.Add(dd.eReportObject3DAxisSystem,"My3DAxisSystem") oMyPos = oMy3DAxisSystem.Position.ByCoordinate oMyPos.X1 = 20 oMyPos.X2 = 80 oMyPos.Y1 = 20 oMyPos.Y2 = 80 oMy3DCurve = dd.Report.ActiveSheet.Objects.Add(dd.eReportObject3DAxisSystem,"My3DAxisSystem") oMyShape = oMy3DCurve.Shape oMyShape.DataStructure = dd.e3DDataStructureTriplet oMyShape.XChannel.Reference = "[2]/[1]" oMyShape.YChannel.Reference = "[2]/[2]" oMyShape.ZChannel.Reference = "[2]/[3]" oMySpike = oMyShape.Extensions.Spike oMySpike.Visible = True oMySpike.Color.SetPredefinedColor(dd.eColorIndexBlue) oMySpike.Width = dd.eLineWidth0100 dd.Report.Refresh() ``` ### Response None ``` -------------------------------- ### Python Example: Plotting a Curve with a Coordinate Comment Source: https://www.ni.com/docs/en-US/bundle/diadem/page/reportapi/properties/report_property_symbolbegin_irepcommentarrowadditionalint.htm This Python example demonstrates how to create a 2D axis system, plot a curve, find the maximum y-value, and display its coordinates in a comment arrow, customizing the start arrowhead. ```APIDOC ## Python Example: Plotting a Curve with a Coordinate Comment ### Description Generates a 2D axis system with a curve, determines the maximum y-value of this curve, and displays the coordinates of this point in a comment arrow, specifically setting the beginning arrowhead type. ### Code ```python oMy2DAxisSystem = dd.Report.ActiveSheet.Objects.Add(dd.eReportObject2DAxisSystem,"My2DAxisSystem") oMyCurveLine = oMy2DAxisSystem.Curves2D.Add(dd.e2DShapeLine,"My2DCurveLine") oMyPos = oMy2DAxisSystem.Position.ByCoordinate oMyPos.X1 = 20 oMyPos.X2 = 80 oMyPos.Y1 = 20 oMyPos.Y2 = 80 oMyShape = oMyCurveLine.Shape oMyShape.XChannel.Reference = "[1]/[1]" oMyShape.YChannel.Reference = "[1]/[2]" oMyCurveCoord = oMy2DAxisSystem.Curves2D.Add(dd.e2DShapeCoordinate,"My2DCurveCoord") MaxValY = dd.Data.GetChannel("[1]/[2]").Properties("maximum").Value MaxValX = dd.Data.GetChannel("[1]/[1]").Values(dd.PNo("[1]/[2]", MaxValY)) oMyCoordShape = oMyCurveCoord.Shape oMyCoordShape.BoundingType = dd.eCoordinateChannelBounded oMyCoordShape.BoundingPosition =dd.e2DCoordinateBoundingAbsoluteMax oMyCoordShape.BoundingXChannel.Reference = "[1]/[1]" oMyCoordShape.BoundingyChannel.Reference = "[1]/[2]" oMyCoordComment = oMyCoordShape.Extensions.CoordinateComment oMyCoordShape.Settings.Type = dd.eMarkerCircle oMyCoordComment.Arrow.SymbolBegin = dd.eArrowHeadPoint oMyCoordComment.Arrow.SymbolEnd = dd.eArrowHeadStandardArrow oMyCoordComment.Arrow.Line.LineType = dd.eLineTypeSolid oMyCoordShape.Settings.Size = 2 oMyCoordShape.Settings.MarkerFilling.SetPredefinedColor(dd.eColorIndexDarkBlue) oMyCoordShape.XCoordinate.Reference = MaxValX oMyCoordShape.YCoordinate.Reference = MaxValY oMyCoordComment.Visible = True oMyCoordComment.Position.OffsetX = 20 oMyCoordComment.Position.OffsetY = 10 oMyCoordComment.Position.Width = 25 oMyCoordComment.Position.Height = 8 oMyCoordComment.Comment.Text = "Max. X: " + MaxValX + "\r\n" + "Max. Y: " + MaxValY dd.Report.Refresh() ``` ``` -------------------------------- ### Playing a Video in DIAdem VIEW Source: https://www.ni.com/docs/en-US/bundle/diadem/page/scriptview/methods/view_method_replay_itocursormasterint.htm Examples demonstrating how to configure a video display and initiate playback using the Replay method. ```VBScript Dim oMySheet: Set oMySheet = View.ActiveSheet oMySheet.ActiveArea.DisplayObjType = "Video" oMySheet.ActiveArea.DisplayObj.FileName = ProgramDrv & "\Examples\Documents\Austin_Drive.wmv" oMySheet.Cursor.XRangeMode = "automatic" Call oMySheet.Cursor.GotoStart Call WndOpen("VIEW") Call oMySheet.Cursor.RePlay(FALSE) ``` ```Python oMySheet = dd.View.ActiveSheet oMySheet.ActiveArea.DisplayObjType = "Video" oMySheet.ActiveArea.DisplayObj.FileName = dd.ProgramDrv + "\\Examples\\Documents\\Austin_Drive.wmv" oMySheet.Cursor.XRangeMode = "automatic" oMySheet.Cursor.GotoStart() dd.WndOpen("VIEW") oMySheet.Cursor.RePlay(False) ```