几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » ObjectARX(C++)
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-04-16, 10:44 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】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)
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



所有的时间均为北京时间。 现在的时间是 11:06 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多