明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1703|回复: 2

[ARX]求助 块的制作出现问题

[复制链接]
发表于 2005-9-7 11:26:00 | 显示全部楼层 |阅读模式

以下是我的程序:程序实现(1)makeablock制作一个块 块包含的实体自己选定(2)printall 显示刚才制作的块的一些特性

问题:为什么特性不能显示?

void ccfch1makeablock()
{
 // TODO: Implement the command
  AcDbBlockTableRecord *precord=new AcDbBlockTableRecord();
   char blockname[10];
   acedGetString(NULL,"\n输入块的名字",blockname);
   precord->setName(blockname);//"ASDK-NO-ATT"
   AcDbBlockTable *ptable;
   AcDbObjectId recordId;
   acdbHostApplicationServices()->workingDatabase()->getBlockTable(ptable,AcDb::kForWrite);
   ptable->add(recordId,precord);
   ptable->close();
  ads_name entname,entn;
   long len;
   AcDbObjectId pentId,pId;
   AcDbEntity *pent;
   acedSSGet(NULL,NULL,NULL,NULL,entname);
   acedSSLength(entname,&len);
   for(int i=0;i<len;i++)
   {
     acedSSName(entname,i,entn);
  acdbGetObjectId(pentId,entn);
  acdbOpenAcDbEntity(pent,pentId,AcDb::kForRead);
  precord->appendAcDbEntity(pId,pent);
  pent->close();
   }
   precord->close();
   acedSSFree(entname);
   acutPrintf("\n块操作完成");
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void ccfch1printall()
{
 // TODO: Implement the command
 int rc;
    char blkName[50];
    rc = acedGetString(Adesk::kTrue,
        "Enter Block Name <CR for current space>: ",
        blkName);

   if (rc != RTNORM)
        return;
 acutPrintf("\n the 1");
    if (blkName[0] == '\0') {
        if (acdbHostApplicationServices()->workingDatabase()->tilemode()
            == Adesk::kFalse) {
            struct resbuf rb;
            acedGetVar("cvport", &rb);
            if (rb.resval.rint == 1) {
                strcpy(blkName, ACDB_PAPER_SPACE);
            } else {
                strcpy(blkName, ACDB_MODEL_SPACE);
            }
        } else {
            strcpy(blkName, ACDB_MODEL_SPACE);
        }
    }
 acutPrintf("\n the 2");
    AcDbBlockTable *pBlockTable;
    acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pBlockTable, AcDb::kForRead);

    AcDbBlockTableRecord *pBlockTableRecord;
    pBlockTable->getAt(blkName, pBlockTableRecord,
        AcDb::kForRead);
    pBlockTable->close();

    AcDbBlockTableRecordIterator *pBlockIterator;
    pBlockTableRecord->newIterator(pBlockIterator);
 acutPrintf("\n the 3");
    for (pBlockIterator->start(); !pBlockIterator->done();
        pBlockIterator->step())
    {
        AcDbEntity *pEntity;
        pBlockIterator->getEntity(pEntity, AcDb::kForRead);

 acutPrintf("\n the 4");

        AcDbHandle objHandle;
        pEntity->getAcDbHandle(objHandle);

        char handleStr[20];
        objHandle.getIntoAsciiBuffer(handleStr);
        const char *pCname = pEntity->isA()->name();
 acutPrintf("\n the 5");
        acutPrintf("Object Id %lx, handle %s, class %s.\n",
            pEntity->objectId(), handleStr, pCname);

        pEntity->close();
    }
    delete pBlockIterator;
    pBlockTableRecord->close();

    acutPrintf("\n");
}

发表于 2005-9-8 11:24:00 | 显示全部楼层
是不是应该把const char *pCname = pEntity->isA()->name();的const去掉?
 楼主| 发表于 2005-9-8 12:51:00 | 显示全部楼层

不是 因为 for (pBlockIterator->start(); !pBlockIterator->done(); pBlockIterator->step())这个循环进不去,块浏览器根本没有发现实体

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

本版积分规则

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

GMT+8, 2024-11-26 04:22 , Processed in 0.151481 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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