Table of Contents

CadMTextEditor

from OpenCAD2D import CadMTextEditor

class CadMTextEditor(System.Object) · CadMTextEditor in the .NET reference

The words of an MTEXT being edited in place, as AutoCAD's text editor holds them: letters of a look each, paragraphs, a caret and a selection, and what the Text Editor tab does to them, each written back by CadMTextEditor.Contents in AutoCAD's codes (CadMTextContent). It knows no window: the editor on the canvas and a test call it the same way.

Constructors

__init__

.NET

def __init__(
    self,
    contents: str,
    height: float,
    styleFont: str | None = ...,
    styleIsShx: bool = ...,
    defaultAlignment: str = ...,
) -> None

Opens the words of an MTEXT for editing.

def __init__(
    self,
    contents: str,
    height: float,
    frame: CadMTextFrame,
    styleFont: str | None = ...,
    styleIsShx: bool = ...,
    defaultAlignment: str = ...,
) -> None

Opens the words of an MTEXT for editing in its box: the width, height and columns the ruler and Column Settings change.

def __init__(
    self,
    contents: str,
    height: float,
    frame: CadMTextFrame,
    styleWidth: float,
    styleFont: str | None = ...,
    styleIsShx: bool = ...,
    defaultAlignment: str = ...,
    fieldShown: System.Collections.Generic.IReadOnlyList[str] | None = ...,
) -> None

Opens the words of an MTEXT in a style of letters of another width for editing in its box: a width in times of the style's ({\W1.2x;ABC}) is read as times that width, 0.96 in a style of 0.8, as AutoCAD 2021 draws it, and written back as that width (\W0.9600;).

Properties and fields

Alignment

.NET

@property
def Alignment(self) -> str

Gets the alignment of the paragraph the caret is in: l, c, r, j or d.

Anchor

.NET

@property
def Anchor(self) -> int

Gets the other end of the selection; the caret where nothing is selected.

AutoCaps

.NET

@property
def AutoCaps(self) -> bool
@AutoCaps.setter
def AutoCaps(self, value: bool) -> None

Gets or sets AutoCAPS: while on, letters typed, pasted or imported go in as capitals. Letters already there are not changed (Change Case does that); the setting is not an undo step.

CanBold

.NET

@property
def CanBold(self) -> bool

Gets whether bold and italic can be given to the look shown: its font, or the style's, is a TrueType font.

CanRedo

.NET

@property
def CanRedo(self) -> bool

Gets whether a change taken back can be made again.

CanUndo

.NET

@property
def CanUndo(self) -> bool

Gets whether a change can be taken back.

Caret

.NET

@property
def Caret(self) -> int

Gets the place of the caret, 0 to CadMTextEditor.Length.

Content

.NET

@property
def Content(self) -> CadMTextContent

Gets the words as paragraphs of runs, for drawing them.

Contents

.NET

@property
def Contents(self) -> str

Gets the words with their codes, as AutoCAD writes them.

CurrentFormat

.NET

@property
def CurrentFormat(self) -> CadMTextParagraphFormat

Gets how the caret's paragraph is set, or the first selected one's, as the ruler shows it.

CurrentLook

.NET

@property
def CurrentLook(self) -> CadMTextLook

Gets the look the ribbon shows: of the letters typed next where nothing is selected, else of the first selected.

DefaultAlignment

.NET

@property
def DefaultAlignment(self) -> str

Gets how a paragraph with no alignment code is aligned.

Frame

.NET

@property
def Frame(self) -> CadMTextFrame

Gets the MTEXT's box as the ruler and Column Settings have it now.

HasFields

.NET

@property
def HasFields(self) -> bool

Gets whether any place holds a field.

Height

.NET

@property
def Height(self) -> float

Gets the MTEXT's height, of which a run's height is written as a factor.

IsChanging

.NET

@property
def IsChanging(self) -> bool

Gets whether a ruler drag is going on (CadMTextEditor.BeginChange): its changes are one undo step when it ends.

IsMatching

.NET

@property
def IsMatching(self) -> bool

Gets whether Match Text Formatting waits for letters to give a look to: CadMTextEditor.BeginMatch was called and neither CadMTextEditor.ApplyMatch nor CadMTextEditor.CancelMatch has ended it.

IsModified

.NET

@property
def IsModified(self) -> bool

Gets whether the words differ from what they were when the editor opened.

Length

.NET

@property
def Length(self) -> int

Gets the number of places: letters, symbols and paragraph breaks.

Original

.NET

@property
def Original(self) -> str

Gets the words as they were when the editor opened.

OriginalFrame

.NET

@property
def OriginalFrame(self) -> CadMTextFrame

Gets the MTEXT's box as it was when the editor opened.

ParagraphCount

.NET

@property
def ParagraphCount(self) -> int

Gets how many paragraphs the words make, at least one.

SelectedParagraphs

.NET

@property
def SelectedParagraphs(self) -> System.ValueTuple[int, int]

Gets the first and the last paragraph the selection, or the caret, is in.

SelectedText

.NET

@property
def SelectedText(self) -> str

Gets the selected words as shown.

SelectionLength

.NET

@property
def SelectionLength(self) -> int

Gets how many places are selected.

SelectionStart

.NET

@property
def SelectionStart(self) -> int

Gets where the selection starts.

StyleFont

.NET

@property
def StyleFont(self) -> str

Gets the font of the MTEXT's style.

StyleIsShx

.NET

@property
def StyleIsShx(self) -> bool

Gets whether the style's font is an SHX file.

StyleWidth

.NET

@property
def StyleWidth(self) -> float

Gets the width factor of the MTEXT's style, of which a width in times (\W1.2x;) is read; 1 for none given.

Text

.NET

@property
def Text(self) -> str

Gets the words as shown, a line feed for each paragraph break, a symbol as its letter (° for %%d).

Events

Changed

.NET

@property
def Changed(self) -> System.EventHandler[System.EventArgs]
@Changed.setter
def Changed(self, value: System.EventHandler[System.EventArgs]) -> None

Raised when the words, the looks, the caret or the selection change.

Methods

ApplyMatch

.NET

def ApplyMatch(self) -> bool

Gives the look CadMTextEditor.BeginMatch took to the selected letters, all of it (the font, bold, italic, underline, overline, strikethrough, colour, height, slant, tracking and width), one undo step, and ends Match Text Formatting. Nothing is done where no letters are selected, and the brush waits.

Backspace

.NET

def Backspace(self) -> None

Backspace: the selection taken out, or the place before the caret.

BeginChange

.NET

def BeginChange(self) -> None

Starts a drag of the ruler: what changes until CadMTextEditor.EndChange is shown at once but makes one undo step at the end, or none where the drag is put back.

BeginMatch

.NET

def BeginMatch(self) -> None

Starts Match Text Formatting, the brush of the Formatting panel: takes the look of the selected letters, or of the letters typed next where none are selected, for CadMTextEditor.ApplyMatch to give to the letters selected next.

CancelMatch

.NET

def CancelMatch(self) -> None

Ends Match Text Formatting with nothing given.

ChangeCase

.NET

def ChangeCase(self, upper: bool) -> None

Changes the selected letters to capitals or to small letters, as AutoCAD's Change Case.

ClearFormatting

.NET

def ClearFormatting(self) -> None

Clears the codes of the selected letters (Clear formatting), as AutoCAD's Remove Character Formatting.

ConvertFieldToText

.NET

def ConvertFieldToText(self, index: int) -> None

Makes the field a place holds words, as Convert Field To Text does: the words it showed, each letter a place of the look the field had, written as they are and no longer as a code.

Delete

.NET

def Delete(self) -> None

Delete: the selection taken out, or the place after the caret.

EndChange

.NET

def EndChange(self, keep: bool) -> None

Ends a drag of the ruler: its changes kept as one undo step (the release), or put back (Esc).

FieldCodeAt

.NET

def FieldCodeAt(self, index: int) -> str

Gets the code of the field a place holds, in its markers; null where the place holds none.

FindNext

.NET

def FindNext(self, find: str, options: CadMTextFindOptions) -> bool

Finds the next match of words after the selection, or the caret, the search going round to the start, and selects it: Find and Replace's Find Next. A symbol or a stack counts as one place, which no words match.

def FindNext(self, find: str, matchCase: bool) -> bool

Finds words after the caret, the search going round to the start, and selects them.

FormatOf

.NET

def FormatOf(self, paragraph: int) -> CadMTextParagraphFormat

Gets how a paragraph is set: its own codes over those of the paragraphs before it, as AutoCAD carries them on. In an MTEXT 2.5 high, \pxt4;A\PB has a tab stop at 10 in both paragraphs.

InsertColumnBreak

.NET

def InsertColumnBreak(self) -> None

Puts a column break at the caret (Alt+Enter), over the selection: the words after it start the next column.

InsertContent

.NET

def InsertContent(self, content: CadMTextContent) -> None

Puts the words of a file at the caret, over the selection, in the looks they come with: Import Text. The paragraphs and runs are those CadMTextImport reads from a text or an RTF file; a run with no look of its own takes the look of the letters typed there. One undo step.

InsertField

.NET

def InsertField(self, shown: str, code: str) -> None

Inserts a field as AutoCAD's Insert Field does: one place, shown as the words the field came to and written as its code in markers (%<\AcVar Date \f "dd/MM/yyyy">%), in the look of the letters typed there.

InsertSymbol

.NET

def InsertSymbol(self, shown: str, code: str) -> None

Inserts a symbol as AutoCAD's Symbol menu writes it: shown as its letter, written as its code (%%d, \U+2248).

LookAt

.NET

def LookAt(self, index: int) -> CadMTextLook

Gets the look of a place: of its letter, the look the letters typed there take for a break.

MoveTo

.NET

def MoveTo(self, place: int, extend: bool = ...) -> None

Moves the caret, the selection grown from its other end where extend, as Shift does.

NumberingOf

.NET

def NumberingOf(self, paragraph: int) -> CadMTextNumbering

Gets the label a paragraph opens with, as CadMTextEditor.SetNumbering writes them: in 1.\tPlate\Pb.\tBeam\PColumn the first is CadMTextNumbering.Number, the second CadMTextNumbering.LetterLower and the third CadMTextNumbering.Off.

OwnAlignmentOf

.NET

def OwnAlignmentOf(self, paragraph: int) -> str

Gets the alignment a paragraph carries of its own: l, c, r, j or d; nought where it follows the MTEXT's attachment.

ParagraphOf

.NET

def ParagraphOf(self, place: int) -> int

The paragraph a place is in, counted from nought.

Redo

.NET

def Redo(self) -> bool

Makes the last change taken back again.

RenumberList

.NET

def RenumberList(self, continuePrevious: bool) -> bool

Starts or continues the numbering of the list the first selected paragraph is in, as the Start and Continue items of Bullets and Numbering do, one undo step: Start numbers that paragraph 1 (or a, A) and the paragraphs of the same list after it from there, so that with the caret in Beam, 1.\tPlate\P2.\tBeam\P3.\tColumn becomes 1.\tPlate\P1.\tBeam\P2.\tColumn; Continue numbers it on from the paragraph before, which puts the second back. A list is the run of paragraphs with the same kind of label. Nothing is done, and false answered, for a paragraph with no number or letter label (none, or a bullet), or for Continue where the paragraph before has not the same kind of label.

Replace

.NET

def Replace(self, find: str, replace: str, options: CadMTextFindOptions) -> bool

Find and Replace's Replace: where the selection is a match of the words it is replaced, in the look of its first letter and as one undo step, and the next match is selected; else the next match is selected, as Find Next does, and nothing is replaced.

ReplaceAll

.NET

def ReplaceAll(self, find: str, replace: str, options: CadMTextFindOptions) -> int

Replaces every match of words with others, each in the look of the letter it starts at, as one undo step: Find and Replace's Replace All. The text put in is not searched again, so that replacing "a" with "aa" ends.

def ReplaceAll(self, find: str, replace: str, matchCase: bool) -> int

Replaces every match of words with others, each in the look of the letter it starts at, as one change; Find and Replace's Replace All.

ReplaceField

.NET

def ReplaceField(self, index: int, shown: str, code: str) -> None

Gives the field a place holds another code and words, as Edit Field does; its look kept.

ReplaceText

.NET

def ReplaceText(self, start: int, length: int, text: str) -> None

Puts words in the place of some places, in the look of the first of them, as one undo step, the caret after the words: a suggestion of the spell check picked from the menu. AutoCAPS does not change them.

Select

.NET

def Select(self, start: int, length: int) -> None

Selects places.

SelectAll

.NET

def SelectAll(self) -> None

Selects every place, as Ctrl+A.

SetAlignment

.NET

def SetAlignment(self, alignment: str) -> None

Aligns the paragraphs the selection or the caret is in: l, c, r, j or d.

SetBold

.NET

def SetBold(self, on: bool) -> None

Makes the letters bold or not (Ctrl+B); nothing on letters of an SHX font.

SetColorIndex

.NET

def SetColorIndex(self, index: int | None) -> None

Gives the letters a colour of the index: 256 ByLayer, 0 ByBlock; null for the MTEXT's own.

SetFont

.NET

def SetFont(self, font: str, shx: bool) -> None

Gives the letters a font: a TrueType family keeping bold and italic, or an SHX file; null for the style's.

SetFormat

.NET

def SetFormat(self, change: System.Func[CadMTextParagraphFormat, CadMTextParagraphFormat]) -> None

Changes how the selected paragraphs, or the caret's, are set: their indents, tab stops and spacing, one undo step. Each is written as AutoCAD writes it, what differs from the paragraph before, and the paragraph after them is written back to how it was: a tab stop at 10 set on the first of "A", "B" in an MTEXT 2.5 high writes \pxt4;A\P\ptz;B.

SetFrame

.NET

def SetFrame(self, frame: CadMTextFrame) -> None

Changes the MTEXT's box: its width, defined height or columns, one undo step.

SetHeight

.NET

def SetHeight(self, height: float) -> None

Gives the letters a height in drawing units; the MTEXT's own height or less than nought is none of their own.

SetItalic

.NET

def SetItalic(self, on: bool) -> None

Makes the letters italic or not (Ctrl+I); nothing on letters of an SHX font.

SetNumbering

.NET

def SetNumbering(self, numbering: CadMTextNumbering) -> None

Labels the selected paragraphs, or the caret's, as a list, as AutoCAD 2021's Bullets and Numbering does, one undo step: each opens with its label and a tab, the paragraphs hanging 3 heights in with a tab stop there, and a label one had is replaced. In an MTEXT 2.5 high, "Plate", "Beam" numbered is written \pxi-3,l3,t3;1.\tPlate\P2.\tBeam and bulleted \pxi-3,l3,t3;{\fSymbol|b0|i0|c2|p18;·\t}Plate\P{\fSymbol|b0|i0|c2|p18;·\t}Beam, as AutoCAD's TextEditor writes them (probed). CadMTextNumbering.Off takes the labels, the indent and the stop away.

SetOblique

.NET

def SetOblique(self, degrees: float) -> None

Slants the letters by degrees; nought is none of their own.

SetOverline

.NET

def SetOverline(self, on: bool) -> None

Overlines the letters or not.

SetStrikethrough

.NET

def SetStrikethrough(self, on: bool) -> None

Strikes the letters through or not.

SetTracking

.NET

def SetTracking(self, factor: float) -> None

Spaces the letters by a factor of their usual spacing; 1 is none of their own.

SetUnderline

.NET

def SetUnderline(self, on: bool) -> None

Underlines the letters or not (Ctrl+U).

SetWidthFactor

.NET

def SetWidthFactor(self, factor: float) -> None

Widens or narrows the letters by a factor; 1 is none of their own.

TextAt

.NET

def TextAt(self, index: int) -> str

Gets the letters a place shows: a line feed for a paragraph break.

Type

.NET

def Type(self, text: str) -> None

Types letters over the selection, each line feed a new paragraph, in the look of the letters typed there.

Undo

.NET

def Undo(self) -> bool

Takes the last change back.