- UID
- 5280
- 积分
- 9466
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-5-18
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
问题:
I'm trying to copy a block definition from one drawing to the current drawing
using the wblock function
but the function is returning eFileInternalErr error. What am I doing wrong?
解答:
The wblock function is meant for writing out database contents. What you are
trying to do is the opposite, i.e. reading the contents of an external file
into the current database. You should be using the insert function for this.
The code snippet below shows how to use one of the overloaded insert functions
to copy a block definition from an external file to the current database.
![](source/plugin/imc_colorcode/images/loading.gif) - void AdskCopyBlockDef()
- {
- struct resbuf *rb;
- char *fname;
- AcDbObjectId blockId;
- rb = acutNewRb(RTSTR);
- Acad::ErrorStatus es;
- acedGetFileD("Pick drawing containing block def", NULL, "dwg", 0, rb);
- if(acutNewString(rb->resval.rstring,fname) != Acad::eOk ){
- acutPrintf("\nString memory allocation failed");
- acutRelRb(rb);
- return;
- }
- acutRelRb(rb);
- AcDbDatabase *pSourceDb = new AcDbDatabase(Adesk::kFalse);
- pSourceDb->readDwgFile(fname);
- char SourceBlockdefName[132];
- acedGetString(0,"Enter block def. name in source DWG: ",SourceBlockdefName);
- char DestBlockdefName[132];
- acedGetString(0,"Enter destination block def. name: ",DestBlockdefName);
- //Get current database
- AcDbDatabase *pCurDb = acdbHostApplicationServices()->workingDatabase();
- //Insert the chosen block definition
- es = pCurDb -> insert(blockId,SourceBlockdefName,DestBlockdefName,pSourceDb) ;
- if (es != Acad::eOk){
- acutPrintf("\nBlock Def copy failed. Error: %d",es);
- return;
- }
- acutDelString(fname);
- }
-
Note: This insert() function seems to create two block definiitions: the source
and the named copy, with the original being as in the external drawing, but
the copy being empty. This behaviour, which has also been observed in AutoCAD
2004, has been logged as a change request for further investigation.
|
|