Parts: ENS_PART
Methods:
- part.tracepaths([variables=[...]]): method only available on particle trace parts and it returns the coordinates of the particle traces. If variables= is specified, it is a list of variables to return values at the trace points. The list can be a combination of variable objects, string names and variable id numbers. (See: ensight.query() for more details).
- part.realtimemode(mode [,emitter=0]): for parts of type PART_CLIP_PLANE and PART_ISO_SURFACE, these functions allow you to turn on/off the realtime mode for those types. Legal mode values are in enums and include: REALTIME_OFF, REALTIME_MANUAL, REALTIME_AUTO, REALTIME_AUTO_CYCLE. If the part is a particle trace, the emitter number can also be specified.
- part.destroy(): destroy the specific part
- part.createpart([name=n][parent=objs][sources=list]): only available on default parts. It creates a new part of the type selected by the default part. Keywords may be used to select the name of the part and the parent object (ENS_CASE or ENS_GROUP object, the default is the current case). By default, the currently selected parts are used as the sources. A list of parts to use as the sources can be passed by the sources keyword. This can be partnames, partnumbers, ENS_GROUP objs, ENS_PART objs in any mix.
- part.get_values(varlist [,activate=0] [,ids=idlist] [,use_nan=0]): This method gets variable values for the variables specified in varlist on the part. 'varlist' is a list of variable references. These can be any mixture of ENS_VAR objects, variable names (string) or variable ids (integers). The returned value is a dictionary. The keys to the dictionary are the values passed in varlist and the values are NumPy Float arrays. For constants the value is a one dimensional array with a single value. For other scalar variables, the value will be a 1D array of values (complex values are returned as NumPy complex types). For vector, tensor and Coordinate variables, a 2D array is returned. The first dimension is the element or node count and the second dimension will be 3, 9 or 3 respectively (Note: Tensor variables will always be expanded to 9 values when returned). If any nodal variables are returned, an additional key 'NODAL_IDS' will be present and will contain a NumPy array of integers that are the EnSight node IDs for any returned node value. Similarly if any element variables are returned, 'ELEMENT_IDS' will be present. Note if the part does not have elment or nodal ids then a list of [-1,-1,-1,....] will be returned. If the variable is a case constant, the value is returned. If the variable is a part constant, the value for this part is returned. EnSight uses a specific value for the 'Undefined' value (ensight.Undefined), If the keyword argument 'use_nan=1' is used, the API will return NumPy NaN values wherever this value would be returned. By default, if a variable specified in varlist is not active, this method will throw an exception. If 'activate=1' is specified, any inactive variables will be activated as needed. The ids=idlist keyword can be used to restrict the output to a specific collection of element or node ids. If you restrict to a given list of ids and ids are not present then an empty dictionary will be returned. It is not possible to specify separate lists for both node and element ids, so the caller must separate these into two calls. Select your part in the part list and do a Query>Part and the resulting dialog will tell you if you have ids and the ranges of the node and / or element ids.
Examples
An example creating a clip part using the current selection of parts explicitly (note by default the same parents are used implicitly.
# create a new clip using the currently selected parts as parents
a = core.DEFAULTPARTS[ensight.PART_CLIP_PLANE].createpart(sources=core.selection(ENS_PART))
# change its name (remember the return value is a list)
a[0].DESCRIPTION = "Hello"
# add to the current selection
core.selection(ENS_PART).addchild(a[0])
An example of using get_values() with the crash test case:
part = ensight.objs.core.PARTS['engine'][0]
coords = ensight.objs.core.VARIABLES['Coordinates'][0]
d = part.get_values([coords, 'plastic', 'Analysis_Time'],activate=1)
print(d.keys())
['Analysis_Time', 'plastic', Class: ENS_VAR, desc: 'Coordinates', CvfObjID: 1005, cached:no, 'NODE_IDS']
print(d[coords].shape)
(562L, 3L)
print(d['Analysis_Time'][0])
0.235
Attributes:
- PARENT : the object that is the parent of this object in the partlist tree (this is normally an ENS_CASE or ENS_GROUP object)
- METADATA
- CASENUMBER
- PARTNUMBER
- PARTTYPE : valid parttypes include: ensight.PART_MODEL, ensight.PART_CLIP_PLANE, ensight.PART_CONTOUR, ensight.PART_DISCRETE_PARTICLE, ensight.PART_FRAME, ensight.PART_ISO_SURFACE, ensight.PART_PARTICLE_TRACE,
ensight.PART_PROFILE, ensight.PART_VECTOR_ARROW, ensight.PART_ELEVATED_SURFACE, ensight.PART_DEVELOPED_SURFACE, ensight.PART_MODEL_EXTRACT, ensight.PART_MODEL_CUT, ensight.PART_MODEL_BOUNDARY, ensight.PART_ISO_VOLUME, ensight.PART_BUILT_UP, ensight.PART_TENSOR_GLYPH,
ensight.PART_FX_VORTEX_CORE, ensight.PART_FX_SHOCK, ensight.PART_FX_SEP_ATT, ensight.PART_MATERIAL_INTERFACE, ensight.PART_POINT, ensight.PART_AXI_SYMMETRIC, ensight.PART_MODEL_MERGE,
ensight.PART_MULT
- PARTNUMELE : a dictionary containing the number of elements of each each type in the part on the server. The keys may include: “Point element”, “Point element(ghost)”, “Bar2”, “Bar2(ghost)”, “Bar3”, “Bar4(ghost)”, “Tria3”, “Tria3(ghost)”, “Tria3”, “Tria3(ghost)”, “Tria6”, “Tria6(ghost)”, “Quad4”, “Quad4(ghost)”, “Quad8”, “Quad8(ghost)”, “Tetra4”, “Tetra4(ghost)”, “Tetra4”, “Tetra4(ghost)”, “Tetra10”, “Tetra10(ghost)”, “Pyra5”, “Pyra5(ghost)”, “Pyra13”, “Pyra13(ghost)”, “Penta6”, “Penta6(ghost)”, “Penta15”, “Penta15(ghost)”, “Hexa8”, “Hexa8(ghost)”, “Hexa20”, “Hexa20(ghost)”, “N-Sided”, “N-Sided(ghost)”, “N-Sided”, “N-Sided(ghost)”, “N-faced”, “N-faced(ghost)”
- PARTNUMELECLIENT: same as PARTNUMELE, but on the client
- HAS3DELEMENTS: True if the part has 3D elements on the server
- MESHTYPE: 0 if unstructured
- SELECTED: True if selected
- LPARTPARENT: If a model part, a reference to the LPART object that created this part
- ISGROUP : true if the part itself is an ensight group part (not an ENS_GROUP object)
- SOURCES : list of parts used to create this part (or children if a group)
Note: the following method is obsolete. attrtree() should be used instead.
- part.attrgroupinfo(): returns a dictionary of attribute group info that can be used to lay out GUI panels. The method returns a dictionary of the form: {’name’: string, ‘attrlist’: [], ‘grouplist’: [] }. ‘name’ is the name of the tier which starts with ‘MAIN’ at the top of the tree. ‘attrlist’ is a list of the attribute numbers in order for the ‘name’. If there are sub-groups, they will be returned as dictionaries in the list ‘attrlist’ (these dictionaries have the same format as the ‘MAIN’ one.
Example using the attrgroupinfo()/attrinfo() calls:
def walkit(part,v,ins):
print("{} Group name= {}".format(ins, v['name']))
print("{} Attrs:".format(ins))
for i in v['attrlist']:
info = part.attrinfo(i)
print("{} {} ({:d}) - '{}'".format(ins, info['name'], i, info['desc']))
for i in v['grouplist']:
walkit(part,i,ins+" ")
a = core.PARTS[0]
list = a.attrgroupinfo()
walkit(a,list,"")