明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1634|回复: 2

10.28在菜单项的响应函数中,如何调用自定义函数?

[复制链接]
发表于 2003-10-28 22:05:00 | 显示全部楼层 |阅读模式
1.菜单响应函数onCommand

void defaultContext::onCommand(Adesk::UInt32 cmdIndex)
{AcDbObjectId         createLine();}   
//不能AcDbObjectId         createLine();这样函数声明?还是其他.....?
//程序执行时为何不跳转到2所列的函数体内?
2.紧接着在同一cpp文件里定义函数createLine的操作——/画一直线(例程)
AcDbObjectId  createLine()
{
        acutPrintf("ssssssssss");
       
        AcGePoint3d start(200,200,0);
                AcGePoint3d end(400,200,0);
        AcDbLine *pfcf=new AcDbLine(start,end);


AcDbBlockTable *pBlockTable;
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable,AcDb::kForRead);
  AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);
  pBlockTable->close();
AcDbObjectId fcfId;
pBlockTableRecord->appendAcDbEntity(fcfId,pfcf);
pBlockTableRecord->close();
  pfcf->close();
  return fcfId;
}

3.报错
Linking...
   Creating library Debug/contextmenu.lib and object Debug/contextmenu.exp
defaultarx.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall AcGePoint3d::AcGePoint3d(double,double,double)" (__imp_??0AcGePoint3d@@QAE@NNN@Z)
Debug/contextmenu.arx : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Creating browse info file...

contextmenu.arx - 2 error(s), 0 warning(s)
4.我都糊涂了,vc不可以在某个函数体内再调用自定义函数?
发表于 2003-10-29 22:01:00 | 显示全部楼层
void defaultContext::onCommand(Adesk::UInt32 cmdIndex)
{
acutPrintf("ssssssssss");

AcGePoint3d start(200,200,0);
                AcGePoint3d end(400,200,0);
AcDbLine *pfcf=new AcDbLine(start,end);


AcDbBlockTable *pBlockTable;
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable,AcDb::kForRead);
  AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);
  pBlockTable->close();
AcDbObjectId fcfId;
pBlockTableRecord->appendAcDbEntity(fcfId,pfcf);
pBlockTableRecord->close();
  pfcf->close();
}
//试试看看,
//defaultContext::onCommand(Adesk::UInt32 cmdIndex)
//错误的原因好象是上面一句话,因为defaultContext类中无成员函数
//AcDbObjectId  createLine()
//可以用判断cmdIndex来对不同的菜单项定义不同的操作,否则对于所有的菜单操作一样
//试试看看
发表于 2003-10-30 16:44:00 | 显示全部楼层
AcDbObjectId  createLine() 首先定义一下看看
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 20:29 , Processed in 0.148320 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表