找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 501|回复: 1

[ARX程序]:办忙了

[复制链接]
发表于 2002-11-24 22:40:41 | 显示全部楼层 |阅读模式

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

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

×
编译通过(为什么运行重视出现对话框‘读写错误“
谢指点)dys-cj@home.ncidi.com...
原程序如下:
CString fname=getfilename.file1;
        CString addintional="d:\\";
        fname=addintional+fname+".dwg";
        //additional prase
        //

        acutPrintf("fname.....%s\n",fname);
        //end.cj

        AcDbDatabase* pDb;
        AcDbObjectId transId;
        pDb = new AcDbDatabase(Adesk::kFalse);
        pDb->readDwgFile(fname);
    if (pDb->readDwgFile(fname) != Acad::eOk)
        {
        acutPrintf("\nSorry, that draing is probably already open.\n");
        return;
    }
    // Get the Block Table and then the model space record.
    //
    AcDbBlockTable *pBlockTable;
    pDb->getSymbolTable(pBlockTable, AcDb::kForRead);
    AcDbBlockTableRecord *pOtherMsBtr;
    pBlockTable->getAt(ACDB_MODEL_SPACE, pOtherMsBtr, AcDb::kForRead);
    pBlockTable->close();
    // Create an iterator.
    //
    AcDbBlockTableRecordIterator *pIter;
    pOtherMsBtr->newIterator(pIter);
    // Set up an object ID array.
    //
    AcDbObjectIdArray objIdArray;
    // Iterate over the model space BTR. Look specifically
    // for lines and append their object ID to the array.
    //
    for (pIter->start(); !pIter->done(); pIter->step())
        {
        AcDbEntity *pEntity;//AcDbText *pEntitytext;
        pIter->getEntity(pEntity, AcDb::kForRead);
        // Look for only AcDbLine objects and add them to the
        // object ID array.
        //
        if (pEntity->isKindOf(AcDbText::desc()))
                {
            objIdArray.append(pEntity->objectId());
        }
        //        pEntitytext->close();
                acutPrintf("111d\n");
        pEntity->close();
    }
    delete pIter;
    pOtherMsBtr->close();
    if (objIdArray.isEmpty())
        {
        //acutPrintf("\nYou must pick a drawing file that contains lines.");
        return;
    }
    // Now get the current database and the object ID for the
    // current database's model space BTR.
    //
    AcDbBlockTable *pThisBlockTable;
    acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pThisBlockTable, AcDb::kForRead);
    AcDbBlockTableRecord *pThisMsBtr;
    pThisBlockTable->getAt(ACDB_MODEL_SPACE, pThisMsBtr, AcDb::kForWrite);
    pThisBlockTable->close();
    AcDbObjectId id = pThisMsBtr->objectId();
    pThisMsBtr->close();
    // Create the long transaction. This will check all the entities
    // out of the external database.
    //
    AcDbIdMapping errorMap;
    acapLongTransactionManagerPtr()->checkOut(transId, objIdArray, id, errorMap);

    // Now modify the color of these entities.
    //
    AcDbObject* pObj;
        //w .by.cj

        //w.by.cj

    if (acdbOpenObject(pObj, transId, AcDb::kForRead) == Acad::eOk)
        {
        AcDbLongTransaction* pLongTrans = AcDbLongTransaction::cast(pObj);
        if (pLongTrans != NULL)
                {
            // Get a work set iterator.
            //
            AcDbLongTransWorkSetIterator* pWorkSetIter;
            pLongTrans->newWorkSetIterator(pWorkSetIter);

                        //add///cj
                       
                        for (pWorkSetIter->start(); !pWorkSetIter->done(); pWorkSetIter->step())
                        {
                AcDbText *pEntity;
                acdbOpenObject(pEntity, pWorkSetIter->objectId(), AcDb::kForWrite);
                //假如语句       
        if(pEntity->textString()=="yyy"                               
        {
pEntity->setTextString("xxx");
                                }
                    pEntity->close();
            }
            delete pWorkSetIter;
        }
        pObj->close();
        }
     acapLongTransactionManagerPtr()->checkIn(transId, errorMap);
        pDb->saveAs(fname);
        delete pDb;
        pDb = NULL;
        acutPrintf("ddd,end....%s",fname);
//        acad_free(fname);
}
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2002-11-25 08:48:33 | 显示全部楼层
请不要重复发主题,浪费别人时间!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-28 11:25 , Processed in 0.329352 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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