|
请教大虾们(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)
|
|