Skip to content

[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McObject TempDraw

Class: McObjectTempDraw

2d.McObjectTempDraw

Temporary Graphics Drawing Manager (McObject TempDraw)

Description

This class is used for high-performance temporary graphic rendering (Overlay) on CAD views. The core feature is "read-only without writing": it allows you to draw graphics on the screen (such as highlights, auxiliary lines, dynamic feedback), But these graphics will not be actually saved to the graphics database. Commonly used to achieve mouse hover highlighting, drag and drop preview, or temporary measurement display.

Summary of usage:

  1. Obtain temporary graphic drawing objects through MxCpp. mxcad. getTempDraw();
  2. Call methods such as' readyMcDbElementsWorldDraw() 'and' setDrawColor() 'to prepare the drawing context;
  3. Call 'worldDrawMcDbElements()' for temporary drawing, and then use 'endMcDbElementsWorldDraw()' to end the drawing.

Example

ts
//Scenario: After selecting an entity, temporarily bold it and turn it red to display (highlight effect)
import { MxCADUtility, MxCpp } from "mxcad";

async function highlightSelectedEntity() {
// 1. Obtain the entity ID selected by the user
Const retIds=await MxCADUtility. setEnt ("Select bold display object");
  if (retIds.length == 0) return;

  const ent = retIds[0].getMcDbEntity();
  if (!ent) return;

// 2. Get temporary drawing context
  const mxcad = MxCpp.getCurrentMxCAD();
  const tempDraw = mxcad.getTempDraw();

// 3. Configure drawing style (red, line width 0.60mm)
tempDraw.clearAll(); //Clear old drawings
tempDraw.readyMcDbEntitysWorldDraw(); //Prepare context
tempDraw.setDrawColor(0xFF0000, 0xFF0000); //Set color
tempDraw.setLineWeightDisplay(true, McDb.LineWeight.kLnWt060); //Set line width

// 4. Execute drawing
  tempDraw.worldDrawMcDbEntitys(ent as any);

// 5. End drawing context
  tempDraw.endMcDbEntitysWorldDraw();
}

Note

  1. The drawn content only exists in the current view frame and may disappear after refreshing or redrawing, requiring a new call.
  2. It is necessary to call 'readyMcDbElementsWorldDraw' and 'endMcDbElementsWorldDraw' in pairs to ensure the correct release of resources.

Table of contents

Constructors

Methods

Constructors

constructor

new McObjectTempDraw(imp)

Constructor function

Parameters

NameTypeDescription
ImpanyObject Implementation

Methods

addLines

addLines(vecLinePoints): void

Add temporary drawing line data

Parameters

NameTypeDescription
VecLinePoints[McGePoint3dArray] (2d. McGePoint3dArray. md)Line Point Array

Returns

void


addTriangles

addTriangles(vecTrianglesPoints): void

Add temporary drawing to fill triangle data

Parameters

NameTypeDescription
VecTrianglePoints[McGePoint3dArray] (2d. McGePoint3dArray. md)Triangle Point Array

Returns

void


clear

clear(): void

Clear temporary drawing data

Returns

void


clearAll

clearAll(): void

Clear all temporary drawing content

Returns

void

Description

Remove all temporary graphics drawn through this type on the current view.


clearMcDbEntitysDisplay

clearMcDbEntitysDisplay(): void

Clear temporary data drawn by McDbEntities

Returns

void


disableDepthTestMcDbEntitysDisplay

disableDepthTestMcDbEntitysDisplay(isDisable?): void

Disable temporary rendering of McDbEntities in OpenGL DepthTest

Parameters

NameTypeDefault valueDescription
IsDisablebooleantrueWhether to disable deep testing, default to true

Returns

void


endMcDbEntitysWorldDraw

endMcDbEntitysWorldDraw(): void

End the temporary drawing context for McDbEntities and release the resources.

Returns

void


freeMcDbEntitysDisplay

freeMcDbEntitysDisplay(): void

Release the temporary drawing context for McDbEntities.

Returns

void


readyMcDbEntitysWorldDraw

readyMcDbEntitysWorldDraw(): void

Prepare temporary drawing context for McDbEntities.

Returns

void


setDrawColor

setDrawColor(color, iMcDbEntityDrawColor?): void

Set Draw color

Parameters

NameTypeDefault valueDescription
Colornumberundefinedcolor value
IMcDbEntity DrawColornumber-2McDbEntity's drawing color

Returns

void


setDrawOrder

setDrawOrder(iDrawOrder, iMcDbEntityDrawOrder): void

Set display order

Parameters

NameTypeDescription
IDrawOrderNumberDrawing Order
IMcDbEntity DrawOrdernumberDrawing order of McDbEntity

Returns

void


setLineWeightDisplay

setLineWeightDisplay(val?, iGlobalLineweight?): void

Enable the display of line weights.

Parameters

NameTypeDefault valueDescription
ValbooleantrueEnable line re display
IGlobalLineweightnumber-1Global line width, default is -1 to use default line width

Returns

void


worldDrawMcDbEntitys

worldDrawMcDbEntitys(ent): boolean

Generate temporary drawn data for McDbEntities

Parameters

NameTypeDescription
EntMcDbEntity (2d. McDbEntity. md)McDbEntity object

Returns

boolean