Skip to content

pydim.update_text

fabian-flassig edited this page Aug 25, 2026 · 1 revision

Changes the content, the placement or the appearance of an existing 2d annotation text.

Similar to the Text -> Correct function in the PYTHA user interface.

pydim.update_text(text, changes)
Parameter Type Description
text element_handle An element handle of type "text".
changes {...} The fields to change. Every field the table does not mention keeps its current value.
changes.text string The new text content.
changes.angle number Rotation of the text in degrees.
changes.orientation string The point of the text box that sits on the text position, see pydim.create_text.
changes.position {x,y} Position of the text in the plane of the view, in object units — the value pydim.get_text reports, not an offset from the anchor.
changes.leader boolean or {...} false deletes every leader of the text. A table applies its values (pen, line_type, flag_length, arrow_length) to the existing leaders.
changes.style {...} The appearance, with the same keys as in pydim.create_text.

Return value

Type Description
boolean true if the text was changed, false if it sits on a locked layer — in that case nothing is changed.

Example:

local t = pydim.create_text("12", {{600, 400, 0}}, {view = "xy", leader = true})

-- renumber and emphasise
pydim.update_text(t, {text = "13", style = {bold = true, pen = 2}})

-- thinner leader
pydim.update_text(t, {leader = {pen = 3, arrow_length = 2}})

-- drop the leader
pydim.update_text(t, {leader = false})

Remarks:

  • The view of a text cannot be changed; create a new text instead.
  • update_text cannot create a leader — a leader needs an arrow tip, which is what pydim.create_text provides. A leader table on a text without leaders does nothing.
  • Changing changes.text recalculates the width of the text box, unless the text has a fixed width or changes.style.width is given.
  • Changing style.in_object_units changes the unit size, width and position are interpreted in, but does not convert the stored values.

Version Support:

Minimum PYTHA Version: V27

See also:

pydim, pydim.create_text, pydim.get_text, pydim.delete_text, element handles

Clone this wiki locally