Creating Custom Dynamo Objects with Command Scripts

When you create a Dynamo object that contains objects with command scripts, you can apply user prompts to those scripts allowing users of the Dynamo to change the command script parameter. To do this, for each command script, add a Variable object to the Dynamo group and change the command script parameter as described in the example below. This allows you to change the command script parameter in the Dynamo Properties dialog box.

Example 1

For example, you may want to create a Dynamo that contains a command button that when clicked, runs the following command script:

ToggleDigitalPoint "FIX32.SCADA01.DO1.F_CV"

And, you may want to allow the Dynamo users to change the tagname for the ToggleDigitalPoint command.

To allow Dynamo users to change the tagname for the ToggleDigitalPoint command:

  1. Add a Variable object for each command script to the Dynamo group.
  2. Set the Variable object's VariableType property to String and its InitialValue property to the tagname.
  3. Change the command script parameter in the script to VariableName.InitialValue.

Example 2

Assume that you have two push buttons in your Dynamo. One has the command script: WriteValue "50", "FIX32.NODE.TAG.F_CV". The other has the following command script: ToggleDigitalPoint "FIX32.NODE.DIGTAG.F_CV".

To allow users to be able to set the tags when they use the Dynamo object:

  1. In Classic view, use the Variable toolbar button on the Toolbox to insert a Variable object.

-Or-

In Ribbon view, on the Insert tab, in the Objects/Links group, click Objects/Links, and then click Variable.

  1. When the Create a Variable Object dialog box appears:
    1. Name the Variable object WriteVal.
    2. Select Variable Type String.
    3. Select Local Variable.
    4. Click OK.
  2. Select the Variable object that you inserted in the System Tree, and select Property Window from the right-click menu.
  3. In the Property Window for the Variable object, set the Initial Value property to FIX32.NODE.TAG.F_CV.
  4. Insert another Variable object and follow steps 1 through 4 above. Name the Variable object ToggleVal and set the Initial Value property of this Variable object to FIX32.NODE.DIGTAG.F_CV.
  5. For the two pushbuttons, open the Visual Basic Editor and change the command scripts as follows:
    • WriteValue "50", WriteVal.InitialValue
    • ToggleDigitalPoint ToggleVal.InitialValue
  6. Close the editor and add the two Variable objects to the Dynamo group by selecting them in the System Tree and dragging and dropping them into the group.

When you select the Create Dynamo toolbar button, the Create Dynamo with User Prompts displays:

Object Property

Current Settings

User Prompt

WriteVal.InitialValue

FIX32.NODE.TAG.F_CV

 

ToggleVal.InitialValue

FIX32.NODE.DIGTAG.F_CV

 

If you set your User Prompts to Write Tag and Toggle Tag, the Dynamo Properties dialog box displays the following:

Dynamo Property

Current Setting

Write Tag

FIX32.NODE.TAG.F_CV

Toggle Tag

FIX32.NODE.DIGTAG.F_CV

See Also

How Do I...