明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1582|回复: 0

为什么已经切换当前数据库,acedSSGet还是对老的数据库操作?

[复制链接]
发表于 2006-3-1 11:17:00 | 显示全部楼层 |阅读模式


bool CBlueprintDrawing::CreateBlueprint(long lBluePrintTemplateID, int iPageNo)
{
 Acad::ErrorStatus es;
 AcDbDatabase *pDb;
 CString m_BlueprintFileFullName;
 CString t_BlueprintTemplateFileName;

 pDb = new AcDbDatabase;


 //获取模板文件名
 es = pDb->readDwgFile( t_BlueprintTemplateFileName);
 if( es != Acad::eOk )
 {
  acutPrintf("\n没有发现 %c 文件!\n", t_BlueprintTemplateFileName);
  delete pDb;
  return false;
 }

 AcDbDatabase *pOldDb = acdbHostApplicationServices()->workingDatabase();
 acdbHostApplicationServices()->setWorkingDatabase(pDb);

 AcDbBlockTable *pBlockTable;
    pDb->getSymbolTable(pBlockTable, AcDb::kForRead);
 //acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, AcDb::kForRead);

    AcDbBlockTableRecord *pBlockTableRecord;
    pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);
 pBlockTable->close(); 
 
 //---- 绘制图形
 CBlueprintDrawing::CreateTableGroup( pBlockTableRecord );
 
 //---- 绘制图纸框架
//?????????????? 选择集出现问题
//如果pOldDb中在选择区域中有实体,就可以;反之不行。
//希望pDb中在选择区域中有实体,就可以;反之不行。
//pDb已经是当前数据库为什么还关联pOldDb

 CBlueprintDrawing::CreateFrameLine( pBlockTableRecord );

 //---- 关闭块表
 pBlockTableRecord->close(); 

 //切换回原工作表
 acdbHostApplicationServices()->setWorkingDatabase(pOldDb);
 //保存图纸
 pDb->saveAs(m_BlueprintFileFullName);

 delete pDb;
}

bool CBlueprintDrawing::CreateFrameLine(AcDbBlockTableRecord *pBlockTableRecord)
{
 int stat;
 long Number;
 ads_name SSName;

 ads_point t_ptW0, t_ptW1;
 AcGePoint3d ptW0(0, 0, 0), ptW1(0, 297, 0);

 Number = 0;

 t_ptW0[X] = 210.0;
 t_ptW0[Y] = 0.0;
 t_ptW0[Z] = 0.0;

 t_ptW1[X] = 420.0;
 t_ptW1[Y] = 297.0;
 t_ptW1[Z] = 0.0;

 //建一个交叉窗口选择集
 stat = acedSSGet("C", t_ptW0, t_ptW1, NULL, SSName); 
 if ( stat != RTNORM )
 {
  acedAlert("创建交叉选择集不成功!");
 }
 else
 {
  acedSSLength(SSName, &Number);
  acedAlert("创建交叉选择集成功!");
  while ( Number != 0 )
  {
   ptW0.x = t_ptW0[X];
   ptW1.x = t_ptW1[X];

   t_ptW0[X] +=  210.0;
   t_ptW1[X] +=  210.0;

   Number = 0;
   acedSSFree(SSName);

   acedSSGet("C", t_ptW0, t_ptW1, NULL, SSName);
   acedSSLength(SSName, &Number);
  }
 }

 //--    绘制外框线
 AcGePoint3d pt0(0, 0, 0), pt1(0, 297, 0), pt2(0, 0, 0), pt3(0, 0, 0);

 pt2.x = ptW1.x;
 pt2.y = ptW1.y;
 pt3.x = ptW1.x;
 pt3.y = ptW0.y;

 CreateLine(pBlockTableRecord, pt0, pt1);
 CreateLine(pBlockTableRecord, pt1, pt2);
 CreateLine(pBlockTableRecord, pt2, pt3);
 CreateLine(pBlockTableRecord, pt3, pt0);

 return true;
}

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

本版积分规则

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

GMT+8, 2024-11-26 01:38 , Processed in 0.155301 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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