Skip to content

← programming package

CastToType

Cast the input value to a certain type.

One use case is for converting a string representation of a type (i.e., a list) into that type, in order to pass into a node requiring that type. Another use case is to convert a value of a certain type (i.e., int or list) into a string representation of that type. Other use cases include converting between different container types (e.g., list, set, dict, array) or numeric type (int vs float). Conversions to bool generally result in True except for empty objects. The node can also seamlessly convert a 1-element list or array to a numeric type (int or float). Note that the node may also receive None values, which are passed through unless pass_through_none is False, in which case they're convertible to bool (False) and string ("None"). Cast to object is a trivial pass-through operation. Version 1.0.1

Ports/Properties

input

Input value to cast.

verbose name
Input
default value
None
port type
DataPort
value type
object (can be None)
data direction
IN

output

Output value in the selected format.

verbose name
Output
default value
None
port type
DataPort
value type
object (can be None)
data direction
OUT

cast_type

The type to which the input value will be cast. Note that additional nested casts beyond some of the most common listed cases are permitted, although not every combination will make sense.

verbose name
Cast Input To
default value
str
port type
ComboPort
value type
str (can be None)

pass_through_none

If set, then None values will silently pass through unconverted, even if cast_type is bool or string.

verbose name
Pass Through None
default value
True
port type
BoolPort
value type
bool (can be None)

set_breakpoint

Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

verbose name
Set Breakpoint (Debug Only)
default value
False
port type
BoolPort
value type
bool (can be None)

metadata

User-definable meta-data associated with the node. Usually reserved for technical purposes.

verbose name
Metadata
default value
{}
port type
DictPort
value type
dict (can be None)