找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 538|回复: 2

[求助]:請問以下 map object arx 的程式碼錯在哪?

[复制链接]
发表于 2003-9-4 11:49:11 | 显示全部楼层 |阅读模式

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

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

×
//this function is to attach the object data to the selection which is fit to
// the input layer name
//功能:先取得使用者輸入的圖層名稱,再取得使用者輸入的選集
//當選集中物件是在使用者輸入的圖層時attach the object data

//執行時都能正常運作 但object data不能貼附到物件上



        // ----- asdkmap._addODbyLayer command (do not rename)
static void asdkmap_addODbyLayer(void)
        {
                // Add your code for command asdkmap._addODbyLayer here



                ads_name ss, ename;
               
                long sslen, sscur;

                AcDbObjectId eId;

                AcDbEntity *pEnt;


                AcMapSession *mapApi = NULL;

                AcMapProject *pProj = NULL;

                AcMapODContainer *pODCont = NULL;

                AcMapODTable *pODTable = NULL;  

                 

                mapApi = AcMapGetSession();

                mapApi->GetProject(pProj);

                pProj->GetODContainer(pODCont);

                pODCont->GetODTable(pODTable, "owner");

//                acutPrintf("flag 7\n");
               


//get input layer 取得 與用者輸入的圖層名稱
                               
                AcDbObjectId inputLayerID;
                char inputLayerName[3];

                if (acedGetString(0,"input filter layer name:",inputLayerName) == Adesk::kFalse){
                        acutPrintf("\nlayer Name is not suitable");
                        return;
                }

                if(checkLayer(inputLayerName) !=Acad::eOk){
                        return;
                }

                getLayerIdFromString(inputLayerName,inputLayerID);
//選取物件
                acutPrintf("\nselect the objects you want to add object data ?");

                if (acedSSGet(NULL, NULL, NULL, NULL, ss) != RTNORM) {

                        acutPrintf("\nNo objects selected.\n");

                        acedSSFree(ss);

                        return;

                }


                acedSSLength(ss, &sslen);

                acutPrintf("flag 6");

//check every entity in the selection and attach the object data, if fit the condition
//檢查每個物件是否在指定圖層上  如果是在指定圖層上 attach object data

                for (sscur = 0; sscur < sslen; sscur++)

                {

                        acedSSName(ss, sscur, ename);

                        acdbGetObjectId(eId, ename);

                        acdbOpenAcDbEntity(pEnt, eId, AcDb::kForRead);

                        char *temp;
                        temp = pEnt->layer();

                        if(*temp == inputLayerName[0]){

                        //        attachODById(eId);

                                AcMapODTableRecord *pTabRec = NULL;

                                pTabRec = new AcMapODTableRecord();

                                pODTable->AddRecord(*pTabRec , eId);

                                acutPrintf("\n object id : %lx", eId);
                                       
                                //acutPrintf(\n object id : %lx", targetId);
                                //acutPrintf("\nObject Id %lx",targetId);

                                acutPrintf ("\nOD Record added to object.");


                                if (pTabRec) delete pTabRec;


                                highlightAll(eId);
                        }

                        pEnt->close();
                }

                delete pODTable;

               

        acedSSFree(ss);


        }



//檢查圖層是否存在

static Acad::ErrorStatus
checkLayer(char* layerName)
{
    AcDbLayerTable *pLayerTbl;
    acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pLayerTbl, AcDb::kForWrite);


    if (!pLayerTbl->has(layerName)) {
   
                return Acad::eNotApplicable;

    } else {
        pLayerTbl->close();
        acutPrintf("\nlayer already exists");
                return Acad::eOk;
    }
}



//從輸入的字串取得layerId
static Acad::ErrorStatus
getLayerIdFromString(const char* pStr, AcDbObjectId& ID)

{
    //  Get a pointer to the drawing's layer table
    //
    AcDbLayerTable* pLayerTable;
    Acad::ErrorStatus err = acdbCurDwg()->getLayerTable(pLayerTable,
        AcDb::kForRead);
    if (err != Acad::eOk)
        return err;

    // Get the ID of the layer with the name in 'pStr' (even if it's
    // erased) and place it in 'id'.  
    //
    err = pLayerTable->getAt(pStr, ID, Adesk::kTrue);

    pLayerTable->close();

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

已领礼包: 145个

财富等级: 日进斗金

发表于 2003-9-4 12:04:13 | 显示全部楼层

Re: [求助]:請問以下 map object arx 的程式碼錯在哪?

最初由 origo 发布
[B]//the problem is object data can't be attached to the entity



//this function is to attach the object data to the selection which is fit to
// the input layer name



        // ----- asdkmap._ad... [/B]


请你把你的代码的功能、作用,和你调试时候出现的错误提示等等告诉大家,你给够大家足够的信息,最终方便的是你。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-6-24 14:11:50 | 显示全部楼层
1楼楼主说:[求助]:請問以下 map object arx 的程式碼錯在哪?  
我现在也要用一些map的开发,但是autocad的类库中并没有包含有一楼楼主提到的那些类!请问我需要安装那些东西?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-21 20:29 , Processed in 0.181332 second(s), 36 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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