明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2089|回复: 2

请教大虾们(Objectarx)程序错误应该如何解决?

[复制链接]
发表于 2009-9-16 11:11:00 | 显示全部楼层 |阅读模式

请教大虾们(Objectarx)程序错误应该如何解决?

程序如下:

#include<iostream.h>
#include "StdAfx.h"
#include "StdArx.h"
#include "dbpl.h"
#include "acedads.h"
#include "dbents.h"
#include "dbsymtb.h"
#include  <string.h>

// This is command 'ADDPOLYDYNAMIC'
void ZffCHAP5AddPolyDynamic()
{
 
 // TODO: Implement the command
 ads_real GetWidth()
 {
  ads_real width = 0;
        if (acedGetReal("\n输入线宽:", &width) == RTNORM)
  {
         return width;
  }
        else
  {
          return 0;
  }
 }

 int GetColorIndex()
 {
  int colorIndex = 0;
        if (acedGetInt("\n输入颜色索引值(0~256):", &colorIndex) !=RTNORM)
            return 0;
 
        // 处理颜色索引值无效的情况
  while (colorIndex < 0 || colorIndex > 256)
  {
   acedPrompt("\n输入了无效的颜色索引.");
            if (acedGetInt("\n输入颜色索引值(0~256):", &colorIndex) !=RTNORM)
               return 0;
  }
  return colorIndex;
 }


}
// This is command 'ADDPOLY'
void ZffCHAP5AddPoly()
{
 // TODO: Implement the command
 int colorIndex = 0;      // 颜色索引值
    ads_real width = 0;      // 多段线的线宽
 
    int index = 2;        // 当前输入点的次数
    ads_point ptStart;   // 起点
 
    // 提示用户输入起点
    if (acedGetPoint(NULL, "\n输入第一点:", ptStart) != RTNORM)
      return;
 
     ads_point ptPrevious, ptCurrent;
     acdbPointSet(ptStart, ptPrevious);
     AcDbObjectId polyId;    // 多段线的ID
 
    // 输入第二点
     acedInitGet(NULL, "W C O");
     int rc = acedGetPoint(ptPrevious,"\n输入下一点 [宽度(W)/颜色(C)]<完成(O)>:", ptCurrent);
     while (rc == RTNORM || rc == RTKWORD)
  {
   if (rc == RTKWORD)    // 如果用户输入了关键字
   {
    char kword[20];
             if (acedGetInput(kword) != RTNORM)
               return;
             if (strcmp(kword, "W") == 0)
    {
     width=GetWidth();    
    }
             else if (strcmp(kword, "C") == 0)
    {
     colorIndex=GetColorIndex();
    }
             else if (strcmp(kword, "O") == 0)
    {
     return;
    }
    else
    {
     acutPrintf("\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=PostToModelSpace(pPoly);
    }

    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->close();
    }
    index++;
     acdbPointSet(ptCurrent, ptPrevious);
   }
   // 提示用户输入新的节点
         acedInitGet(NULL,"W C O");
         rc=acedGetPoint(ptPrevious,"\n输入下一点 [宽度(W)/颜色(C)]<完成(O)>:",ptCurrent);
  } 
}

错误如下:

--------------------Configuration: AddPolyDynamic - Win32 Debug--------------------
Compiling...
AddPolyDynamicCommands.cpp
     Compiling STL header files in release mode.
D:\TEST\AddPolyDynamic\AddPolyDynamicCommands.cpp(20) : error C2601: 'GetWidth' : local function definitions are illegal
D:\TEST\AddPolyDynamic\AddPolyDynamicCommands.cpp(33) : error C2601: 'GetColorIndex' : local function definitions are illegal
D:\TEST\AddPolyDynamic\AddPolyDynamicCommands.cpp(80) : error C2065: 'GetWidth' : undeclared identifier
D:\TEST\AddPolyDynamic\AddPolyDynamicCommands.cpp(84) : error C2065: 'GetColorIndex' : undeclared identifier
D:\TEST\AddPolyDynamic\AddPolyDynamicCommands.cpp(114) : error C2065: 'PostToModelSpace' : undeclared identifier
执行 cl.exe 时出错.

ZffAddPolyDynamic.arx - 1 error(s), 0 warning(s)

发表于 2009-9-17 02:06:00 | 显示全部楼层

D:\TEST\AddPolyDynamic\AddPolyDynamicCommands.cpp(20) : error C2601: 'GetWidth' : local function definitions are illegal

本地函数定义非法


D:\TEST\AddPolyDynamic\AddPolyDynamicCommands.cpp(33) : error C2601: 'GetColorIndex' : local function definitions are illegal
本地函数定义非法

D:\TEST\AddPolyDynamic\AddPolyDynamicCommands.cpp(80) : error C2065: 'GetWidth' : undeclared identifier
未定义的识别符,(因为函数原型非法)

D:\TEST\AddPolyDynamic\AddPolyDynamicCommands.cpp(84) : error C2065: 'GetColorIndex' : undeclared identifier
同上

D:\TEST\AddPolyDynamic\AddPolyDynamicCommands.cpp(114) : error C2065: 'PostToModelSpace' : undeclared identifier
同上

lz不仅对arx不理解,连vc++的编译环境也不了解,对C++也不懂,如此仓促上阵,是要遇到许多问题的,楼主还是先看看vc++的编译,弄几个教程,再来搞arx吧~~

 楼主| 发表于 2009-9-17 20:26:00 | 显示全部楼层
谢谢,小弟受教!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 13:38 , Processed in 0.189124 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表