明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1622|回复: 0

新建DWG文挡

[复制链接]
发表于 2008-7-24 16:22:00 | 显示全部楼层 |阅读模式

#include "StdAfx.h"
#include "StdArx.h"
#include "dbsymtb.h"
#include "dbents.h"

//-----------------------------------------------------------------------------
// This is command 'NEWDOC, by  [2005-5-17], ,
void ACADnewdoc()
{
#ifdef OARXWIZDEBUG
 acutPrintf ("\nOARXWIZDEBUG - ACADnewdoc() called.");
#endif // OARXWIZDEBUG

 // TODO: Implement the command
 static char pData[] ="acad.dwt";
 acDocManager->executeInApplicationContext(CreateDoc, (void *)pData);

 AcDbDatabase *pdb =acdbHostApplicationServices()->workingDatabase();

 AcDbBlockTable *pBtbl;
    pdb->getSymbolTable(pBtbl, AcDb::kForRead);

    AcDbBlockTableRecord *pBtblRcd;
    pBtbl->getAt(ACDB_MODEL_SPACE, pBtblRcd,
        AcDb::kForWrite);
    pBtbl->close();

    AcDbCircle *pCir1 = new AcDbCircle(AcGePoint3d(1,1,1),
                                       AcGeVector3d(0,0,1),
                                       1.0),
               *pCir2 = new AcDbCircle(AcGePoint3d(4,4,4),
                                       AcGeVector3d(0,0,1),
                                       2.0);
    pBtblRcd->appendAcDbEntity(pCir1);
    pCir1->close();
   
    pBtblRcd->appendAcDbEntity(pCir2);
    pCir2->close();
    pBtblRcd->close();

}

void CreateDoc( void *pData)
{
 AcApDocument* pDoc = acDocManager->curDocument();
 if(acDocManager->isApplicationContext())
 {
  acDocManager->appContextNewDocument((const char *)pData);
 }
 else
  acutPrintf("\nERROR To Create Doc!\n");
}

上述代码执行后,圆并未画在新建出来的DWG文挡上,而画在了前一个DWG文挡上,这样新建的DWG并不是当前的WorkingDatabase

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

本版积分规则

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

GMT+8, 2024-11-25 16:03 , Processed in 0.187341 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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