Core: ENS_GLOBALS
ensight.objs.core object
The ENS_GLOBALS object is central to the Python Object API. This is the ensight “global” object, the one and only instance of the ‘ENS_GLOBALS’ class. Check the attributes on this object. They include lists of parts, cases, variables, annotations, etc.
Attributes:
- CASES: a list of the cases - Note: cases are also a tree structure to GROUPS with terminal LPART and PART objects.
- VARIABLES: a list of the defined variables
- VARIABLETREE: the root group of the variable tree
- PARTS: a list of the loaded/created parts
- ANNOTS: a list of the created annots
- PLOTS: a list of created plots
- QUERIES: a list of created queries
- VPORTS: a list of the defined viewports
- TOOLS: a list of the current tool objects
- CURRENTCASE: the current case object
- CURRENTGUI: the currently active gui_extension
- DEFAULTPARTS: a list of default parts (used to store default attributes)
- DEFAULTANNOTS: a list of default annotations (used to store default attributes)
- DEFAULTQUERY: the default query (used to store default attributes)
- DEFAULTPLOT: the default plotter (used to store default attributes)
- STATUS_STRING: the string in the upper right corner of the GUI
- QUERY_PROBE_DATA: the output of the current probe query buffers (see: ensight.query(ensight.QUERY_PROBE_DATA))
- MRU: the current ensight MRU (returns a list of dicts)
- JLCS: the current ENS_JLC object (job launch and control)
- FONTFAMILIES: the available fonts (list of dicts, one per family. see enums.CVF_FONT_* for BOLD,ITALIC, ... interpretation of the ‘style’ key).
- PREDEFINEDPALETTES: the predefined palette names and filename (list of dicts)
- DELAY_REFRESH: delay refresh boolean
- PARTHIGHLIGHT: part highlighting boolean
- SHADING: global shading boolean
- HIDDENLINE: global hidden line boolean
- FASTDISPLAY: global fast display mode boolean
- PERSPECTIVE: global perspective mode boolean
- AUXCLIPPING: global aux clipping boolean
- STEREO: stereo boolean
- STEREO_SEPARATION: the current stereo separation (float)
- REALTIME_ISOS,REALTIME_CLIPS: the current state of realtime isos and clips. The return value is a dictionary with the keys ‘part’ and ‘state’. See ENS_PART::realtimemode() for more details.
- ANIMATING: see ensight.objs.ens_animobj above.
- RECORDING: see ensight.objs.ens_animobj above.
- FRAME_DURATION: see ensight.objs.ens_animobj above.
- ANIMOBJS: see ensight.objs.ens_animobj above.
- OBJECT_API_JOURNAL: boolean that is true if the object API should generate command language journaling
- TIMESTEP: the current timestep
- TIMESTEP_LIMITS: the min and max timestep values
- SOLUTIONTIME: the current solution time
- SOLUTIONTIME_LIMITS: the min and max solution times
- TIMEVALUES: a list of valid [timestep, solution_time] pairs
- WINDOWSIZE: the size of the current rendering window
- VOLUME_NUM_PASSES: the number of passes used for volume rendering
- VOLUME_CHUNKING_NUM_TETS: the number of tets to put into a single rendering chunk
- ALLOW_MRU_UPDATE: if 0, any case operations will not update the MRU
- PLAYING_COMMAND_FILE: True if playing a command file, False if interactive
Methods:
- ensight.objs.core.generate_uuid() : returns a new UUID every time it is called. The return value is a string formatted like this: '6065a0a6-1609-11e6-8777-23d57158e597'
- ensight.objs.core.anim_control([play=v][seek=t]): Animation control settings. If play= is specified, the ‘v’ values is used as the ANIMATING attribute above (ANIMOBJ_PLAY_STEP_REV, ANIMOBJ_PLAY_REV, ANIMOBJ_PLAY_STOP, ANIMOBJ_PLAY_FWD, ANIMOBJ_PLAY_STEP_FWD). If seek= is specified, all of the animations are seeked to time ‘t’. This is done by rewinding all objects to their initial frame (first frame of the first object in a chain) and then stepping forward ‘t’ seconds into the objects.
- ensight.objs.core.selection([|name=”“][|type=typeobj]): returns an ENS_GROUP object of the current selection in EnSight. name can be “ENS_PART”, “ENS_VAR”, “ENS_ANNOT”. type can be ensight.objs.ENS_PART, ensight.objs.ENS_VAR, ensight.objs.ENS_ANNOT.
- ensight.objs.core.pick_operation(operation[,points=][,normal=][,prepick=]): performs one of the picking operations (specified by operation) at the points specified by the points= list. By default, the point units are pixels, but if normal=1, the units are normalized. The prepick=’name’ option can be used with the PICK_SIMULATE_MENU to insert the name of a specific menu to be inserted in the _info dictionary. The return value is a list of error code (one per point) unless the operation is PICK_SIMULATE_MENU in which case the output is a list of _info dictionaries (see the user-defined menus documentation for details). Valid operations include: PICK_BLANK_ELEMENTS, PICK_PART, PICK_PLANE_NODEIDS, PICK_PLANE, PICK_LINE, PICK_LINE_SURFACE_NORMAL, PICK_LINE_NODEIDS, PICK_POINT, PICK_FRAME_ORIGIN, PICK_CAMERA_LOCATION_XYZ, PICK_CAMERA_LOCATION_NODE, PICK_CAMERA_DIRECTION_XYZ, PICK_CAMERA_DIRECTION_NODE, PICK_POLYLINE_POINT, PICK_POLYLINE_POINT_PART_CENTER, PICK_PALETTE_BAND, PICK_PLANE_ORIGIN, PICK_PLANE_ORIGIN_AND_NORMAL, PICK_TRANSFORM_CENTER, PICK_LOOKAT, PICK_SIMULATE_MENU
- ensight.objs.core.create_group([children]): this method creates a user ENS_GROUP selection object. The optional child list can be used to initialize the CHILDREN attribute.
- ensight.objs.core.remote_launch(url[,cmd]): undocumented internal method
- case = ensight.objs.core.add_case(JLC): undocumented internal method
- a = ensight.objs.core.path_cache(which=v): this method returns the string (pathname) cached away against the target selected by ‘v’. ‘v’ can be: ENS_DEFPATH_TEXTURE, ENS_DEFPATH_PYEDIT, ENS_DEFPATH_CMDPLY, ENS_DEFPATH_CMDREC, ENS_DEFPATH_GBLMACRO, ENS_DEFPATH_LCLMACRO, ENS_DEFPATH_MISC. If unspecified, ‘v’ defaults to: ENS_DEFPATH_MISC
- ensight.objs.core.path_cache(which=v,path=str): If path= is included to the above method, it will set the string to that value and the return value is None.
- attrid = ensight.objs.core.alloc_userdef_attr(namestring): this method creates a new, userdefined attribute on the ‘core’ object. The attribute number is returned and string passed is defined in the ensight.objs.enums module with the returned value. The attribute can be used for callbacks, etc. The attribute can store any python value and acts like all other attributes. Note: in general, prefer ensight.objs.allocextattr() over this method. While it cannot support arbitrary Python objects, it is more accessible to the EnSight GUI and a bit more flexible.
- varobj = ensight.objs.core.create_variable("name",value="expression"[,sources=list][,materials=list][,species=list][,private=1]): this method creates a new variable. It is basically a wrapper around variables: evaluate. It creates a variable with the provided name, using the calculator expression supplied by the value= keyword (ascii string). If the expression requires a partlist, this is supplied using the sources= keyword (the default is the current part selection). This can be specified as an ENS_GROUP object, or a list of part names/ids/objects. Similarly with materials and species, except there are no defaults and only objects may be passed in lists. If the private=1 keyword is set, the variable will be marked as "hidden" and will not show up in some partlists (e.g. in popup dialogs or the EnSight CFD partlist).
- ensight.objs.core.get_units(object, format=0, utf8=0, prefix="", suffix="") : This method will look at the specified object and get any unit information specified by the UNIT schema. It will then return a string with the specified prefix and suffix strings added before the units and after the units. The format can be: 0=raw, 1=Unicode, local 8bit representation unless utf8=1 in which case, Unicode in UTF8 encoding, 2=a valid EnSight annotation string.
For example, for a variable with the ENS_UNITS_LABEL and version 2.0 of the schema specified, the command:
ensight.objs.core.get_units(var)
returns: 'm^2 s^-2'
ensight.objs.core.get_units(var, format=1, prefix='[', suffix=']')
returns: '[m2/s2]' encoded in the platforms native 8bit Unicode scheme.
ensight.objs.core.get_units(var, format=2, prefix='[', suffix=']')
returns: '[m<uc=00b2>/s<uc=00b2>]'
Starting from EnSight R 20.1, utf8=0 and utf8=1 will return the same unicode string object (in Python 3 all strings are unicode). You can set utf8=2 to get the corresponding byte object. So,
ensight.objs.core.get_units(var)
returns: 'm^2 s^-2'
ensight.objs.core.get_units(var, format=1, utf8=1)
returns: "m2/s2 "
ensight.objs.core.get_units(var, format=1, utf8=2)
returns: "b'm\xc2\xb2/s\xc2\xb2''
It is also legal to pass a dimensions string to get_units() instead of a variable object. For example ensight.objs.core.get_units("LL/SS",...) will generate the same output as the above examples, except that it may not return specific units labels associated with the variable.
This API can generate labels from DIMS and SYSTEM values if no explicit label string has been specified for the variable object.
- ensight.objs.core.unit_system([name=s,silent=1,enumerate=-1,record=0]) : Get/set the current unit system to the named value (see ENS_UNITS_SYSTEM). With no arguments, this method simply returns a tuple: ('unit system string', 'unit system name', True if this is the session unit system, a dictionary of the unit labels). If the system name is passed as 'name', the method will attempt to set the current unit system. In this case, 'name' should be set to the simple string name of the unit system (e.g. 'SI'). If the unit system has been locked (e.g. a dataset has been loaded), the method will throw an exception unless 'silent=1' (the default) has been specified. If 'record' is non-zero and the unit system was changed, the change will be recorded in command language. If enumerate is set to a number greater than -1, it will walk the list of known unit systems. When the end of the list is reached, an exception will be thrown. The following snippet will dump the unit system table in EnSight.
idx = 0
while True:
try:
print(ensight.objs.core.unit_system(enumerate=idx))
except:
break
idx += 1
Which looks like this:
('USER', 'User defined units', False, {'A': '', 'D': '', 'I': '', 'K': '', 'M': '', 'L': '', 'Q': '', 'T': ''})
('SI', 'Metric SI', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'K', 'M': 'kg', 'L': 'm', 'Q': 'A', 'T': 's'})
('CGS', 'Metric CGS', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'C', 'M': 'g', 'L': 'cm', 'Q': 'A', 'T': 's'})
('BFT', 'US ft Consistent', False, {'A': 'slugmol', 'D': 'rad', 'I': 'cd', 'K': 'F', 'M': 'slug', 'L': 'ft', 'Q': 'A', 'T': 's'})
('BIN', 'US in Consistent', False, {'A': 'lbmmol', 'D': 'rad', 'I': 'cd', 'K': 'F', 'M': 'slinch', 'L': 'in', 'Q': 'A', 'T': 's'})
('MKS', 'Metric MKS', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'C', 'M': 'kg', 'L': 'm', 'Q': 'A', 'T': 's'})
('MPA', 'Metric MPA', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'C', 'M': 'tonne', 'L': 'mm', 'Q': 'mA', 'T': 's'})
('uMKS', 'Metric uMKS', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'C', 'M': 'kg', 'L': 'um', 'Q': 'pA', 'T': 's'})
('CGSK', 'Metric CGSK', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'K', 'M': 'g', 'L': 'cm', 'Q': 'A', 'T': 's'})
('NMM', 'Metric NMM', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'C', 'M': 'kg', 'L': 'mm', 'Q': 'mA', 'T': 's'})
('uMKSS', 'Metric uMKSS', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'C', 'M': 'kg', 'L': 'um', 'Q': 'mA', 'T': 's'})
('NMMDAT', 'Metric NMMDAT', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'C', 'M': 'decatonne', 'L': 'mm', 'Q': 'mA', 'T': 's'})
('NMMTON', 'Metric NMMTON', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'C', 'M': 'tonne', 'L': 'mm', 'Q': 'mA', 'T': 's'})
('BFTS', 'US ft', False, {'A': 'lbmmol', 'D': 'rad', 'I': 'cd', 'K': 'F', 'M': 'lbm', 'L': 'ft', 'Q': 'A', 'T': 's'})
('BINS', 'US in', False, {'A': 'lbmmol', 'D': 'rad', 'I': 'cd', 'K': 'F', 'M': 'lbm', 'L': 'in', 'Q': 'A', 'T': 's'})
('USENG', 'US Engineering', False, {'A': 'lbmmol', 'D': 'rad', 'I': 'cd', 'K': 'R', 'M': 'lb', 'L': 'in', 'Q': 'A', 'T': 's'})
('Unknown', 'From first loaded case', False, {'A': '', 'D': '', 'I': '', 'K': '', 'M': '', 'L': '', 'Q': '', 'T': ''})
- ensight.objs.core.get_unit_dimensions(varobj, normalized=False): This method will return the units dimension string for a given variable object. If there is a variable 'v' that is velocity, the call ensight.object.core.get_unit_dimensions(v) will return the dimension string: "L/T". If normalized is set to True, the form of the dimension string will be standardized. For example: 'LT/TT' would be converted to 'L/T' and the ordering of the dimension letters will be sorted to a standard order (MLIDKQTA). This allows for the direct comparison of variable unit dimensions.
- ensight.objs.core.get_unit_conversion(from_unit_system, to_unit_system, dimension_string): This method will return the M and B linear equation parameters for the equation: y = Mx + b that can be used to convert an entity of the dimensionality specified by dimension_string (e.g. L/TT) from the first unit system to the second (e.g. "SI" to "BIN"). If the conversion fails, this function will raise an exception. Otherwise it returns a tuple of two floats. An example use case for a volume variable from SI to BFT might be:
var_dims = ensight.objs.core.get_unit_dimensions(ensight.objs.core.VARIABLES['EleSize'][0])
(m, b) = ensight.objs.core.get_unit_conversion(ensight.objs.core.unit_system()[0], "BFT", var_dims)
returns: (35.31466672148858, 0.0)
- ensight.objs.core.grpc_server([start=False[,port=0]][,stop=False][,security_string=""]): This method controls the status of the current EnSight gRPC server from Python. If stop is true, the current server (if any) is stopped. If start is true, a new server will be started (if need be). The port number used when starting the new server will be taken from the port keyword. If not present, the previous port default will be used. If both start and stop are true, the method will first stop any existing server and then start a new server, potentially on a new port.
In all cases, the return value will be a three value tuple of the current gRPC server status. The first value will be True or False depending on if the server is running or not. The second value will be the port number the server is running on. The third value is the security string. The security string used when starting the new server will be taken from the security_string keyword. If not present, the previous security_string will be used.
This method may throw exceptions on server start/stop errors.
- ensight.objs.core.mouseactionget(mouse_button_combo): This method returns the mouse action assigned to the mouse button combo.
Options for mouse actions are:
ensight.MOUSE_ROTATE: rotate
ensight.MOUSE_TRANSLATE: translate
ensight.MOUSE_ZOOM: zoom
ensight.MOUSE_ZOOMBAND: rubber band zoom
ensight.MOUSE_SELECT_TOOL: region selection
ensight.MOUSE_PICK_PART: select a part
ensight.MOUSE_PICK_TRANSFORM_CENTER: set center of transformation
ensight.MOUSE_PICK_CURSOR: set cursor tool position
ensight.MOUSE_NORMAL_ACTION: the primary navigation action: rotate, translate, zoom, etc
ensight.MOUSE_PICK_ACTION: select a part, annotation, ect
ensight.MOUSE_PICK_PART_OPTIONS: select a part (same as ensight.MOUSE_PICK_PART)
ensight.MOUSE_ACTION_NONE: no action
ensight.MOUSE_USER_DEFINED: display context menus
Options for mouse button combo are:
ensight.MOUSE_BTN_RIGHT
ensight.MOUSE_BTN_MIDDLE
ensight.MOUSE_BTN_LEFT
ensight.MOUSE_BTN_RIGHT_MIDDLE
ensight.MOUSE_BTN_LEFT_MIDDLE
ensight.MOUSE_BTN_LEFT_RIGHT
ensight.MOUSE_BTN_ALL
- ensight.objs.core.mouseactionset(mouse_button_combo, mouse_action): This method assigns a mouse button, or button combination, to an action. EnSight requires one mouse button combo assigned to ensight.MOUSE_NORMAL_ACTION.
- ensight.objs.core.post_event(dictionary): This method makes it possible to generate mouse and keyboard events that EnSight will interpret the same as direct interaction. The 'dictionary' has a very specific form for each of the event types. On success, the method returns '0'. It can also return -1 if the event type is unknown. It may also throw an exception if necessary keys are not specified.
There are a number of event types. Each event type has an ID number and several required dictionary keys:
CVF_MOUSE_BUTTON_DOWN = 100
CVF_MOUSE_BUTTON_UP = 101
CVF_MOUSE_DOUBLE_CLICK = 102
dict(type={event type}, x={xposition}, y={yposition}, button={button that caused the event},
buttonstates={the state of all of the other mouse buttons}, modifiers={the current keyboard modifiers})
Simple left mouse down example:
dict(type=100, x=200, y=200, button=1, buttonstate=1, modifiers=0)
CVF_MOUSE_MOTION = 103
dict(type={event type}, x={xposition}, y={yposition}, buttonstates={the state of all of the other mouse buttons},
modifiers={the current keyboard modifiers})
Simple mouse motion with the right button down with the shift key:
dict(type=103, x=200, y=200, buttonstate=4, modifiers=2)
CVF_WHEEL_MOTION = 150
CVF_WHEEL_BEGIN = 151
CVF_WHEEL_END = 152
The mouse wheel consists of three events: begin, motion and end in that order.
dict(type={event type}, value={change in value}, x={xposition}, y={yposition}, modifiers={the current keyboard modifiers})
Simple mouse wheel motion takes three events:
dict(type=151, x=200, y=200, modifiers=0)
dict(type=150, x=200, y=200, value=-120, modifiers=0)
dict(type=152, x=200, y=200, modifiers=0)
CVF_KEY_DOWN = 200
CVF_KEY_UP = 201
dict(type={event type}, x={xposition}, y={yposition}, buttonstates={the state of all of the other mouse buttons},
modifiers={the current keyboard modifiers})
Simple key ('A') down with the control key down:
dict(type=200, x=200, y=200, key=0x41, modifiers=1)
The keycodes for most keys match their ASCII codes. Other keys (e.g. Function Keys) use the same lower 8bits as their Qt Keycodes, but or-ed with 0x1000. For example, the 'End' key in Qt is 0x01000011 while the CVF keycode is 0x1011.
The button value masks are:
CVF_BUTTON_NONE = 0
CVF_BUTTON_LEFT = 1
CVF_BUTTON_MIDDLE = 2
CVF_BUTTON_RIGHT = 4
CVF_BUTTON_WHEEL = 128
The keyboard modifier value masks are:
CVF_MODIFIER_NONE = 0
CVF_MODIFIER_CTRL = 1
CVF_MODIFIER_SHIFT = 2
CVF_MODIFIER_ALT = 4
- ensight.objs.core.grpc_server([start=False[,port=0]][,stop=False]): This method controls the status of the current EnSight gRPC server from Python. If stop is True, the current server (if any) is stopped. If start is True, a new server will be started (if need be). The port number used when starting the new server will be taken from the port keyword. If not present, the previous port default will be used. In all cases, the return value will be a two value tuple of the current gRPC server status. The first value will be True or False depending on if the server is running or not. The second value will be the port number the server is running on. If the port number of 0 is specified, EnSight will pick an unused, open port at random to start the server on. This method can throw exceptions on server start/stop errors. Note that is both start and stop are set to True, the method will stop the current server (if any) and then start a new one using the specified port.
- result = ensight.objs.core.find_objs([list=l][filter=dict][group=1][recurse=1][depth=-1][types=[]]): this method will walk an object tree, looking for objects that meet the specified requirements. The objects to be searched are passed via list=l. This can be a Python list or a ENS_GROUP subclass. The method will walk all of the objects in the list and all the children in the groups. By default, it will recurse the groups, but that can be disabled by specifying recurse=0. Once the algorithm finds an object, it will apply two filters (if specified). The simplest filter is the types=[] list. This specifies a list of allowable type objects (e.g. ensight.objs.ENS_PART is a type object). Only objects of the types in the list are returned. Second, is the filter= dictionary. This is a dictionary keyed by attribute enums. The algorithm gets the attribute value for the specified enum (if the enum does not exist, the object is not selected) and compares it to the value of the key in the dictionary. If the value comparisons fail, the object is not selected. Note: the algorithm uses the cmp() method on the values in the dictionary to make the comparison. Thus, comparisons other than equality can be implemented using objects with custom cmp() methods. By default, the routine returns a Python list of objects, but group=1 can be specified to return a user selection group object containing the objects that would be in the list. The group option makes it easy to change attributes in bulk on the objects. It also makes it possible to access a 'ensobjlist' interface (group.CHILDREN is an 'ensobjlist' instance) which includes a useful 'find()' method as well. The depth option controls the depth to which the method is allowed to recurse. A value of -1 puts no limits on the recursion.
find_objs() examples:
The ensight.objs.core.find_objs() method can be used in a large number of ways. Some common examples are illustrated here. Note also that: ensight.objs.core.find_objs(...,group=1).CHILDREN will return an ensobjlist interface to objects returned by find_objs().
import ensight
from ensight.objs import *
# find all PART objects in the current case
l = core.find_objs(core.CURRENTCASE,types=[ENS_PART],recurse=1)
# make a group from them...
c = core.create_group(l)
# find all non VISIBLE parts as a group object
g = core.find_objs(core.PARTS,filter={enums.VISIBLE: False},group=1)
# and make them all visible
g.setchildattr(enums.VISIBLE, True)
# find all the VISIBLE, CLIP parts currently selected
d = {enums.VISIBLE: True, enums.PARTTYPE: ensight.PART_CLIP_PLANE}
l = core.find_objs(core.selection(ENS_PART),filter=d)
# define a class with a custom __cmp__ method
class strstr():
def __init__(self, value):
self._v = value
def __cmp__(self, other):
if other.find(self._v) >= 0:
return 0
return 1
def __eq__(self, other):
return other.find(self._v) >= 0
def __ne__(self, other):
return other.find(self._v) < 0
def __lt__(self, other):
return False
def __gt__(self, other):
return False
def __le__(self, other):
return other.find(self._v) >= 0
def __ge__(self, other):
return other.find(self._v) >= 0
# find all parts in the current case that have "Block" in their DESCRIPTION
# Note the function defines both the Python 2 and Python 3 interfaces
# core.find_objs() will only use the __eq__() method, the others are there for completeness
d = {enums.DESCRIPTION: strstr("Block")}
l = core.find_objs(core.CURRENTCASE,filter=d,types=[ENS_PART],recurse=1)
# define a pure comparison case to see if a variable is valid for a case
class casevar():
def __cmp__(self, other):
if other[core.CURRENTCASE[0].CASENUMBER]:
return 0
return 1
def __eq__(self, other):
return other[core.CURRENTCASE[0].CASENUMBER]
def __ne__(self, other):
return not other[core.CURRENTCASE[0].CASENUMBER]
def __lt__(self, other):
return False
def __gt__(self, other):
return False
def __le__(self, other):
return other[core.CURRENTCASE[0].CASENUMBER]
def __ge__(self, other):
return other[core.CURRENTCASE[0].CASENUMBER]
# find active, scalar variables defined for the current case and make a group
# Note the function defines both the Python 2 and Python 3 interfaces
d = {enums.EXIST_CASE: casevar(), enums.ACTIVE: 1, enums.VARTYPE: enums.ENS_VAR_SCALAR}
g = core.find_objs(core.VARIABLES,filter=d,group=1)
# define a class that defines __cmp__ to be the "find" operation
# on a list
class multival():
def __init__(self,lst):
self._list = lst
def __cmp__(self,other):
if self._list.count(other):
return 0
return 1
def __eq__(self, other):
return self._list.count(other) > 0
def __ne__(self, other):
return self._list.count(other) <= 0
def __gt__(self, other):
return False
def __lt__(self, other):
return False
def __ge__(self, other):
return self._list.count(other) > 0
def __le__(self, other):
return self._list.count(other) > 0
# use it to find the parts with descriptions that are in a list
f = {enums.DESCRIPTION: multival(["engine","windshields"])}
parts = core.find_objs(core.PARTS,filter=f)
#
# Returns a list of selected parts
# Resolves selected groups into parts
#
def expand_children(inparts):
output = []
for i in inparts:
lst = core.find_objs(core.PARTS,filter {enums.PARTNUMBER:i,enums.ISGROUP:True})
if len(lst):
for j in lst[0].SOURCES:
output.append(j.PARTNUMBER)
else:
output.append(i)
return output
Note: the “default” lists can be used to generate GUIs, etc without creating an actual item.