fazi 发表于 2005-9-7 11:26:00

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

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

wuddy 发表于 2005-9-8 11:24:00

是不是应该把const char *pCname = pEntity-&gt;isA()-&gt;name();的const去掉?<BR>

fazi 发表于 2005-9-8 12:51:00

<P>不是 因为 for (pBlockIterator-&gt;start(); !pBlockIterator-&gt;done();&nbsp;pBlockIterator-&gt;step())这个循环进不去,块浏览器根本没有发现实体<BR></P>
页: [1]
查看完整版本: [ARX]求助 块的制作出现问题