GetElements - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


DocumentTools[Canvas]

  

GetElements

  

extract elements from a canvas

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

GetElements(canvas)

GetElements(canvas, kind)

GetElements(canvas, options)

Parameters

canvas

-

XML canvas string, or table

kind

-

(optional) one of the following strings or a set containing one or more of "math", "plot", "plot3d", "text", "checkbox", "button", "line", "state"

Description

• 

The GetElements command extracts the content from a canvas inserted by the ShowCanvas command, or Maple Learn canvas constructed by a command, or fetched by the GetCanvas command.

  

Note that ShowCanvas and button actions clicked in an active canvas will set the global variable, _canvas.  If the first argument is omitted, the _canvas global is used. The returned list will contain Record structures describing the content.  Each Record will have a type field, such that elem[i]:-type will return "math", "text", or other identifier.  For elements that have their type member set to "math", there will be a math member containing the value.  Similarly text elements will have a text member containing the value.

• 

A "canvas" is an interactive section of a Maple document created by the NewCanvas command, or a shared web-based Maple Learn document.  See the Script command for a more complete description.

• 

When the keeptext=true option is given, the text content is returned in addition to the math.  The default is to return only the math content.

• 

When the keepall=true option is given, text and other content such as buttons are returned in addition to the math.  

• 

Empty math structures are normally pruned from the result.  Use the keepempty=true option to retain these.  Their math member will be set to the empty string, "".

• 

When the inert=true option is specified, operators will remain in InertForm style.  This prevents simplification, for example, returning `%+`(1,1) instead of 2.

• 

When the mathmlonly=true option is specified, the record's math field will be set to NULL, but the mathml field will remain populated.

• 

By default math markup such as overbar division, exponent superscripts and other "2D" elements in text will cause a retrieved text-field value to be delivered as MathML.   Use textconvert=true to cause the MathML to be converted to a linear "1D" format.

• 

When the custom=string option is specified, only elements that match the given custom attribute will be returned.  

• 

A filter={name=value} option can be used to specify arbitrary properties of any element.  Only elements with the given named properties that also match the given values will be returned in the result.

• 

When group=N is given, only elements that appear in the Nth group will be returned. In this context a group is a canvas group element with the first group starting at 1.  You can also specify group as a range, eg. group=2..4.  Leaving the end-point blank is a short-hand for beginning or end, as group=2.. will find all elements in groups 2 or bigger.

• 

When contentgroup=N is given, only elements that appear with an id prefix of N will be returned. The first contentgroup is 0.

• 

When id=X is given, only the element with the given id will be returned.

• 

By default empty math inputs are excluded from the returned elements.  To include empty elements set keepempty=true.

• 

If position=[a,b] is given, where a and b are numbers or ranges, only elements in the given bounds will be returned.

• 

Similar to the position option, you can provide the option exclude_column=N, where all elements with an x-position greater than N will be excluded.

Examples

Process a canvas from Maple Learn

• 

In this section we will fetch a shared canvas from Maple Learn, and process it.  This is similar to the processing that is done when clicking a button in Maple Learn.

withDocumentTools:-Canvas:

urlhttps://learn.maplesoft.com/?d=OULPGFDHIFNKDLJJGGMKJKNOARBJLHGRPOOKHKCQHPMFKMOTBFEHCUBUCQFNOGKSAMDOCUEFGMAJMQELFLEQEGOMETNULHFSCUGU:

cvGetCanvasurl:

seqelemtype,elem=GetElementscv

seqelemtype,elem=GetElementscv,keepempty

seq`if`elemtype=math,elemmath,elemtext,elem=GetElementscv,math,text

seqelemmath,elem=GetElementscv,math,inert

Process an Active Canvas

• 

In this section we create and show a canvas, then use the global variable _canvas to access the state.

withDocumentTools:-Canvas:

cvNewCanvasAnother GetElements Example,ScriptButtonCheck Your Page,DoNothing,position=500,50:

ShowCanvascv,input=`%+`1,1,x2

av_canvas:

seqelemtype,elem=GetElementsav

seqelemmath,elem=GetElementsav,math,keepempty

seq`if`elemtype=math,elemmath,elemtext,elem=GetElementsav,math,text

seqelemmath,elem=GetElementsav,math,inert

Compatibility

• 

The DocumentTools[Canvas][GetElements] command was introduced in Maple 2022.

• 

For more information on Maple 2022 changes, see Updates in Maple 2022.

• 

The textconvert option was introduced in Maple 2023.

• 

For more information on Maple 2023 changes, see Updates in Maple 2023.

See Also

Annotate

GetCanvas

Math

NewCanvas

Script

ShareCanvas

Text