New VI Object Function

Owning Palette: VI Scripting VI and Functions

Requires: VI Scripting

Adds a new VI object to the front panel or block diagram of the VI specified by owner refnum and returns a reference to the new object. VI objects include any controls, nodes, calls to subVIs, and user-defined controls that you can create in the LabVIEW editing environment.

Example

 Add to the block diagram  Find on the palette
auto wire? specifies whether LabVIEW attempts to automatically wire the terminals of the new object with compatible terminals of the source object wired to location. National Instruments recommends that you do not use this input. Instead, use VI Scripting to wire the new object to other objects precisely.
vi object class indicates the class of the object you want to create. To specify a class, wire a class specifier constant to this input. A class specifier constant displays a hierarchical menu that contains the classes of all of the objects in LabVIEW. To identify which class to use for a specific object, explore the anatomy of common VI objects.

LabVIEW uses vi object class to determine the type of reference returned by object refnum. For example, if you wire a Boolean-typed class specifier constant to vi object class, the returned object refnum changes to a Boolean reference.
owner refnum is a reference to the container into which you want to place the new object. The most common containers are VIs, clusters, and the diagrams of loops and other structures. For example, to add a new control to the front panel of a VI, wire a reference to either the relevant VI or the front panel of the relevant VI to owner refnum. To place a new object inside of a For Loop, wire a reference to the diagram of the relevant For Loop to owner refnum.
style indicates the exact kind of object to create. When you create a constant from the style terminal, you obtain a list of all the objects that are native to LabVIEW. Select a value for style that is compatible with the class specified by vi object class. For example, you can select the Round Push Button style if viobject class is Boolean, and you can select the Add style if viobject class is Function. However, LabVIEW returns a run time error if you select the Add style when viobject class is Boolean because this pairing is not compatible.

You can use the Control:Style ID and Node:Style properties to help identify the style of an object that you want to create.
location specifies where the function places the new object within the container referenced by owner refnum. The location terminal accepts the following three kinds of arguments:
  • Pair of x, y coordinates—LabVIEW places the new object at the given coordinates in relation to the origin of the owner. To quickly create this type of cluster, create a constant from the location terminal.
  • Reference to a pre-existing object—LabVIEW places the new object next to the referenced object.
  • New VI Object Offset From Referenced Object cluster—LabVIEW places the new object a specified distance from the object referenced by this cluster.
Refer to the New VI Object Location Argument VI in the Examples section of this topic for a visual comparison of these argument types.
Horizontal is the horizontal position.
Vertical is the vertical position.
error in describes error conditions that occur before this node runs. This input provides standard error in functionality.
path is a path to a subVI or pre-existing custom control. Wire data to path only when you want to add one of these objects to the owner.

If you wire data to path, you must set vi object class to Generic»GObject»Node»SubVI or any of the listed parent classes. LabVIEW ignores the style input when you wire path.
bounds specifies the width and height of the new object if the new object is resizable. LabVIEW ignores bounds for fixed-sized objects.
Width specifies the width of the object.
Height specifies the height of the object.
object refnum returns a reference to the new object created by this function. The reference is of the class specified by vi object class.
error out contains error information. This output provides standard error out functionality.

Example

Refer to the New VI Object Location Argument VI in the labview\examples\Application Control\VI Scripting\Creating Objects directory for an example of using the New VI Object function.

 Open example  Find related examples