Skip to content

set_dict_objectSetDictObjectSetDictObjectset_dict_objectT_set_dict_objectπŸ”—

Short descriptionπŸ”—

set_dict_objectSetDictObjectSetDictObjectset_dict_objectT_set_dict_object β€” Add a key/object pair to the dictionary.

SignatureπŸ”—

set_dict_object( object Object, dict DictHandle, string Key )void SetDictObject( const HObject& Object, const HTuple& DictHandle, const HTuple& Key )static void HOperatorSet.SetDictObject( HObject objectVal, HTuple dictHandle, HTuple key )def set_dict_object( object: HObject, dict_handle: HHandle, key: Union[str, int] ) -> None

Herror T_set_dict_object( const Hobject Object, const Htuple DictHandle, const Htuple Key )

void HDict::SetDictObject( const HObject& Object, const HTuple& Key ) const

void HDict::SetDictObject( const HObject& Object, const HString& Key ) const

void HDict::SetDictObject( const HObject& Object, const char* Key ) const

void HDict::SetDictObject( const HObject& Object, const wchar_t* Key ) const (Windows only)

void HDict.SetDictObject( HObject objectVal, HTuple key )

void HDict.SetDictObject( HObject objectVal, string key )

DescriptionπŸ”—

set_dict_objectSetDictObject stores an object associated with a key in the dictionary. The dictionary is denoted by the DictHandledictHandledict_handle parameter.

ObjectobjectValobject is copied by the operation and can thus be immediately reused. Thereby the object data is copied in HALCON’s object database, meaning the new object contains a reference to ObjectobjectValobject, see copy_objCopyObj.

Both an empty object or an object tuple are considered as a valid value that can be associated with the key. If any data (tuple or object) was already associated with given key (Keykeykey), the old data is destroyed by set_dict_objectSetDictObject and replaced by ObjectobjectValobject.

The Keykeykey has to be a string or an integer. Strings are treated case sensitive.

The object data for the given key can be retrieved again from the dictionary using get_dict_objectGetDictObject.

HDevelop In-line OperationπŸ”—

HDevelop provides an in-line operation for set_dict_objectSetDictObject, which can be used in an expression in the following syntax:

  • Dynamic syntax:

    DictHandle.['Key'] := Object

  • Static syntax:

    DictHandle.Key := Object

Execution informationπŸ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

This operator modifies the state of the following input parameter:

During execution of this operator, access to the value of this parameter must be synchronized if it is used across multiple threads.

ParametersπŸ”—

ObjectobjectValobject (input_object) object(-array) β†’ objectHObjectHObjectHObjectHobject

Object to be associated with the key.

DictHandledictHandledict_handle (input_control, state is modified) dict β†’ (handle)HTuple (HHandle)HDict, HTuple (IntPtr)HHandleHtuple (handle)

Dictionary handle.

Number of elements: DictHandle == 1

Keykeykey (input_control) string β†’ (string / integer)HTuple (HString / Hlong)HTuple (string / int / long)Union[str, int]Htuple (char* / Hlong)

Key string.

Number of elements: Key == 1
Restriction: length(Key) > 0

ExampleπŸ”—

(HDevelop)

create_dict (Dict)
read_image (Image, 'filename')
set_dict_object (Image, Dict, 'my_image')

ResultπŸ”—

If the operation succeeds, set_dict_objectSetDictObject returns 2 (H_MSG_TRUE). Otherwise an exception is raised. Possible error conditions include invalid parameters (handle or key) or resource allocation error.

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

create_dictCreateDict

Possible successors

set_dict_objectSetDictObject, set_dict_tupleSetDictTuple

Alternatives

set_dict_tupleSetDictTuple

See also

create_dictCreateDict, set_dict_tupleSetDictTuple, get_dict_tupleGetDictTuple, get_dict_objectGetDictObject, remove_dict_keyRemoveDictKey, get_dict_paramGetDictParam

ModuleπŸ”—

Foundation