[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/MxModifyColor
Class: MxModifyColor
2d.MxModifyColor
MxModifyColor is used to temporarily modify the display color of CAD objects.
Description
This class does not change the properties of the object itself, but batch modifies the color of the object through temporary display. It is suitable for scenarios such as differential annotation, preview, and effect display. It can quickly apply color changes and subsequently restore the original display state. Summary of usage:
- Create an instance of 'MxModifyColor';
- Call 'Do (database, color)' to perform color modification;
- Call 'DoRestore()' when restoration is required.
Example
//Temporarily change the color of all objects to white and call to restore the original color again.
import { MxCpp, McCmColor, ColorIndexType } from "mxcad";
let modify: any;
function Mx_Test_ModifyAllEntityColor() {
if (modify) {
modify.DoRestore();
modify = undefined;
}
else {
modify = new MxModifyColor();
let color = new McCmColor();
color.setColorIndex(ColorIndexType.kWhite);
modify.Do(MxCpp.getCurrentDatabase(), color);
}
}Table of contents
Constructors
Methods
Constructors
constructor
• new MxModifyColor()
Methods
Do
▸ Do(database, color): boolean
Modify the display color of objects in the specified database.
Parameters
| Name | Type | Description |
|---|---|---|
| Database | [McDbDatabase] (2d. McDbDatabase. md) | Target database. |
| Color | [McCMColor] (2d. McCmColor. md) | Target color. |
Returns
boolean
Whether the modification was successfully executed.
DoRestore
▸ DoRestore(): void
Restore the color of the object that was temporarily modified before.
Returns
void
