找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 750|回复: 1

[分享]:选择当前图形中的实体,作为块插入外部DWG的代码

[复制链接]
发表于 2002-12-6 14:42:06 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
同时想请教各位,如果外部DWG由程序生成,用对话框预览的方法?因为acdbDisplayPreviewFromDwg
(path,GetDlgItem(IDC_COUSTOM1)->GetSafeHwnd());无法实现

  1. [font=courier new]
  2. //代码
  3. addBlockToDwg()
  4. {
  5.         //省略构造选择集的
  6.         AcDbObjectIdArray objIdArray(0,8);
  7.         AcDbDatabase *pTempDb;
  8.         ads_name ent;
  9.         long nss;
  10.         AcDbObjectId objId;
  11.         acedSSLength(ss,&nss);
  12.         for(long i=0;i<nss;i++)
  13.         {
  14.         acedSSName(ss,i,ent);
  15.         acdbGetObjectId(objId,ent);
  16.         objIdArray.append(objId);
  17.            }
  18.         acedSSFree(ss);

  19. AcGePoint3d   BASEPT(newbasept[X],newbasept[Y],newbasept[Z]);

  20. acdbHostApplicationServices()->workingDatabase()->wblock(pTempDb,objIdArray,BASEPT);
  21. AcDbDatabase *EquipDb = new AcDbDatabase(Adesk::kFalse);
  22. AcDbDatabase *EquipDb1 = new AcDbDatabase(Adesk::kTrue);
  23. CString tukuname;
  24. CString path;
  25. CString path1;
  26. path="D:\\dwgname.dwg";//外部DWG
  27. path="D:\\newdwgname.dwg";
  28. ads_printf("\n%s\n",path);
  29. ads_printf("\n%s\n",path1);
  30. EquipDb->readDwgFile(path,_SH_DENYRW);//读取外部DWG
  31.         AcDbObjectId blockId;
  32.     EquipDb->insert(blockId,"signname",pTempDb);
  33.     EquipDb->saveAs(path);

  34.    EquipDb1->insert(blockId,"signname",pTempDb);//以下代码生成新的DWG,包含可见的块参照
  35.    AcDbBlockTable *pBlockTable;
  36.    AcDbBlockTableRecord *pBTableRecord;
  37.    AcDbBlockReference *pBTableRefer;
  38.    AcDbObjectId blockId1;
  39.    AcDbObjectId insId;
  40.    EquipDb1->getBlockTable(pBlockTable,AcDb::kForRead);
  41.    pBlockTable->getAt(signname,blockId1);
  42.    pBlockTable->getAt(ACDB_MODEL_SPACE,pBTableRecord,AcDb::kForWrite);
  43.    
  44. pBTableRefer= new AcDbBlockReference(BASEPT,blockId1);
  45. pBTableRecord->appendAcDbEntity(insId,pBTableRefer);
  46. pBTableRefer->close();
  47. pBTableRecord->close();
  48. pBlockTable->close();
  49.    EquipDb1->saveAs(path1);
  50.                 delete EquipDb;
  51.                 delete pTempDb;
  52.                 delete EquipDb1;
  53. }

  54. [/font]
复制代码
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-12-6 15:06:30 | 显示全部楼层
下面是ARX联机帮助,注意下蓝色的部分。

  1. [font=courier new]
  2. acdbDisplayPreviewFromDwg Global Function bool

  3. acdbDisplayPreviewFromDwg(

  4. const char * pszDwgfilename,

  5. void* pPreviewWnd,

  6. const Adesk::UInt32* pBgColor = NULL);

  7. pszDwgfilename Input path\filename string
  8. pPreviewWnd Input HWND for window within which to display preview
  9. pBgColor Description to come

  10. This function obtains the preview image [color=blue](if any)[/color] of the drawing specified by pszDwgfilename
  11. and displays it in the window identified by the HWND argument pPreviewWnd.

  12. The image size varies up to a maximum size no larger than 256 x 188 pixels.
  13. If the pPreviewWnd window is larger than the image, then the image will be stretched to fit.
  14. But, if the window is smaller than the image, the image will not be
  15. adjusted and will spill out beyond the window's borders.

  16. Returns true if successful; otherwise, it returns false.


  17. [/font]


  1. [font=courier new]
  2. AcDbDatabase::saveAs Function Acad::ErrorStatus

  3. saveAs(

  4. const char* fileName);

  5. fileName Input file name or URL to write database out to

  6. Runs the save process on the database and writes the drawing information out to fileName.
  7. The fileName argument is taken as is. If no file extension is present, .dwg is not appended.

  8. [color=blue]If the database executing the saveAs() function is not the current database
  9. in the AutoCAD editor, then the thumbnail preview image is not saved to fileName.[/color]

  10. Returns Acad::eOk if process completes successfully

  11. [/font]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-12-27 00:28 , Processed in 0.371217 second(s), 33 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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