Set the type of a port

The way in which you resolve the type of a port depends on whether it is a referenced or local compound.

To resolve the type of a port on a referenced compound

For auto ports

Right-click on an auto port and select Value Types, and a list of Suggested Types is provided. auto ports can accept any type, and the sub-menu lists the most common options. If the type you want is not listed, select Set Value Type, then select the type you want from the Set Value Type editor.

Auto port Value Types menu

The currently resolved type is indicated with a checkmark.

Currently resolved type checkmark

To revert the port to its auto type, right-click and select Clear Value.

For more information about auto ports, see About auto-type ports.

For overloaded ports

Similarly, you can right-click on a port on an overloaded node and select Value Types, and a list of Supported Types is provided.

An overloaded node contains multiple definitions, each for a different data type — the most commonly used types are listed in this menu. If the type you want is not listed, expand the All Supported Types submenu, and select from other available overloads. With this menu, you can also explore the available overloads for a compound.

Selecting a type from the list selects an overload, and the currently resolved type is indicated with a checkmark. To revert the port to its original state (inferred type), right-click and select Clear Value.

In this graph, a value node of type float3 is added to set the type of set_geo_property.data to float3.

set_geo_property with a Value node

In this graph, set_geo_property.data is set to float3 by selecting Value Types > Math::Float3. Manually creating a value node is not needed.

set_geo_property with menu

for information about overloads, see Overloadable.

Note:

The Set Value Type, Value Types and Clear Value menu items only appear when the port does not have an incoming connection. Otherwise, the type of the port is determined by its input.

Set unresolved port types on referenced compounds

In addition to using the right-click menu, you can also set the type of an unresolved port in the drop-down list of the Parameter Editor.

Unresolved type in the Parameter Editor

Additional example of wrangling a type by adding a value

You can also use this feature to convert one data type to another with a minimum number of steps.

In this example, if you want to change your (x, y, z) values from the second to the first quadrant - that is, from (-1, 1) to (0, 1) - as soon as you set the value port type to array<float3>, all other ports are also promoted to float3. Right-click on each port and set it to float.

This removes the need to enter (x,y,z) values for all four ports, and the need to create a value node to set the type of each port.

Change range example

Set the port type on a local compound

Right-click the port on a local compound and expand the Value Types menu to select a type. If the type you want is not listed, select Set Value Type to set it from the Set Value Type editor.

Note:

When you right-click on a port and choose Clear Value, the port's type is reset to its default in addition to its value being reset.

Add a Suggested Types menu to a port on your custom compound

To add a Value Types menu with a list of suggested types to an auto port on your compound, do either of the following:

Add metadata to the port description in the compound's .json file

An example from get_geo_property.json is provided here:

{
    "portName": "type",
    "portDirection": "input",
    "metadata": [
        {
            "metaName": "TypeWranglingSuggestedTypes",
            "metaType": "string",
            "metaValue": "array<float>, array<long>, array<uint>, array<bool>, array<string>, array<Math::float2>, array<Math::float3>, array<Math::float4>, array<Math::float3x3>, array<Math::float4x4>"
        }
                ]
},

Set the metadata name to "TypeWranglingSuggestedTypes", and provide the list of suggested types in the metadata value.

For more information, see ../resources/bif/jsonLibs/get_geo_property.json.

Add metadata with the vnnCompound command

Use the vnnCompound command with the setPortMetaDataValue flag and provide: the port name, metadata name (TypeWranglingSuggestedTypes), and metadata value (list of suggested types).

For example:

vnnCompound "bifrostGraph1" "/myCompound" -setPortMetaDataValue "myPort" "TypeWranglingSuggestedTypes" "array<float>, array<long>, array<uint>, array<bool>, array<string>, array<Math::float2>, array<Math::float3>, array<Math::float4>, array<Math::float3x3>, array<Math::float4x4>";

Publish the compound. Now when you create myCompound, the Value Types menu will appear when you right-click myPort.

For more information, see the -setPortMetaDataValue flag in the vnnCompound documentation (MEL) or vnnCompound documentation (Python).