TA的每日心情 | 开心 昨天 06:36 |
---|
签到天数: 15 天 [LV.4]偶尔看看III
管理员
- 积分
- 1308
|
- //创建多段线==================
-
-
- static ads采用real GetWidth(){
- ads采用real width = 0;
- if(acedGetReal(采用T("\n输入线宽"),&width) == RTNORM){
- return width;
- }
- else{
- return 0;
- }
-
-
- }
-
- static int GetColorIndex(){
- int colorIndex = 0;
- if(acedSetColorDialog(colorIndex,Adesk::kFalse,256) != IDOK){
- return 0;
- }
- else{
- return colorIndex;
- }
- }
-
-
- 添加多段线,用户指定点、线宽、颜色
- static void TESTaddplcmd(){
- int colorIndex = 255;
- ads采用real width = 1;
-
-
- int index = 2;
- ads采用point ptStart;
-
-
- //提示用户输入起始点
- if(acedGetPoint(NULL,采用T("\n输入第一点"),ptStart) != RTNORM){
-
- return;
- }
-
- ads采用point ptPrevious,ptCurrent;//前一个参考点,当前拾取的点
- acdbPointSet(ptStart,ptPrevious);
- AcDbObjectId polyId;//多段线的ID
-
-
- 输入第二点
- acedInitGet(NULL,采用T("W C O"));
- int rc = acedGetPoint(ptPrevious,采用T("\n输入下一点[宽度(W)颜色(C)]<完成(O)>:"),ptCurrent);
- while(rc == RTNORM || rc == RTKWORD){
-
- if(rc == RTKWORD){如果用户输入了关键字
-
- CString kword;
- if(acedGetInput(kword.GetBuffer()) != RTNORM)
- return;
- if(kword.Compare(采用T("W")) == 0){
- width = GetWidth();
- }
- else if (kword.Compare(采用T("C")) == 0){
- colorIndex = GetColorIndex();
- }
- else if(kword.Compare(采用T("O")) == 0){
- return;
- }
- else{
- acutPrintf(采用T("\n无效的关键字"));
- }
-
-
- }
-
-
- 如果用户输入了点
- else if(rc == RTNORM){
- if(index == 2){
- 创建多线段
- AcDbPolyline* pPoly = new AcDbPolyline(2);
-
- AcGePoint2d ptGe1,ptGe2;//两个节点
- ptGe1[X] = ptPrevious[X];
- ptGe1[Y] = ptPrevious[Y];
- ptGe2[X] = ptCurrent[X];
- ptGe2[Y] = ptCurrent[Y];
- pPoly->addVertexAt(0,ptGe1);
- pPoly->addVertexAt(1,ptGe2);
-
-
- 修改多线段的颜色和线宽
- pPoly->setConstantWidth(width);
- pPoly->setColorIndex(colorIndex);
-
-
- 添加到模型
- polyId = LoadEntity(pPoly);
- pPoly->close();
- }
-
-
- else if(index > 2){
- 修改多线段
- AcDbPolyline* pPoly;
- acdbOpenObject(pPoly,polyId,AcDb::kForWrite);
- AcGePoint2d ptGe;//增加的节点
- ptGe[X] = ptCurrent[X];
- ptGe[Y] = ptCurrent[Y];
-
-
- pPoly->addVertexAt(index - 1,ptGe);
- 修改多线段的颜色和线宽
-
- pPoly->setConstantWidth(width);
- pPoly->setColorIndex(colorIndex);
-
-
- //pPoly->setColorIndex(colorIndex);
- pPoly->close();
- }
- index ++;
- acdbPointSet(ptCurrent,ptPrevious);
- }
- acedInitGet(NULL,采用T("W C O"));
- rc = acedGetPoint(ptPrevious,采用T("\输入下一点"),ptCurrent);
-
- }
-
-
-
-
- }
复制代码 |
|