乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 45|回复: 2

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

[复制链接]

4

主题

7

帖子

1

银币

初来乍到

Rank: 1

铜币
23
发表于 2009-9-16 11:11:00 | 显示全部楼层 |阅读模式
请教大虾们(Objectarx)程序错误应该如何解决?
程序如下:
#include[i]
#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 (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)]:", 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)]:",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)
回复

使用道具 举报

2

主题

165

帖子

6

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
173
发表于 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吧~~
回复

使用道具 举报

4

主题

7

帖子

1

银币

初来乍到

Rank: 1

铜币
23
发表于 2009-9-17 20:26:00 | 显示全部楼层
谢谢,小弟受教!
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-5-1 17:02 , Processed in 0.453728 second(s), 69 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表