Symbolic constant keyword examples

Symbolic constants provide a way to specify choices for a command argument that make the command more readable. For example, there are three choices for the renderStyle argument in display options commands.

We could number these choices using integer values from 1 to 3. However, using integer values would result in a command that is not very readable; for example, renderStyle=2. Alternatively, if we define symbolic constants for each choice, the command becomes more readable; for example, renderStyle=HIDDEN. Internally, symbolic constants contain an integer ID that can be accessed via its getId() method. Symbolic constants can be used in both the GUI and kernel processes. Typically you should create a module that defines your symbolic constants and then import that module into both your kernel and GUI scripts.

You can import the SymbolicConstant constructor from the symbolicConstants module. The constructor takes a single string argument. By convention, the string argument uses all capital letters, with an underscore between words, and the variable name is the same as the string argument. For example,

from symbolicConstants import SymbolicConstant
AS_IS = SymbolicConstant('AS_IS')

In the case of symbolic constant keywords, you can use a value of zero or the value of the ID of a symbolic constant for the message ID. Symbolic constants have a unique integer ID that is used to set the value of symbolic constant keywords along with a string representation that is used in the generation of the command. To access the integer ID of a symbolic constant, use its getId method.

If the keyword is connected to a list or combo box widget, you should use a value of zero for the ID in the widget constructor. The AFXList, AFXComboBox, and AFXListBox widgets have been designed to handle symbolic constant keywords as targets. When items are added to a list or combo box, a symbolic constant’s ID is passed in as user data. These widgets react by setting their value to the item whose user data matches the value of their target, as opposed to setting their value to the item whose index matches the target’s value. The following example illustrates how a combo box can be connected to a symbolic constant keyword:

combo = AFXComboBox(hwGb, 18, 4, 'Highlight method:',
    mode.highlightMethodHintKw, 0)
combo.appendItem('Hardware Overlay', HARDWARE_OVERLAY.getId())
combo.appendItem('Software Overlay', SOFTWARE_OVERLAY.getId())
combo.appendItem('XOR', XOR.getId())
combo.appendItem('Blend', BLEND.getId()) 

If the keyword is connected to a radio button, you should use the ID of the symbolic constant that corresponds to that radio button for the message ID. Since the ID of all symbolic constants is greater than zero, this tells the keyword to operate in option mode. The following example illustrates how symbolic constant keywords can be used with radio buttons:

from abaqusConstants import *
... 

# Modeling Space
#
gb = FXGroupBox(self, 'Modeling Space',
    FRAME_GROOVE|LAYOUT_FILL_X)
FXRadioButton(gb, '3D', mode.dimensionalityKw,
    THREE_D.getId(), LAYOUT_SIDE_LEFT)
FXRadioButton(gb, '2D Planar', mode.dimensionalityKw,
    TWO_D_PLANAR.getId(), LAYOUT_SIDE_LEFT) 
FXRadioButton(gb, 'Axisymmetric', 
    mode.dimensionalityKw, AXISYMMETRIC.getId(),
    LAYOUT_SIDE_LEFT)