找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 533|回复: 4

[求助]:请教一个简单的问题!怎么实现数据库之间的对象拷贝

[复制链接]
发表于 2003-6-16 17:39:59 | 显示全部楼层 |阅读模式

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

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

×
大家好!请问怎么样实现在数据库之间的快拷贝!从一个数据库中的块考到另一个数据库中(包括当前数据库),而且在不知道块 的类型的情况下实现!我已经看一整天帮助了,还是没头绪!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2003-6-17 08:45:50 | 显示全部楼层
看看这个行吗?AcDbDatabase::wblock Function
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2003-6-17 16:10:39 | 显示全部楼层
不行啊!我试过了,就是不行!好象WBLOCK自动会给你创建一个数据库!INSERT我也试了,也不行!救救我吧!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-6-17 16:35:39 | 显示全部楼层
你的情况用象insert命令,把代码粘贴出来,我帮你改!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2003-6-22 21:52:31 | 显示全部楼层
谢谢binbin的关心!问题我已经解决了。
wbcok和insert都要用到。
我看了帮助clones的例子。
这是现成的,

// Copies an external drawing into the current model space.
// This is the supported way: a combination of
// AcDbDatabase::insert and AcDbDatabase::wblock.
// First, we wblock the external database into a temporary
// in-memory database. We can't wblock directly into the
// current drawing, because wblock is destructive on the
// target database.
// Then we use insert to insert the temporary database into
// the current drawing. We can't use insert to insert the
// external drawing directly, because insert uses
// cheapClone, which moves the objects from the source to
// the target database.
//
// Using this approach, all the symbol table gets merged
// correctly into the current drawing database.
//
void
clone3()
{
    AcDbObjectId id;
    AcDbObjectIdArray list;
    AcDbDatabase extDatabase( Adesk::kFalse );
    char dwgName[_MAX_PATH];

    if (RTNORM != getFile( "Enter DWG name", "Select Drawing", "dwg",
                           dwgName ))
    {
        return;
    }
    if (Acad::eOk != extDatabase.readDwgFile( dwgName ))
    {
        acedAlert( "Error reading DWG!" );
        return;
    }
    AcDbBlockTable* pBT;
    if (Acad::eOk != extDatabase.getSymbolTable( pBT, AcDb::kForRead ))
    {
        acedAlert( "Error getting BlockTable of DWG" );
        return;
    }
    AcDbBlockTableRecord* pBTR;
    Acad::ErrorStatus es = pBT->getAt( ACDB_MODEL_SPACE, pBTR, AcDb::kForRead );
    pBT->close();
    if (Acad::eOk != es) {
        acedAlert( "Error getting model space of DWG" );
        return;
    }

    AcDbBlockTableRecordIterator* pIT;
    if (Acad::eOk != pBTR->newIterator( pIT )) {
        acedAlert( "Error iterating model space of DWG" );
        pBTR->close();
        return;
    }

    for ( ; !pIT->done(); pIT->step()) {
        if (Acad::eOk == pIT->getEntityId( id )) {
            list.append( id );

            // There is a bug in ARX that causes extension dictionaries
            // to appear to be soft owners of their contents.  This causes
            // the contents to be skipped during wblock.  To fix this we
            // must explicitly tell the extension dictionary to be a hard
            // owner of it's entries.
            //
            AcDbEntity *pEnt;
            if ( Acad::eOk == pIT->getEntity(pEnt, AcDb::kForRead)) {
                AcDbObjectId obj;
                if ((obj = pEnt->extensionDictionary())
                    != AcDbObjectId::kNull)
                {
                    AcDbDictionary *pDict = NULL;
                    acdbOpenObject(pDict, obj, AcDb::kForWrite);
                    if (pDict) {
                        pDict->setTreatElementsAsHard(Adesk::kTrue);
                        pDict->close();
                    }
                }
                pEnt->close();
            }
        }
    }

    delete pIT;
    pBTR->close();

    if (list.isEmpty()) {
        acedAlert( "No entities found in model space of DWG" );
        return;
    }

    AcDbDatabase *pTempDb;

    if (Acad::eOk != extDatabase.wblock( pTempDb, list, AcGePoint3d::kOrigin ))
    {
        acedAlert( "wblock failed!" );
        return;
    }
    if (Acad::eOk != acdbHostApplicationServices()->workingDatabase()
        ->insert( AcGeMatrix3d::kIdentity, pTempDb ))
        acedAlert( "insert failed!" );

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-21 00:30 , Processed in 0.182040 second(s), 39 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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