• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++CADArx二次开发用户交互

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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("\n please input first point:"),ptStart))

{

return;

}

AcGePoint3d ptPrevious,ptCurrent;

ptPrevious=ptStart;

AcDbObjectId polyId;

while (CGetInputUtil::GetPoint(ptPrevious,TEXT("\n 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("\n 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("\n输入下一点[宽度(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("\n输入了无效的关键字"));

}

}

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("\n输入下一点[宽度(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("\n输入一个点或[Keyword1/KeyWord2]:"),pt);

 

switch (rc)

{

case RTKWORD:

if (acedGetInput(kword)!=RTNORM)

{

return;

}

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

{

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

}

else

{

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

}

break;

case RTNORM:

acutPrintf(TEXT("\n输入点的坐标是(%.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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#Winfrom常用的几个公共控件发布时间:2022-07-13
下一篇:
【C#】为什么有可能会被多个线程修改的对象要加线程锁发布时间:2022-07-13
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap