[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McDbTextCtyleTableRecord
Class: McDbTextStyleTableRecord
2d.McDbTextStyleTableRecord
McDbTextCtyleTableRecord is a single record in a text style sheet used to save and manage text font style parameters.
Description
This class is used to describe a set of text styles, such as font name, size, tilt angle, width factor, and large font parameters. It can accomplish: -Create and configure text styles; -Set font, size, italic, width, and flag position; -Save to text style sheet; -Apply styles to text objects or annotation objects.
Usage:
- Create an instance of McDbTextCtyleTableRecord;
- Set properties such as name, fileName, textSize, xScale, etc;
- Apply to text objects after adding to a text style sheet.
Summary: In practical development, McDbTextCtyleTableRecord is the most fine-grained object for controlling text style and font, suitable for unified management of text styles.
Example
import { McCmColor, MxCpp, McDbTextStyleTableRecord, McDb } from "mxcad"
//Create and set text style records.
async function testTextStyleRecord() {
const mxcad = MxCpp.getCurrentMxCAD();
//Get the current text style sheet
const textSyleTable = mxcad.getDatabase().getTextStyleTable();
//Construct a text style sheet to record objects
let newTextStyleRecord = new McDbTextStyleTableRecord();
//Set object file name
newTextStyleRecord.fileName = "txt.shx";
//Set the large font name for the object
newTextStyleRecord.bigFontFileName = "hztxt.shx";
//Set object text size
newTextStyleRecord.textSize = 10;
//Set object name
newTextStyleRecord.name = sMyTextStyle;
//Set object width factor
newTextStyleRecord.xScale = 0.7;
//Add Text Style
const res = textSyleTable.add(newTextStyleRecord).isValid()
if (res) {
console.log("add ok");
}
}Hierarchy
↳
McDbTextStyleTableRecord
Table of contents
Constructors
Properties
Accessors
Methods
- assertObjectModification
- clone
- createExtensionDictionary
- erase
- font
- getDatabase
- getDatabaseIndexId
- getExtensionDictionary
- getGripEditBasePointsIndex
- getGripPoints
- getHandle
- getImp
- getJson
- getObjectID
- getOwnerID
- initTempObject
- isErased
- isHaveExtensionDictionary
- isKindOf
- isNull
- moveGripPointsAt
- setFont
- setJson
- unErase
Constructors
constructor
• new McDbTextStyleTableRecord(imp?)
Constructor.
Parameters
| Name | Type | Description |
|---|---|---|
imp? | Any | Internal implementation object |
Overrides
Properties
imp
• imp: any = 0
Internal implementation object.
Inherited from
Accessors
bigFontFileName
• get bigFontFileName(): string
Large font file name
Returns
string
• set bigFontFileName(val): void
Parameters
| Name | Type |
|---|---|
val | string |
Returns
void
dxf0
• get dxf0(): string
Obtain the type name of the object's DXF group code, which is the same as the DXF group code in AutoCAD. For example, the type name of the line is McDbLine, and the group code value for DXF0 is: LINE and DXF0 group code values can be used for type filtering when constructing sets.
Returns
string
Inherited from
McDbObject.dxf0
fileName
• get fileName(): string
Font file name
Returns
string
• set fileName(val): void
Parameters
| Name | Type |
|---|---|
val | string |
Returns
void
flagBits
• get flagBits(): number
Get or set a set of flags for a text style sheet record
Returns
number
• set flagBits(val): void
Parameters
| Name | Type |
|---|---|
val | number |
Returns
void
isShapeFile
• get isShapeFile(): boolean
Get or set whether to use shape fonts for text styles
Returns
boolean
• set isShapeFile(val): void
Parameters
| Name | Type |
|---|---|
val | boolean |
Returns
void
isVertical
• get isVertical(): boolean
Get or set whether to use italics for text style
Returns
boolean
• set isVertical(val): void
Parameters
| Name | Type |
|---|---|
val | boolean |
Returns
void
name
• get name(): string
Get or set the name of the text style.
Returns
string
• set name(val): void
Parameters
| Name | Type |
|---|---|
val | string |
Returns
void
objectName
• get objectName(): string
Get the object name.
Returns
string
Return object name
Inherited from
McDbObject.objectName
obliquingAngle
• get obliquingAngle(): number
Tilt angle
Returns
number
• set obliquingAngle(val): void
Parameters
| Name | Type |
|---|---|
val | number |
Returns
void
textSize
• get textSize(): number
Text size (height)
Returns
number
• set textSize(val): void
Parameters
| Name | Type |
|---|---|
val | number |
Returns
void
xScale
• get xScale(): number
Scale factor size
Returns
number
• set xScale(val): void
Parameters
| Name | Type |
|---|---|
val | number |
Returns
void
Methods
assertObjectModification
▸ assertObjectModification(autoUndo?): number
Setting the state of the object to be changed can automatically trigger the update display function to update the display. For example, if the block table record is updated and the block reference needs to be notified to update the display, this function can be called.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AutoUndo | boolean | false | Should this modification automatically support undo? Default is false |
Returns
number
Inherited from
McDbObject.assertObjectModification
clone
▸ clone(): null | McDbObject
Clone objects.
Returns
null | McDbObject
The cloned object.
Inherited from
createExtensionDictionary
▸ createExtensionDictionary(): boolean
Create extended dictionary data for objects
Returns
boolean
Inherited from
McDbObject.createExtensionDictionary
erase
▸ erase(): boolean
Delete object.
Returns
boolean
Whether the deletion was successful.
Inherited from
font
▸ font(): Object
Get font style
Returns
Object
sTypeface: Font Name | bold: bold or not | italic: italic or not | charset: character set | pitchAndFamily: font spacing and style
| Name | Type |
|---|---|
bold | boolean |
charset | number |
italic | boolean |
pitchAndFamily | number |
sTypeface | string |
getDatabase
▸ getDatabase(): McDbDatabase
Get the database where the object is located
Returns
Return to database
Inherited from
getDatabaseIndexId
▸ getDatabaseIndexId(): number
Get the index ID of the object
Returns
number
Inherited from
getExtensionDictionary
▸ getExtensionDictionary(): McDbDictionary
Obtain the extended dictionary data of the object
Returns
Expand dictionary data
Inherited from
McDbObject.getExtensionDictionary
getGripEditBasePointsIndex
▸ getGripEditBasePointsIndex(): number[]
Retrieve the edit base point index corresponding to the grip of the object.
Returns
number[]
Inherited from
McDbObject.getGripEditBasePointsIndex
getGripPoints
▸ getGripPoints(): McGePoint3dArray
Get the grip array of the object
Returns
Inherited from
getHandle
▸ getHandle(): string
Obtain object handle
Returns
string
Return object handle
Inherited from
getImp
▸ getImp(): any
Retrieve internal implementation objects.
Returns
any
Internal implementation object.
Inherited from
getJson
▸ getJson(): string
Retrieve a string in JSON format.
Returns
string
A string in JSON format.
Inherited from
getObjectID
▸ getObjectID(): McObjectId
Get the object ID.
Returns
Object ID.
Inherited from
getOwnerID
▸ getOwnerID(): number
Obtain the ID of the object owner
Returns
number
Inherited from
initTempObject
▸ initTempObject(imp): void
Initialize temporary objects.
Parameters
| Name | Type | Description |
|---|---|---|
| 'imp' | 'any' | Internal implementation object |
Returns
void
Inherited from
isErased
▸ isErased(): boolean
Has the object been deleted
Returns
boolean
Inherited from
isHaveExtensionDictionary
▸ isHaveExtensionDictionary(): boolean
Is there any extended dictionary data available
Returns
boolean
Inherited from
McDbObject.isHaveExtensionDictionary
isKindOf
▸ isKindOf(sObjectName): boolean
Determine object type
Parameters
| Name | Type | Description |
|---|---|---|
| SOrtName | string | Type Name |
Returns
boolean
Return whether the object is of the target type
Inherited from
isNull
▸ isNull(): any
Determine if it is an empty object
Returns
any
Inherited from
moveGripPointsAt
▸ moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset): any
Grips for moving objects
Parameters
| Name | Type | Description |
|---|---|---|
| IIndex | Number | Index |
| DXOffset | number | X-axis offset |
| DYOffset | number | Y-axis offset |
| DZOffset | number | Z-axis offset |
Returns
any
Inherited from
setFont
▸ setFont(sTypeface, bold, italic, charset, pitchAndFamily): boolean
Set font style
Parameters
| Name | Type | Description |
|---|---|---|
| STypeface | string | Font Name |
| Bold | boolean | Is it bold |
| Italic | boolean | italic or not |
| Charset | number | character set |
| PitchAndFamily | number | Font spacing and style |
Returns
boolean
Is the setting successful
Example
import { McDbTextStyleTableRecord } from 'mxcad';
const newTextStyleRecord = new McDbTextStyleTableRecord();
//Set font
const typeface = "Arial"; // Font Name
const isBold = true; // Is it bold
const isItalic = false; // Is it italicized
const charset = 0; // character set
const pitchAndFamily = 0; // Font spacing and style
const isSetFontSuccessful = newTextStyleRecord.setFont(typeface, isBold, isItalic, charset, pitchAndFamily);
//Check if the settings are successful
if (isSetFontSuccessful) {
console.log("Font set successfully.");
} else {
console.log("Failed to set font.");
}setJson
▸ setJson(str): boolean
Set a string in JSON format.
Parameters
| Name | Type | Description |
|---|---|---|
| Str | string | JSON formatted string |
Returns
boolean
Is the setting successful.
Inherited from
unErase
▸ unErase(): boolean
Anti delete object.
Returns
boolean
