zoukankan      html  css  js  c++  java
  • C++ CAD Arx二次开发用户交互

    C++ CAD Arx二次开发用户交互

    展开
    一、本节课程
    Arx二次开发用户交互
    二、本节要讲解的知识点
    1、用户交互的一些函数:acedGetXXX(acedGetString、acedGetPoint、acedGetInt acedGetKword、acedGetReal)。

    2、动态创建多段线的实现。

    3、acedGetPoint函数中使用关键字。

    三、具体内容
    1、acedGetString:获取用户输入的字符串

    acedGetPoint:获取用户输入的点

    acedGetInt:获取用户输入的整型

     acedGetKword:获取用户输入的关键字

    acedGetReal:获取用户输入的实数。

    2、动态创建多段线:最基本的要求就是用户在图形窗口中按顺序拾取各个点,每次拾取一点都会将其加入到多段线的末端,最终按ENTER键或者ESC键就完成多段线的创建。

    (1)拾取第一点;

    (2)拾取第二点,创建多段线。

    (3)如果没有按ENTER或ESC键,则拾取下一点,并将拾取的点添加到多段线的末尾。

    (4)如果用户按ENTER或ESC键,退出程序的执行,多段线创建完毕,否则执行步骤3。

    3、动态创建多段线(简单版、升级版)

    static void YunyouMyGroupAddPolyBaic(void)

    {

    int index=2;

    AcGePoint3d ptStart;

    if (!CGetInputUtil::GetPoint(TEXT(" please input first point:"),ptStart))

    {

    return;

    }

    AcGePoint3d ptPrevious,ptCurrent;

    ptPrevious=ptStart;

    AcDbObjectId polyId;

    while (CGetInputUtil::GetPoint(ptPrevious,TEXT(" please input NEXT point:"),ptCurrent))

    {

    if (index==2)

    {

    polyId=CPolylineUtil::Add(CConvertUtil::ToPoint2d(ptPrevious),CConvertUtil::ToPoint2d(ptCurrent));

    }

    else if(index>2)

    {

    AcDbPolyline *pPoly=NULL;

    if (acdbOpenObject(pPoly,polyId,AcDb::kForWrite)==Acad::eOk)

    {

    pPoly->addVertexAt(index-1,CConvertUtil::ToPoint2d(ptCurrent));

    pPoly->close();

    }

    }

    ptPrevious=ptCurrent;

    index++;

    }

    }

    static void YunyouMyGroupAddPoly(void)

    {

    int colorIndex=0;

    ads_real width=0;

    int index=2;

    AcGePoint3d ptStart;

    if (!CGetInputUtil::GetPoint(TEXT(" please input first point:"),ptStart))

    {

    return;

    }

    AcGePoint3d ptPrevious,ptCurrent;

    ptPrevious=ptStart;

    AcDbObjectId polyId;

    acedInitGet(NULL,TEXT("W C O"));

    int rc=CGetInputUtil::GetPointReturnCode(ptPrevious,

    TEXT(" 输入下一点[宽度(W)/颜色(C)<完成(O)>:"),

    ptCurrent);

    while (rc==RTNORM || rc==RTKWORD)

    {

    if (rc==RTKWORD)

    {

    ACHAR kword[20];

    if (acedGetInput(kword)!=RTNORM)

    {

    return;

    }

    if (_tcscmp(kword,TEXT("W"))==0)

    {

    width=GetWidth();

    }

    else if (_tcscmp(kword,TEXT("C"))==0)

    {

    colorIndex=GetColorIndex();

    }

    else if (_tcscmp(kword,TEXT("O"))==0)

    {

    return;

    }

    else

    {

    acutPrintf(TEXT(" 输入了无效的关键字"));

    }

    }

    else if(rc==RTNORM)

    {

    if (index==2)

    {

     polyId=CPolylineUtil::Add(CConvertUtil::ToPoint2d(ptPrevious),CConvertUtil::ToPoint2d(ptCurrent));

     AcDbPolyline *pPoly=NULL;

     if (acdbOpenObject(pPoly,polyId,AcDb::kForWrite)==Acad::eOk)

     {

     pPoly->setConstantWidth(width);

     pPoly->setColorIndex(colorIndex);

     pPoly->close();

     }

    }

    else if(index>2)

    {

    AcDbPolyline *pPoly=NULL;

    if (acdbOpenObject(pPoly,polyId,AcDb::kForWrite)==Acad::eOk)

    {

    pPoly->addVertexAt(index-1,CConvertUtil::ToPoint2d(ptCurrent));

    pPoly->setConstantWidth(width);

    pPoly->setColorIndex(colorIndex);

    pPoly->close();

    }

    }

    ptPrevious=ptCurrent;

    index++;

    }

    //

    acedInitGet(NULL,TEXT("W C O"));

    rc=CGetInputUtil::GetPointReturnCode(ptPrevious,TEXT(" 输入下一点[宽度(W)/颜色(C)<完成(O)>:"),ptCurrent);//

    }

    }

    static void YunyouMyGroupGetPointKeyword(void)

    {

    int rc;

    ACHAR kword[20];

    AcGePoint3d pt;

    acedInitGet(RSG_NONULL,TEXT("K W"));

    rc=CGetInputUtil::GetPointReturnCode(TEXT(" 输入一个点或[Keyword1/KeyWord2]:"),pt);

    switch (rc)

    {

    case RTKWORD:

    if (acedGetInput(kword)!=RTNORM)

    {

    return;

    }

    if (_tcscmp(kword,TEXT("K"))==0)

    {

    acutPrintf(TEXT(" 选择的关键字是Keyword1"));

    }

    else

    {

    acutPrintf(TEXT(" 选择的关键字是Keyword2"));

    }

    break;

    case RTNORM:

    acutPrintf(TEXT(" 输入点的坐标是(%.2f,%.2f,%.2f)"),pt.x,pt.y,pt.z);

    break;

    default:

    break;

    }

    }

    四、总结
    acedGetString:获取用户输入的字符串

    acedGetPoint:获取用户输入的点

    acedGetInt:获取用户输入的整型

    acedGetKword:获取用户输入的关键字

    acedGetReal:获取用户输入的实数

    acedGetDist:获取用户输入的距离值

    acedGetCorner:获取用户输入的角点

    acedGetAngle:获取用户输入的角度

    acedGetFileD:打开文件选择对话框获取用户输入的文件名
    ————————————————
    版权声明:本文为CSDN博主「yunyouxy」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/yunyouxy/article/details/81036230

  • 相关阅读:
    Excel中输入身份证后3位变成0,怎么办?
    Css中如何使英文和拼音变成全大写、全小写和首字母大写?
    css中 font常用的样式属性
    Css的向左浮动、先右浮动、绝对定位、相对定位的简单使用
    如何解决Css属性text-overflow:ellipsis 不起作用(文本溢出显示省略号)
    mysql 基本语法学习1(数据库、数据表、数据列的操作)
    sql server中如何将两个字段数据合并成一个字段显示(字段与字段添加特殊符号)
    Linq to Entity 求最大小值Max/Min返回null的处理方法
    C#匿名对象在其它方法体内怎么取到相应的值(不想建立对应的类并转化的情况下)?
    【转发】JQuery中操作Css样式的方法
  • 原文地址:https://www.cnblogs.com/mjgw/p/12348003.html
Copyright © 2011-2022 走看看