Skip to content

[mxcad_2d API Document] (../README. md)/[2d] (../modules/2d. md)/MxCADUiPrKeyWord

Class: MxCADUiPrKeyWord ​

2d.MxCADUiPrKeyWord

MxCADUiPrKeyWord is a prompt class used for interactive input of keyword options.

Description

This class is used to allow users to select an option from a set of keywords, such as "add/modify/delete", "automatic/manual", "yes/no", etc. Commonly used for command branch selection and interactive parameter confirmation, suitable for simplifying the user decision-making process of complex commands. Usage:

  1. Create a keyword input tool using new MxCADUiPrKeyWord();
  2. Call setKeyWords() to set the keyword list;
  3. Call go() and wait for the user to select;
  4. After obtaining the return value, use value() or keyWordPicked() to continue with the next logical step.

Example

ts
import { MxCADUiPrKeyWord } from "mxcad";

const getKey = new MxCADUiPrKeyWord();
GetKey.setMessage ("Please choose the operation method");
GetKey. setKeyWords ("[Manual (M)/Automatic (A)]");
const key = await getKey.go();
if (!key) return;

Console.log ("user selection:", key);

Hierarchy ​

Table of contents ​

Constructors ​

Methods ​

Constructors ​

constructor ​

• new MxCADUiPrKeyWord()

Constructor function

Overrides ​

MxCADUiPrBase.constructor

Methods ​

abort ​

▸ abort(cause?): void

Stop the current dynamic drag

Parameters ​

NameTypeDefault value
causeDetailedResultDetailedResult.kCodeAbort

Returns ​

void

void

Inherited from ​

MxCADUiPrBase.abort


clearLastInputPoint ​

▸ clearLastInputPoint(): void

Clear the previous input point data.

Returns ​

void

Inherited from ​

MxCADUiPrBase.clearLastInputPoint


disableAllTrace ​

▸ disableAllTrace(isDisable?): void

Disable all tracking

Parameters ​

NameTypeDefault valueDescription
IsDisablebooleantrueIs it disabled

Returns ​

void

Inherited from ​

MxCADUiPrBase.disableAllTrace


drawReserve ​

▸ drawReserve(callAddEntity?): void

Keep the dynamically drawn objects on the graph.

Parameters ​

NameTypeDescription
callAddEntity?(ent: Objecti3D)=>voidcallback parameter ent type: THREE.THREE.Object3D

Returns ​

void

Example

ts
//Example of MxCADUiPrPoint class
 import { MxCADUiPrPoint } from 'mxcad';

 async function test(){
   const getPoint = new MxCADUiPrPoint();
   const basePt = new McGePoint3d(0, 0, 0);
   getPoint.setBasePt(basePt);
   getPoint.setUserDraw((pt,pw)=>{
   const line = new McDbLine(basePt, pt);
   pw.drawMcDbEntity(line)
   })
   const val = await getPoint.go();
   if (!val) return;
   getPoint.drawReserve()
 }

Inherited from ​

MxCADUiPrBase.drawReserve


getCursorType ​

▸ getCursorType(): MxCursorType

Return cursor type

Returns ​

MxCursorType

Inherited from ​

MxCADUiPrBase.getCursorType


getDetailedResult ​

▸ getDetailedResult(): DetailedResult

Return detailed reasons for interactive operation exit

Returns ​

DetailedResult

The return value type of the current interactive operation

Example

ts
//Example of MxCADUiPrList class
  import { MxCADUiPrDist } from 'mxcad';
  import { DetailedResult } from "mxdraw";

  async function test(){
    const getDist = new MxCADUiPrDist();
    const val = await getDist.go();
    if (!val) return;
    if (getDist.getDetailedResult() === DetailedResult.kCoordIn) {
Console.log ('prompt input', val)
    }
  }

Inherited from ​

MxCADUiPrBase.getDetailedResult


getDynamicInputType ​

▸ getDynamicInputType(): DynamicInputType

Return dynamic input type

Returns ​

DynamicInputType

Dynamic input display type

Inherited from ​

MxCADUiPrBase.getDynamicInputType


getInputToucheType ​

▸ getInputToucheType(): number

Return the required Touche input type

Returns ​

number

Touche input type

Inherited from ​

MxCADUiPrBase.getInputToucheType


getLastInputPoint ​

▸ getLastInputPoint(): undefined | McGePoint3d

Return to the previous input point.

Returns ​

undefined | McGePoint3d

Selected keywords

Inherited from ​

MxCADUiPrBase.getLastInputPoint


getResultPointOsnapMode ​

▸ getResultPointOsnapMode(): AcquirePointOsnapMode

Return the capture type of the point obtained from the interactive point taking operation

Returns ​

AcquirePointOsnapMode

Inherited from ​

MxCADUiPrBase.getResultPointOsnapMode


getResultPointType ​

▸ getResultPointType(): AcquirePointType

Return the point type obtained from the interactive point retrieval operation

Returns ​

AcquirePointType

Inherited from ​

MxCADUiPrBase.getResultPointType


getStatus ​

▸ getStatus(): MrxDbgUiPrBaseReturn

Get operation status

Returns ​

MrxDbgUiPrBaseReturn

Operation status value

Example

ts
//Example of MxCADUiPrList class
 import { MxCADUiPrDist } from 'mxcad';
 import { MrxDbgUiPrBaseReturn } from "mxdraw";

 const getDist = new MxCADUiPrDist();
 const val = await getDist.go();
 if (!val) return;
 if(getPoint.getStatus() === MrxDbgUiPrBaseReturn.kNone) {
//Empty input
 }

Inherited from ​

MxCADUiPrBase.getStatus


go ​

▸ go(): Promise<null | string>

Start dynamic dragging

Returns ​

Promise<null | string>

Return a promise object containing the keywords entered by the user

Example

ts
import { MxCADUiPrKeyWord } from 'mxcad'

const getType = new MxCADUiPrKeyWord();
GetType.setMessage ('Select Connection Method ');
GetType.setKeyWords ('[Manual Connect One by One (H)/Automatic Batch Connect (A)] ')
const type = await getType.go();
if (!type) return;

isDisableDynInput ​

▸ isDisableDynInput(): boolean

Do you want to disable dynamic input boxes

Returns ​

boolean

Inherited from ​

MxCADUiPrBase.isDisableDynInput


isDisableDynamicTrace ​

▸ isDisableDynamicTrace(): boolean

Do you want to disable dynamic tracking

Returns ​

boolean

Inherited from ​

MxCADUiPrBase.isDisableDynamicTrace


isDisableGridTrace ​

▸ isDisableGridTrace(): boolean

Do you want to disable grid tracking

Returns ​

boolean

Inherited from ​

MxCADUiPrBase.isDisableGridTrace


isDisableOrthoTrace ​

▸ isDisableOrthoTrace(): boolean

Do you want to disable ortho tracing

Returns ​

boolean

Inherited from ​

MxCADUiPrBase.isDisableOrthoTrace


isDisableOsnap ​

▸ isDisableOsnap(): boolean

Do you want to disable capture

Returns ​

boolean

Inherited from ​

MxCADUiPrBase.isDisableOsnap


isDisablePolarAxisTrace ​

▸ isDisablePolarAxisTrace(): boolean

Do you want to disable polar tracking

Returns ​

boolean

Inherited from ​

MxCADUiPrBase.isDisablePolarAxisTrace


isKeyWordPicked ​

▸ isKeyWordPicked(matchKeyWord): boolean

Test whether a certain keyword is selected by the user

Parameters ​

NameTypeDescription
MatchKeyWordstringKeywords to be detected

Returns ​

boolean

True is true

Example

ts
//Example of MxCADUiPrPoint class
  import { MxCADUiPrPoint } from 'mxcad';

 async function test(){
   const getPoint = new MxCADUiPrPoint();
GetPoint. setKeyWords ("[Option 1 (A)/Option 2 (B)]");
   const pt = await getPoint.go();
   if(getPoint.isKeyWordPicked('A')){
Console.log (Option 1)
   }else if(getPoint.isKeyWordPicked('B')){
Console.log (Option 2)
   }
 }

Inherited from ​

MxCADUiPrBase.isKeyWordPicked


isOffsetInputPostion ​

▸ isOffsetInputPostion(): boolean

Whether the input point is offset for display/processing

Returns ​

boolean

Inherited from ​

MxCADUiPrBase.isOffsetInputPostion


keyWordPicked ​

▸ keyWordPicked(): string

Return the keywords selected by the user

Returns ​

string

Selected keywords

Example

ts
//Example of MxCADUiPrPoint class
  import { MxCADUiPrPoint } from 'mxcad';

  async function test(){
   const getPoint = new MxCADUiPrPoint();
GetPoint. setKeyWords ("[Option 1 (A)/Option 2 (B)]");
   const pt = await getPoint.go();
   const key = getPoint.keyWordPicked();
   console.log(key)
  }

Inherited from ​

MxCADUiPrBase.keyWordPicked


keyWords ​

▸ keyWords(): string

Return keyword list

Returns ​

string

Keyword List

Example

ts
//Taking the MxCADUiPrPoint class as an example, the same applies to other classes in the MxCADUiPr * series
  import { MxCADUiPrPoint } from 'mxcad'
  const getPoint = new MxCADUiPrPoint();
GetPoint. setKeyWords ("[Option 1 (A)/Option 2 (B)]");
  const keyList = getPoint.keyWords();
Console.log ("Keyword List", keyList)//Keyword List [Option 1 (A)/Option 2 (B)]

Inherited from ​

MxCADUiPrBase.keyWords


message ​

▸ message(): string

Prompt string

Returns ​

string

Reminder message

Inherited from ​

MxCADUiPrBase.message


setCursorType ​

▸ setCursorType(type): void

Set cursor type

Parameters ​

NameTypeDescription
TypeMxCursorTypeMouse Style Type

Returns ​

void

Example

ts
//Example of MxCADUiPrPoint class
  import { MxCADUiPrPoint } from 'mxcad';
  import { MxCursorType } from "mxdraw";

  async function test(){
   const getPoint = new MxCADUiPrPoint()
GetPoint.setMessage ("Specify text starting point:")
   getPoint.setCursorType(MxCursorType.kCross);
   const pt = await getPoint.go();
  }

Inherited from ​

MxCADUiPrBase.setCursorType


setDisableDynInput ​

▸ setDisableDynInput(isDisable): void

Set whether to disable dynamic input boxes

Parameters ​

NameTypeDescription
IsDisablebooleanIs it disabled

Returns ​

void

Inherited from ​

MxCADUiPrBase.setDisableDynInput


setDisableDynamicTrace ​

▸ setDisableDynamicTrace(isDisable): void

Set whether to disable dynamic tracking

Parameters ​

NameTypeDescription
IsDisablebooleanIs it disabled

Returns ​

void

Inherited from ​

MxCADUiPrBase.setDisableDynamicTrace


setDisableGridTrace ​

▸ setDisableGridTrace(isDisable): void

Set whether to disable grid tracking

Parameters ​

NameTypeDescription
IsDisablebooleanIs it disabled

Returns ​

void

Inherited from ​

MxCADUiPrBase.setDisableGridTrace


setDisableOrthoTrace ​

▸ setDisableOrthoTrace(isDisable): void

Set whether to disable orthotracing

Parameters ​

NameTypeDescription
IsDisablebooleanIs it disabled

Returns ​

void

Inherited from ​

MxCADUiPrBase.setDisableOrthoTrace


setDisableOsnap ​

▸ setDisableOsnap(isDisable): void

Set whether to disable capture

Parameters ​

NameTypeDescription
IsDisablebooleanIs it disabled

Returns ​

void

Inherited from ​

MxCADUiPrBase.setDisableOsnap


setDisablePolarAxisTrace ​

▸ setDisablePolarAxisTrace(isDisable): void

Set whether to disable polar tracking

Parameters ​

NameTypeDescription
IsDisablebooleanIs it disabled

Returns ​

void

Inherited from ​

MxCADUiPrBase.setDisablePolarAxisTrace


setDynamicInputType ​

▸ setDynamicInputType(type): void

Set dynamic input type

Parameters ​

NameTypeDescription
TypeDynamicInputTypeDynamic Input Display Type

Returns ​

void

Example

ts
//Example of MxCADUiPrPoint class
  import { MxCADUiPrPoint } from 'mxcad';
  import { DynamicInputType } from "mxdraw";

  async function Mx_WindowZoom() {
    let getPoint = new MxCADUiPrPointTransform(MxInsidePublicFuns.getMxCADViewSpinMatrix(MxCpp.getCurrentMxCAD()));
    getPoint.disableAllTrace();
GetPoint.setMessage ("\ n Click to zoom area");
    getPoint.setDynamicInputType(DynamicInputType.kDynTip);
    let pt1 = await getPoint.go();
    if (pt1 == null) return;
    let mxcad = MxCpp.getCurrentMxCAD();
    getPoint.setUserDraw((p1, worldDraw) => {
        worldDraw.drawRect(MxCoordConvert.cad2doc1((pt1 as any)), MxCoordConvert.cad2doc1((p1 as any)));
    });

    let pt2 = await getPoint.go();
    if (pt2 == null) return;

    pt1.transformBy(getPoint.rmat);
    pt2.transformBy(getPoint.rmat);
    mxcad.zoomW(pt1, pt2);
 }

Inherited from ​

MxCADUiPrBase.setDynamicInputType


setInputToucheType ​

▸ setInputToucheType(toucheType): void

Set the required Touche input type, default value is MxType InputToucheType.kGetBegan

Parameters ​

NameTypeDescription
ToucheTypeNumberToucheType Type

Returns ​

void

Example

ts
//Example of MxCADUiPrPoint class
  import { MxCADUiPrPoint, MxCpp } from "mxcad";
  import { MxType } from "mxdraw";

//Draw a straight line on the touch screen of a mobile phone
   async function Mx_Test_Touch_DrawLine() {
       const getPoint = new MxCADUiPrPoint();
       getPoint.setOffsetInputPostion(true);
GetPoint.setMessage ("\ nSpecify the first point:");
//Receive kGetBegan and press it with your touch screen finger
       getPoint.setInputToucheType(MxType.InputToucheType.kGetEnd);
       let pt1 = await getPoint.go();
       if (!pt1) return;
GetPoint.setMessage ("\ nSpecify second point:");
       getPoint.setBasePt(pt1);

       console.log(getPoint.getResultPointOsnapMode());
       console.log(getPoint.getResultPointType());

//Receive kGet and release the touch screen finger
       getPoint.setInputToucheType(MxType.InputToucheType.kGetEnd);
       let pt2 = await getPoint.go();
       if (!pt2) return;
       let mxcad = MxCpp.getCurrentMxCAD();
       let ent = mxcad.drawLine(pt1.x, pt1.y, pt2.x, pt2.y).getMcDbEntity();
       if (ent) {
           ent.lineweight = 20;
       }
   }

Inherited from ​

MxCADUiPrBase.setInputToucheType


setKeyWords ​

▸ setKeyWords(keyWordList): void

Set keyword list

Parameters ​

NameTypeDescription
KeyWordListstringKeyword List

Returns ​

void

void

Example

ts
//Taking the MxCADUiPrPoint class as an example, the same applies to other classes in the MxCADUiPr * series
  import { MxCADUiPrPoint } from 'mxcad'
  const getPoint = new MxCADUiPrPoint();
GetPoint. setKeyWords ("[Option 1 (A)/Option 2 (B)]")

Inherited from ​

MxCADUiPrBase.setKeyWords


setLastInputPoint ​

▸ setLastInputPoint(pt): void

Set the previous input point.

Parameters ​

NameTypeDescription
Ptundefined \[McGePoint3d] (2d. McGePoint3d. md)

Returns ​

void

Inherited from ​

MxCADUiPrBase.setLastInputPoint


setMessage ​

▸ setMessage(message): void

Set prompt string

Parameters ​

NameTypeDescription
messagestringprompt message

Returns ​

void

Reminder message

Inherited from ​

MxCADUiPrBase.setMessage


setOffsetInputPostion ​

▸ setOffsetInputPostion(isOffset): void

Set input point traversal, commonly used for point retrieval on mobile devices

Parameters ​

NameType
isOffsetboolean

Returns ​

void

Example

ts
import { MxCADUiPrPoint } from "mxcad";
import { MxFun } from "mxdraw";

//Draw temporary annotation circles on mobile devices
async function test(){
   const getPoint = new MxCADUiPrPoint();
GetPoint.setMessage ("\ nSpecify a point:");
   getPoint.setOffsetInputPostion(true);
   getPoint.clearLastInputPoint();
   let pt1 = (await getPoint.go());
   if (!pt1) return;

   let mxdraw = MxFun.getCurrentDraw();

   mxdraw.getTempMarkDraw().drawCircleMark(pt1.toVector3(), mxdraw.viewCoordLong2Cad(50), 0xFF0000);
   mxdraw.updateDisplay();
}

Inherited from ​

MxCADUiPrBase.setOffsetInputPostion


setOsModeExParam ​

▸ setOsModeExParam(lVal): void

Set extended capture parameters during capture.

Parameters ​

NameTypeDescription
LValOsModeExParamExtended Object Snap Parameters

Returns ​

void

Example

ts
import { MxCADUiPrPoint } from "mxcad";
import { OsModeExParam } from "mxdraw";

    async function Mx_Test_Rect2() {
        const getPoint = new MxCADUiPrPoint();
        getPoint.clearLastInputPoint();
GetPoint.setMessage ("Please select the first point");
        const pt1 = await getPoint.go();
        if (!pt1) return;

        const getNextPt = new MxCADUiPrPoint();
GetNextPt.setMessage ("Please select the second corner");
        getNextPt.setOsModeExParam(OsModeExParam.kCircleTangentOsmode);
        getNextPt.setUserDraw((pt2, pWorldDraw) => {
            let pl = new McDbPolyline();
            pl.addVertexAt(pt1);
            pl.addVertexAt(new McGePoint3d(pt1.x, pt2.y, pt1.z));
            pl.addVertexAt(pt2);
            pl.addVertexAt(new McGePoint3d(pt2.x, pt1.y, pt1.z));
            pl.isClosed = true;
            pWorldDraw.drawMcDbEntity(pl);
        });

        if (!await getNextPt.go()) return;

        getNextPt.drawReserve();
    }

Inherited from ​

MxCADUiPrBase.setOsModeExParam


setUserDraw ​

▸ setUserDraw(pDraw): void

Set the dynamic drawing calling object for the interaction process

Parameters ​

NameTypeDescription
PDraw(CurrentPoint: [McGePoint3d] (2d. McGePoint3d. md), pWorldDraw: McEdGetPointWorldDrawObject)=>voidMcEdGetPointWorldDrawObject \

Returns ​

void

void

Example

ts
//Example of MxCADUiPrPoint class
  import { MxCADUiPrPoint } from 'mxcad';

  async function test(){
   const getPoint = new MxCADUiPrPoint();
   getPoint.setUserDraw((pt,pw)=>{
       pw.setColor(0xff00ff);
       pw.drawCircle(new HTREE.Vector3(pt.x,pt.y,pt.z), 10)
   })
   const pt = await getPoint.go();
   console.log("point", pt)
  }

Inherited from ​

MxCADUiPrBase.setUserDraw


setUserInputControls ​

▸ setUserInputControls(contros): void

Set input control settings

Parameters ​

NameType
controsnumber

Returns ​

void

Example

ts
//Example of MxCADUiPrInt class
  import { MxCADUiPrInt } from 'mxcad';
  import { UserInputControls } from "mxdraw"

  let getInt = new MxCADUiPrInt();
GetInt.setMessage ("Enter integer: ");
  getInt.setUserInputControls(UserInputControls.kNoZeroResponseAccepted);
  let iRowNum = await getInt.go();
  if (iRowNum == null) return;

Inherited from ​

MxCADUiPrBase.setUserInputControls


userInputControls ​

▸ userInputControls(): number

Return to input control settings

Returns ​

number

Inherited from ​

MxCADUiPrBase.userInputControls