[ARX]求助 块的制作出现问题
<P>以下是我的程序:程序实现(1)makeablock制作一个块 块包含的实体自己选定(2)printall 显示刚才制作的块的一些特性</P><P>问题:为什么特性不能显示?</P>
<P>void ccfch1makeablock()<BR>{<BR> // TODO: Implement the command<BR> AcDbBlockTableRecord *precord=new AcDbBlockTableRecord();<BR> char blockname;<BR> acedGetString(NULL,"\n输入块的名字",blockname);<BR> precord->setName(blockname);//"ASDK-NO-ATT"<BR> AcDbBlockTable *ptable;<BR> AcDbObjectId recordId;<BR> acdbHostApplicationServices()->workingDatabase()->getBlockTable(ptable,AcDb::kForWrite);<BR> ptable->add(recordId,precord);<BR> ptable->close();<BR> ads_name entname,entn;<BR> long len;<BR> AcDbObjectId pentId,pId;<BR> AcDbEntity *pent;<BR> acedSSGet(NULL,NULL,NULL,NULL,entname);<BR> acedSSLength(entname,&len);<BR> for(int i=0;i<len;i++)<BR> {<BR> acedSSName(entname,i,entn);<BR> acdbGetObjectId(pentId,entn);<BR> acdbOpenAcDbEntity(pent,pentId,AcDb::kForRead);<BR> precord->appendAcDbEntity(pId,pent);<BR> pent->close();<BR> }<BR> precord->close();<BR> acedSSFree(entname);<BR> acutPrintf("\n块操作完成");<BR>}</P>
<P>////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////<BR>void ccfch1printall()<BR>{<BR> // TODO: Implement the command<BR> int rc;<BR> char blkName;<BR> rc = acedGetString(Adesk::kTrue,<BR> "Enter Block Name <CR for current space>: ",<BR> blkName);</P>
<P> if (rc != RTNORM)<BR> return;<BR> acutPrintf("\n the 1");<BR> if (blkName == '\0') {<BR> if (acdbHostApplicationServices()->workingDatabase()->tilemode() <BR> == Adesk::kFalse) {<BR> struct resbuf rb;<BR> acedGetVar("cvport", &rb);<BR> if (rb.resval.rint == 1) {<BR> strcpy(blkName, ACDB_PAPER_SPACE);<BR> } else {<BR> strcpy(blkName, ACDB_MODEL_SPACE);<BR> }<BR> } else {<BR> strcpy(blkName, ACDB_MODEL_SPACE);<BR> }<BR> }<BR> acutPrintf("\n the 2");<BR> AcDbBlockTable *pBlockTable;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getSymbolTable(pBlockTable, AcDb::kForRead);</P>
<P> AcDbBlockTableRecord *pBlockTableRecord;<BR> pBlockTable->getAt(blkName, pBlockTableRecord,<BR> AcDb::kForRead);<BR> pBlockTable->close();</P>
<P> AcDbBlockTableRecordIterator *pBlockIterator;<BR> pBlockTableRecord->newIterator(pBlockIterator);<BR> acutPrintf("\n the 3");<BR> for (pBlockIterator->start(); !pBlockIterator->done();<BR> pBlockIterator->step())<BR> {<BR> AcDbEntity *pEntity;<BR> pBlockIterator->getEntity(pEntity, AcDb::kForRead);</P>
<P> acutPrintf("\n the 4");</P>
<P> AcDbHandle objHandle;<BR> pEntity->getAcDbHandle(objHandle);</P>
<P> char handleStr;<BR> objHandle.getIntoAsciiBuffer(handleStr);<BR> const char *pCname = pEntity->isA()->name();<BR> acutPrintf("\n the 5");<BR> acutPrintf("Object Id %lx, handle %s, class %s.\n",<BR> pEntity->objectId(), handleStr, pCname);</P>
<P> pEntity->close();<BR> }<BR> delete pBlockIterator;<BR> pBlockTableRecord->close();</P>
<P> acutPrintf("\n");<BR>}</P> 是不是应该把const char *pCname = pEntity->isA()->name();的const去掉?<BR> <P>不是 因为 for (pBlockIterator->start(); !pBlockIterator->done(); pBlockIterator->step())这个循环进不去,块浏览器根本没有发现实体<BR></P>
页:
[1]