乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 55|回复: 3

[求助]wblock的问题

[复制链接]

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
6
发表于 2011-5-24 11:06:00 | 显示全部楼层 |阅读模式
假设下面将数组idarr成功填充
for (pltr->start();!pltr->done();pltr->step())
    {
     AcDbEntity *nEntity ;
     ErrorStatus es = pltr->getEntity(nEntity,AcDb::kForRead);
     if (nEntity->layerId() == bulidLID || nEntity->layerId() == splitLID ||  nEntity->layerId() == bulidSymLID ||  nEntity->layerId()  == splitSymLID)
     {
      idarr.append(nEntity->id());
      AcDbLine *line = AcDbLine::cast(nEntity);
      if (line != NULL)
      {
       x += line->startPoint().x;
       x += line->endPoint().x;
       y += line->startPoint().x;
       y += line->endPoint().x;
       i++;
      }
     }
     nEntity->close();
    }
那么本段代码
const ACHAR * filea= _T("Save");
resbuf *result = ads_newrb(RTSTR);
int iflags=ads_getfiled(filea, NULL, _T("dwg"), 33, result);
  for (int i = 0 ;i[i]close();
  }
  ACHAR *FileName;
     if (iflags==RTNORM)
        {
   FileName = (ACHAR*)malloc(sizeof(result->resval.rstring));
   StrCpy(FileName,result->resval.rstring);
   AcDbDatabase * pdb;
   AcGePoint3d pt3d(x / i,y / i,0);
   if (idarr.isEmpty())
   {
    acedAlert(_T("实体数组中未包含任何实体!"));
    return;
   }
   AcDbDatabase *db = acdbHostApplicationServices()->workingDatabase();
   ErrorStatus es = db->wblock(pdb,idarr,pt3d);                                                      //执行到这里会报错
   if (es != Acad::eOk)
   {
     acedAlert(_T("wblock操作失败!"));
     return;
   }
   es =  pdb->saveAs(FileName);
   delete pdb;
   //free(FileName);
  }
这是怎么回事?
回复

使用道具 举报

0

主题

38

帖子

1

银币

初来乍到

Rank: 1

铜币
38
发表于 2011-5-26 10:39:00 | 显示全部楼层

Acad::ErrorStatus
wblock(
AcDbDatabase*& pOutputDb,
const AcDbObjectIdArray& outObjIds,
const AcGePoint3d& basePoint);
pOutputDb Returns pointer to the database that was written to
outObjIds Input array of objectId entities of all objects to be wblocked out
basePoint Input base point (in WCS coordinates for pOutputDb) to be used in pOutputDb
Creates a new AcDbDatabase object, sets pOutputDb to point to it, and then uses the wblockClone mechanism to write the array of objects specified by outObjId entities out to the Model Space block table record of the database pointed to by pOutputDb, using basePoint as the base point value for pOutputDb.
The calling application is responsible for deallocating (via the C++ delete operator) the AcDbDatabase object that pOutputDb is set to point to.
Returns Acad::eOk if operation is successful.
See the BASE command documentation in the AutoCAD online help for more information on base point.
这里面写的很清楚,你的pdb没有创建,所以死机。
还有你的代码很不规范,注意养成良好的代码书写格式和合理的容错处理。
回复

使用道具 举报

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
6
发表于 2011-5-30 13:42:00 | 显示全部楼层
不是你说的问题。
                const ACHAR * filea= _T("Save");
        resbuf *result = ads_newrb(RTSTR);
        int iflags=ads_getfiled(filea, NULL, _T("dwg"), 33, result);
                AcDbDatabase * pdb1;
                AcDbDatabase *db1 = acdbHostApplicationServices()->workingDatabase();
                AcGePoint3d pt3d1(x / i,y / i,0);
                ErrorStatus es1 = db1->wblock(pdb1,idarr,pt3d1);
                pdb1->saveAs(result->resval.rstring);
这样写为什么就正常?我现在都没弄清楚到底是怎么回事。报的错误有时候说缓存满,有时候说CAD空引用。莫名其妙。
回复

使用道具 举报

2

主题

87

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
95
发表于 2011-7-13 14:31:00 | 显示全部楼层
也是一头雾水
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-2-5 16:55 , Processed in 0.271902 second(s), 60 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表