Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

GraphElem

The GraphElem is the base class for all representations of graph elements: entities, junctors, groups and edges. This class has variables and methods common to all elements.

Fields

FieldTypeDescription
eidintegerRead only. Unique integer assigned to each GraphElem.
isEntitybooleanRead only. Returns False (see Entity.)
isJunctorbooleanRead only. Returns False (see Junctor.)
isGroupbooleanRead only. Returns False (see Group.)
isEdgebooleanRead only. Returns False (see Edge.)
canHaveParentbooleanRead only. Returns False (see VertexElem.)
hasParentbooleanRead only. Returns True if has parent.
frametupleRead only. The element’s bounds as a tuple (left, top, width, height), or (0, 0, 0, 0) if the element is hidden in a collapsed group.
annotationstring or NoneThe annotation (note) of the element, an HTML document as a string, or None if the element has no note. If set to plain text, the font of the annotation defaults to Monospaced/12. The annotation renderer parses the string as XHTML (strict XML), not lenient HTML. Named HTML entities such as &larr; are not recognized and will cause a ScriptingException; use numeric character references (&#8592;) or literal Unicode characters instead. Void elements (<br>, <img>) must be self-closed (<br/>).
isHiddenInCollapsebooleanRead only. Returns True if the element is in a collapsed group, otherwise False.
hasAnnotationbooleanRead only. Returns True if the element has an annotation, otherwise False.
annotationNumberintegerRead only. The annotation (note) number of the element, an integer, or zero if the element has no note.
displayAnnotationNumberintegerRead only. The annotation (note) number of the element if note numbers are displayed as an integer, or zero if the element has no note or note numbers are not displayed.
partFramesdictionaryRead only. A dictionary of tuples (x, y, width, height). The keys are Shape Part Types for visual elements that vary by GraphElem type and state.
plainAnnotationstring or NoneRead only. the annotation (note) of the element as plain text, or None if the element has no note.
annotationEditorTextEditorReturns a TextEditor instance which allows for modification of the annotation, or None if the element has no note (variable is read only, the TextEditor itself can be modified).
userdictionaryA dictionary of user-defined attributes. The variable is read-only but the dictionary is mutable. Supports subscript read/write, del, key in obj, for key in obj, .keys(), .values(), and .items(). Example: previousFacility = elem.user['facility']; elem.user['facility'] = 'Los Angeles'; del elem.user['careless']

Typing: UDA values are typed — str, int, float, or bool. The type is inferred from the Python value assigned: elem.user['n'] = 1 stores an integer, elem.user['n'] = 1.0 stores a float. Assigning a value of a different type changes the attribute's type as well as its value. The UDA Inspector lets users choose an initial type and change it (coercing the value); via script there is no separate "create with type" step. Use a float literal (1.0) rather than an integer (1) when you intend a float attribute.
userDisplayeddictionaryAPI 1.18
Read only. Returns a read-only view of the element's user defined attributes filtered according to the current document and entity-class visibility settings.
userDefinedAttributesVisiblebooleanAPI 1.18
True if user defined attributes are visible independently of the document’s userDefinedAttributesVisible setting.
onCriticalPathbooleanAPI 1.18
Read-only. Returns True if the element is on the critical path. Returns False if project management not enabled.
destroyedbooleanAPI 1.18
Read-only. Returns True if the element has been deleted from the graph. Scripts can use this to check whether a previously-obtained element reference is still valid.

Methods

appendAnnotation( text )

API 1.18
Adds text to the end of the element's annotation, keeping the formatting of what is already there, and returns the annotation as plain text afterwards. Exactly text is added, as plain text; no line break is inserted before it, so begin text with a line break to start a new line. If the element has no annotation, one is created. An empty text changes nothing. Prefer this to assigning plainAnnotation plus new text to annotation, which replaces the annotation with plain text and discards its formatting.

isUserDefinedAttributesVisible()

API 1.18
True if the user defined attributes are visible either because this GraphElem's userDefinedAttributesVisible is True or the document’s userDefinedAttributesVisible for all setting is True, otherwise False.