qszchew 发表于 2009-9-16 11:11:00

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

请教大虾们(Objectarx)程序错误应该如何解决?
程序如下:
#include
#include "StdAfx.h"
#include "StdArx.h"
#include "dbpl.h"
#include "acedads.h"
#include "dbents.h"
#include "dbsymtb.h"
#include   
// 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 (colorIndex256)
{
   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)]:", ptCurrent);
   while (rc == RTNORM || rc == RTKWORD)
{
   if (rc == RTKWORD)    // 如果用户输入了关键字
   {
    char kword;
             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=ptPrevious;
               ptGe1=ptPrevious;
               ptGe2=ptCurrent;
               ptGe2=ptCurrent;
               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 = ptCurrent;
               ptGe = ptCurrent;   
               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)]:",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)

luowy 发表于 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吧~~

qszchew 发表于 2009-9-17 20:26:00

谢谢,小弟受教!
页: [1]
查看完整版本: 请教大虾们(Objectarx)程序错误应该如何解决?