ExternalDictionary is a data tool to define configuration variants for other
tool instances.
General
In the general tab the Variant is use to link a tool to an
ExternalDictionary. When a tool is link to an ExternalDictionary the tool
has multiple named configurations. The configurations are transparently
changed when the Value of the Dictionary is set.
Setup
- Add - adds new element in dictionary
- ID - sets index for selected element
- Default - sets selected element to Default
- Current - set the selected element as the current variant
- Paste - paste image to image
- Load - load image from file
- Clear - remove image and description
Results
- Value - the current value - Note: SetValue will only accept a
value that is defined in the Dictionary
- ID - the ID of the current value
- Dictionary - python dictionary for complete Dictionary
Note 1: Track changes of an ExternalDictionary tool using the
ToolVariantChange system event
Note 2: Use eval to convert Dictionary to a python dictionary
dict = eval(GetValue('ProductType.Dictionary'))
or
dict = GetResultValue('ProductType.Dictionary')
Commands
ExecuteCmd -
More
information
Command
|
Parameters
|
Return values
|
Comments
|
Set |
Object=IMAGE;Name=<variant>;Value=<filename>
Object=IMAGE;Name=<variant>;Value=CLIPBOARD |
ok,None |
sets the named variants image from clipboard or file |
Get |
Object=IMAGE;Name=<variant>;Filename=<filename>
Object=IMAGE;Name=<variant>;Filename=CLIPBOARD |
ok,None |
copies named variants image to file or clipboard |
Set |
Object=DESCRIPTION;Name=<variant>;Value=<text>
Object=DESCRIPTION;Name=<variant>;Source=CLIPBOARD |
ok,None |
sets the named variants description from file or clipboard |
Get |
Object=DESCRIPTION;Name=<variant>
Object=DESCRIPTION;Name=<variant>;Destination=CLIPBOARD |
ok,description |
get the description for named variant |
Example: Write variant V1's image to a diskfile tool = GetTool('Variant')
tool.executeCmd('Get','Object=IMAGE;Name=V1;Filename=c:\v1.bmp')
Examples
Add a variant from script def AddProduct(p):
pdict=GetResultValue('ProductType.Dictionary') # retrieve dictionary
l=pdict.keys()
pdict[str(int(p))]=len(l)+1 # adds product with index equal length +1
print pdict
SetResultValue('ProductType.Dictionary' , pdict)
|