Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Accessing Objects in DIAdem REPORT

DIAdem 2011 Help

Edition Date: July 2011

Part Number: 370859J-01

»View Product Info

Use the object commands and variables to create new REPORT objects or to modify existing REPORT objects with a script.

Including a New Object and Editing the Object Properties

Use the GraphObjNew command to create new objects and subobjects in DIAdem REPORT. In the GraphObjNew command, you specify the type of the created object and an object name. With this name you then open the object and change the properties. To create a 2D axis system with a curve and then specify the position and the background color of the 2D axis system and the color of the curve, complete the following steps:

  1. Select the DIAdem SCRIPT panel.

  2. Select File»New»VBS Script to create a new script.

  3. Enter or copy the following text into the script editor:
    Display script

    Call PicDelete()                            'Deletes all objects
    
    Call GraphObjNew("2D-Axis","New_2DAxis1")   'Creates a new 2D axis system
    Call GraphObjOpen("New_2DAxis1")            'Opens the axis object
      D2AxisBackColor  ="yell."                 'Sets the background color
      D2AxisTop        =10                      'Sets the position
      D2AxisBottom     =10
      D2AxisLeft       =10
      D2AxisRight      =10
    
      Call  GraphObjNew("2D-Curve","New_Curve") 'Creates a new curve
      Call GraphObjOpen("New_Curve")            'Opens the curve object
        D2CCHNX          ="[1]/[1]"             'Defines the x-channel
        D2CCHNY          ="[1]/[2]"             'Defines the y-channel
        D2CurveColor     ="red"                 'Defines the curve color
      Call GraphObjClose("New_Curve")           'Closes the curve object
    
    Call GraphObjClose("New_2DAxis1")           'Closes the axis object
    Call PicUpdate()                            'Updates the report
  4. Select Script»Start VBS Script to start the script.

In DIAdem REPORT a new axis system appears with a yellow background and a red curve.

Renaming an Object

Use the GraphObjRename command to rename an object. For example, to select a curve and to change the color of the curve and the background color of the axis system, complete the following steps:

  1. Select the DIAdem SCRIPT panel.

  2. Select File»New»VBS Script to create a new script.

  3. Enter or copy the following text into the script editor:
    Display script

    Dim iObjNo
    For iObjNo = 1 To ObjectNoMax         'Loop over all objects in DIAdem REPORT
    
      If ReportObjType(iObjNo) = "2D-Axis" Then
        'Rename Main Object
        Call GraphObjRename(ReportObj(iObjNo),"2DAxis1")
        
        'Rename Axis
        Call GraphObjOpen("2DAxis1")
          Call GraphObjRename(D2AXISXOBJ(1),"2DAxis1_X1")
          Call GraphObjRename(D2AXISYOBJ(1),"2DAxis1_Y1")
        Call GraphObjClose("2DAxis1")
        
        'Rename Curve
        Call GraphObjOpen("2DAxis1")
          Call GraphObjRename(D2CurveObj(1),"2DAxis1_Curve1")
        Call GraphObjClose("2DAxis1")
    
        Exit For
      End If
    Next
    
  4. Select Script»Start VBS Script to start the script.

Editing Objects That Are the Same Type and Have the Same Properties

Use the ReportObjType variable to obtain the object type. Use the ReportObj variable to obtain an object name. You can use various variables to specify the subobject name. To find the name of the variable you need for specifying an object name, refer to the help page for the property you want to edit.

For example, to change the axis color of all 2D axis systems and the color of the curves that are the same color, complete the following steps:

  1. Select the DIAdem SCRIPT panel.

  2. Select File»New»VBS Script to create a new script.

  3. Enter or copy the following text into the script editor:
    Display script

    Dim iObjNo, sObjectName, sCurveName, iCurveNo
    For iObjNo = 1 To ObjectNoMax         'Loop over all objects in DIAdem REPORT
      sObjectName = ReportObj(iObjNo)     'Gets the object name
      If sObjectName <> "" Then           'Ensures that the object is not deleted
        Select Case ReportObjType(iObjNo) 'Gets the object type
        Case "2D-Axis"
          Call Change2DAxis(sObjectName)  'Calls procedure to change the objects of the 2D axis system
        Case Else
          'Do something else
        End Select
      End If
    Next
    Call PicUpdate()
    
    ' --- Procedure to change object of the 2D axis system ---
    Sub Change2DAxis(sObjectName)          
      Call GraphObjOpen(sObjectName)       'Opens the 2D axis system
        D2AxisColor      = "blue"          'Sets the axis color
        For iCurveNo = 1 To CurveNoMax     'Loop over all curves
          sCurveName= D2CurveObj(iCurveNo) 'Gets the curve name
          If sCurveName <> "" Then         'Ensures that curve is not deleted
            Call GraphObjOpen(sCurveName)  'Opens the curve object
              If D2CurveColor = "black" Then
                D2CurveColor     = "yell." 'Sets the curve color
              End  If
            Call GraphObjClose(sCurveName) 'Closes the curve object
          End If
        Next
      Call GraphObjClose(sObjectName)      'Closes the 2D axis system
    End Sub
  4. Select Script»Start VBS Script to start the script.

DIAdem colors the axes of all 2D axis systems blue and the black curves yellow.

Editing an Object Selected in the Window

Use the GraphObjRename command to rename main objects or subobjects in DIAdem REPORT. In the GraphObjRename command, you specify the type of the created object and an object name. With this name you then open the object and change the properties. To create a 2D axis system with a curve and then specify the position and the background color of the 2D axis system and the color of the curve, complete the following steps:

  1. Select the DIAdem SCRIPT panel.

  2. Select File»New»VBS Script to create a new script.

  3. Enter or copy the following text into the script editor:
    Display script

    Dim iObj, strMainObj, strSubObj 
    Call WndShow("REPORT")
    Call MsgBoxDisp("Please select at at least one curve and click 'End interaction' to continue")
    Call InteractionOn                            'Enables the interaction mode
    For iObj = 1 To SelAllObjCount                'Loop over all selected objects
      If SelObjType(iObj, 1) = "2D-Axis" Then     'Checks the main object type
        strMainObj = SelObjName(iObj, 1)          'Gets the object name
        Call GraphObjOpen(strMainObj)             'Opens the object
        D2AxisBackColor = "green"                 'Sets the parameter
        If SelObjType(iObj, 2) = "2D-Curve" Then  'Checks the sub object type
           strSubObj = SelObjName(iObj, 2)        'Gets the sub object name
           Call GraphObjOpen(strSubObj)           'Opens the sub object
             D2CurveColor = "blue"                'Sets the curve color
           Call GraphObjClose(strSubObj)          'Closes the sub object
        End If
        Call GraphObjClose(strMainObj)            'Closes the main object
      End If
    Next
    Call PicUpdate()                              'Updates the report
  4. Select Script»Start VBS Script to start the script.

DIAdem prompts you to select at least one curve and then to disable the interaction mode. DIAdem makes the selected curve blue and the background of the 2D axis system green.

Note  Press <Ctrl-A> to also record the current settings of the dialog box that is open, in the recording mode. If the recording mode is not enabled, press <Ctrl-A> to copy the settings of the open dialog box to the clipboard. In both cases, DIAdem also records the object hierarchy, which means all commands required for opening and for closing the dialog box. DIAdem does not record commands for creating an object.
Note  When you select an object, DIAdem displays the name of the main object in the status bar.
Note  Refer to Commands and Variables for Working in DIAdem REPORT for a list of all REPORT variables and the assignment of main objects to subobjects.
Note  Refer to the Help page on Opening REPORT Configuration Dialog Boxes with a Script for more information about opening dialog boxes in DIAdem REPORT.


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit