Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Tutorial: Repositioning an Object in a VI Using VI Scripting

LabVIEW 2013 Help

Edition Date: June 2013

Part Number: 371361K-01

»View Product Info

You can reposition objects on the front panel and block diagram of VIs using VI Scripting. This tutorial repositions an object on the block diagram. Complete the following steps to reposition an object on the block diagram of a VI using VI Scripting.

Note Note  
  • This topic assumes familiarity with the VI Scripting introduction.
  • You must enable VI Scripting to display the VI Scripting VI and functions and use the associated properties and methods.
  1. Complete the previous exercise if you have not already completed it. If the untitled VI you created in the previous exercise is still open, close the VI.
  2. Remove the wires from the Close Reference function that closes the VI reference and move the function to the right to make room on the block diagram.
  3. Add another New VI Object function to the block diagram to create an Add function on the block diagram of the target VI. Configure the New VI Object function and complete the wiring as shown in the following block diagram. Make sure to close all references. Specify the owner refnum as the VI.



    Tip Tip  To specify Function in the class specifier constant, select Generic»GObject»Node»Function»Function from the shortcut menu.
  4. Save the VI.
  5. Run the VI.

    LabVIEW creates and opens untitled front panel and block diagram windows. The block diagram contains a For Loop in the upper left-hand corner and an Add function near the bottom of the block diagram. You can place the Add function inside the For Loop by wiring the object refnum output of the New VI Object function that creates the For Loop to the owner refnum input of the New VI Object function that creates the Add function. Then, you can specify coordinates that fall within the For Loop in the location input of the New VI Object function used to create the Add function. However, to examine another option for repositioning block diagram objects, the next steps of the tutorial use the Move method to move the Add function into the For Loop.
  6. If the untitled VI LabVIEW created is still open, close the VI.
  7. Remove the wires from all three Close Reference functions, and move the functions to the right to make room on the block diagram. Refer to the block diagram in step 13 for a visual reference.
  8. Add an Invoke Node to the right of the New VI Object function that creates the Add function.

  9. Wire the object refnum output of the New VI Object function to the reference input of the Invoke Node.
  10. Click the Method terminal of the Invoke Node and select Move from the shortcut menu.
  11. To specify the block diagram object into which you want to move the Add function, wire the object refnum output of the New VI Object function that creates the For Loop to the owner input of the Invoke Node.
  12. To specify a location within the For Loop to where you want to move the Add function, right-click the position input of the Invoke Node, select Create»Constant from the shortcut menu, and enter 75 and 25 as values for the Left and Top inputs, respectively.
  13. Complete all wiring to match the following block diagram.

  14. Save the VI.
  15. Run the VI.

LabVIEW creates and opens untitled front panel and block diagram windows. The block diagram contains a For Loop in the upper left-hand corner and an Add function inside the For Loop.

Note Note  Use the Delete method to delete an object using VI Scripting. You also can use the Replace method to replace an object. To clean up any broken wires after a delete operation, use the Block Diagram:Remove Bad Wires method.

To continue this tutorial, continue to the Tutorial: Wiring Objects Using VI Scripting topic.


 

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