![]() |
【转帖】objectarx开发实例教程中问题
objectarx开发实例教程中问题
objectarx开发实例教程中问题 我在第二章的例子中 改变图层的应用中编译出现下列问题 // // objectarx defined commands #include "stdafx.h" #include "stdarx.h" #include "createent.h" #include "modifyent.h" // this is command 'changelayer' void zffchap2changelayer() { acdbobjectid lineid; lineid = ccreateent::createline(); cmodifyent::changelayer(lineid, lx); // todo: implement the command } --------------------configuration: createenta - win32 debug-------------------- compiling... createentacommands.cpp compiling stl header files in release mode. e:\createenta\createentacommands.cpp(15) : error c2065: 'lx' : undeclared identifier error executing cl.exe. zffcreateenta.arx - 1 error(s), 0 warning(s) changelyer函数中的参数cstring strlayername是什么? 高手解释一下 在命令中怎么用这个函数? 代码没发全啊? 楼主,需要把所有文件都发吗? changelyer函数中的参数cstring strlayername是什么? 你问的这个问题, 但是changelyer的定义都没给,就让别人给解答,这个难度也太高了吧 acad::errorstatus cmodifyent::changelayer(acdbobjectid entid, cstring strlayername) { acdbentity *pentity; // 打开图形数据库中的对象 acdbopenobject(pentity, entid, acdb::kforwrite); // 修改实体的图层 pentity->setlayer(strlayername); // 用完之后,及时关闭 pentity->close(); return acad::eok; strlayername 就是图层名喽,,比如0层就应该传入 _t("0"),另外使用之前要确认图层是否存在,否则可能会出错 楼主,还是不行呀 看代码 // // objectarx defined commands #include "stdafx.h" #include "stdarx.h" #include "createent.h" #include "modifyent.h" // this is command 'changelayer' void zffchap2changelayer() { acdbobjectid lineid; lineid = ccreateent::createline(); // 修改直线的颜色 cmodifyent::changelayer(lineid,_t("lx")); // todo: implement the command } lx图层cad中是有的 错误如下 --------------------configuration: createenta - win32 debug-------------------- compiling... createentacommands.cpp compiling stl header files in release mode. e:\createenta\createentacommands.cpp(15) : error c2352: 'cmodifyent::changelayer' : illegal call of non-static member function e:\createenta\modifyent.h(18) : see declaration of 'changelayer' error executing cl.exe. zffcreateenta.arx - 1 error(s), 0 warning(s) 下载次数:8 9-1-4 09:33 am 你在类的头文件中写的是 class cmodifyent { public: cmodifyent(); virtual ~cmodifyent(); acad::errorstatus cmodifyent::changelayer(acdbobjectid entid, cstring strlayername); cmodifyent::changelayer的cmodifyent::应该不写 函数为static 运行时加入lx层那是自然不必多说了 版主,我在changelayer函数的头文件中去了cmodifyent:: 结果错误如下 --------------------configuration: createenta - win32 debug-------------------- compiling... createentacommands.cpp compiling stl header files in release mode. e:\createenta\createentacommands.cpp(15) : error c2352: 'cmodifyent::changelayer' : illegal call of non-static member function e:\createenta\modifyent.h(18) : see declaration of 'changelayer' generating code... compiling... modifyent.cpp generating code... compiling stl header files in release mode. error executing cl.exe. zffcreateenta.arx - 1 error(s), 0 warning(s) 请版主调试一下程序, 本帖最后由 catface 于 9-1-4 07:05 pm 编辑 cmodifyent::changelayer的cmodifyent::应该不写 函数为static 运行时加入lx层那是自然不必多说了 改正以上就可以运行了 class cmodifyent { public: cmodifyent(); virtual ~cmodifyent(); static acad::errorstatus changelayer(acdbobjectid entid, cstring strlayername); 然后运行就会出现告警。 但是在你的changelayer函数实现中随便输入回车或者重新输入函数实现代码等动作 再运行就没问题了 acad::errorstatus cmodifyent::changelayer(acdbobjectid entid, cstring strlayername) { acdbentity *pentity; // 打开图形数据库中的对象 acdbopenobject(pentity, entid, acdb::kforwrite); // 修改实体的图层 pentity->setlayer(strlayername); // 用完之后,及时关闭 pentity->close(); return acad::eok; } 帖子是你发的 你自己就是楼主 这帖子里除了楼主(qigefei) 版主(忽悠悠) 还有个中级会员(catface) |
所有的时间均为北京时间。 现在的时间是 01:21 AM. |