再次请教!
<P>再次请教各位大虾:程序代码如下,完全是参考的例子上的:</P><P>dwgpath="D:\\Drawing1.dwg";<BR> acDocManager->lockDocument(curDoc(),AcAp::kWrite,NULL,NULL,true);<BR> <BR> AcDbDatabase *pNewDb =new AcDbDatabase(Adesk::kFalse); </P>
<P> Acad::ErrorStatus es=pNewDb->readDwgFile(dwgpath , _SH_DENYNO); <BR> if (es!=Acad::eOk) <BR> { <BR> acutPrintf("\nThe file %s cannot be opend",dwgpath); <BR> return; <BR> } <BR> AcDbDatabase *pDb; <BR> pDb =acdbHostApplicationServices ()->workingDatabase ();<BR> <BR> CString pBlockName=BlockDwg; <BR> AcDbObjectId blockId; //出问题的地方<BR> if((es=pDb->insert(blockId, pBlockName,pNewDb, true))==Acad::eOk) <BR> { <BR> acutPrintf("\ninsert ok\n"); <BR> } <BR> else <BR> { <BR> AfxMessageBox("Insert failed"); <BR> delete pNewDb; <BR> return; <BR> } <BR> <BR> const AcGePoint3d& Pt=AcGePoint3d(0,0,0);<BR> <BR> double Angle=0;<BR> double XrefScale=0;<BR> AcDbBlockReference *pBlkRef = new AcDbBlockReference; <BR> pBlkRef->setBlockTableRecord(blockId);<BR> pBlkRef->setPosition(Pt);<BR> pBlkRef->setRotation(Angle);<BR> pBlkRef->setScaleFactors( XrefScale);<BR> <BR> AcDbBlockTable *pBlockTable; <BR> pDb->getSymbolTable(pBlockTable, AcDb::kForRead); <BR> <BR> AcDbBlockTableRecord *pBlockTableRecord; <BR> pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite); <BR> pBlockTable->close(); <BR> AcDbObjectId newEntId; //出问题的地方<BR> pBlockTableRecord->appendAcDbEntity(newEntId, pBlkRef); <BR> pBlockTableRecord->close(); <BR> <BR> AcDbBlockTableRecord *pBlockDef; <BR> acdbOpenObject(pBlockDef, blockId, AcDb::kForRead); <BR> <BR> AcDbBlockTableRecordIterator *pIterator; <BR> pBlockDef->newIterator(pIterator); <BR> AcGePoint3d basePoint; <BR> AcDbEntity *pEnt; <BR> AcDbAttributeDefinition *pAttdef; <BR> for (pIterator->start(); !pIterator->done(); pIterator->step())//将source.dwg中所有的Attibute进行遍历 <BR> { <BR> pIterator->getEntity(pEnt, AcDb::kForRead); <BR> pAttdef = AcDbAttributeDefinition::cast(pEnt); <BR> if (pAttdef != NULL && !pAttdef->isConstant()) { <BR> AcDbAttribute *pAtt = new AcDbAttribute(); <BR> pAtt->setPropertiesFrom(pAttdef); <BR> pAtt->setInvisible(pAttdef->isInvisible()); <BR> basePoint = pAttdef->position(); <BR> basePoint += pBlkRef->position().asVector(); <BR> pAtt->setPosition(basePoint); <BR> pAtt->setHeight(pAttdef->height()); <BR> pAtt->setRotation(pAttdef->rotation()); <BR> pAtt->setTag("Tag"); <BR> pAtt->setFieldLength(25); <BR> char *pStr = pAttdef->tag(); <BR> pAtt->setTag(pStr); <BR> acutDelString(pStr); <BR> pAtt->setFieldLength(pAttdef->fieldLength()); <BR> pAtt->setTextString("-"); <BR> <BR> AcDbObjectId attId; <BR> <BR> pBlkRef->appendAttribute(attId, pAtt); <BR> pAtt->close(); <BR> } <BR> pEnt->close(); // use pEnt... pAttdef might be NULL <BR> } <BR> delete pIterator; </P>
<P> acDocManager->unlockDocument(curDoc()); </P>
<P>程序编译无误,也将dwg文件的块插到当前稳当的数据库中了,但是不知为什么,视图上并没有显示,查找当前的数据库,发现块名在里面,就是没有图形,请教各位!</P>
<P>另外在AcDbObjectId blockId;这句话时,调试时出现了find symbols对话框,要求查找acdbhdr.pdb文件,cancel掉以后程序能继续执行,真是奇怪,是vc的毛病么,请教!</P>
<P>我的程序是在非模对话框的单击事件里调用的,不知是不是有影响,谢谢各位!</P> <P>谢谢二楼大虾,不过我按照你说的改了其中的:</P>
<P>if((es=pDb->insert(blockId, pBlockName,pNewDb, true))==Acad::eOk) <BR> { <BR> acutPrintf("\ninsert ok\n"); <BR> delete pNewDb; <BR> } <BR> else <BR> { <BR> AfxMessageBox("Insert failed"); <BR> delete pNewDb; <BR> return; <BR> } </P>
<P>删除了pNewDb数据库,但是问题依旧啊。。。。。。</P>
<P>是不是因为加了这句:acDocManager->lockDocument(curDoc(),AcAp::kWrite,NULL,NULL,true);锁定了文档,使图块写不尽去了呢,但是不加这句 程序就出错误,而且将解锁语句acDocManager->unlockDocument(curDoc()); 提前也会出错,头疼。。。。</P> 一边看世界杯,一边想问题,呵呵,ppstream这个网络电视不错,播放很流畅。 <P>还是想不出来,那位大虾帮帮忙啊,不用输入数据的图块能显示,但是有的图块要求输入一些信息的显示不出来,如果用autocad的insert命令通过对话框也可以加入,和锁定文档没什么关系,那位大虾帮忙想想办法!!!</P>
<P> </P> <P>???/</P>
<P>请教高手,帮忙看看,。。。。。。。。。急。。。</P> <P>这个问题应该等价于如何用arx来实现autocad中的insert命令,不过不是动态的,是静态的,也就是并不要求用户输入数据,各位认为如何去做,请教。。。。</P> <P>咋没人理我呢???????</P> <P>搞定了,!!!!</P>
<P>代码没变,我也不知道怎么就可以了,,,,</P>
页:
[1]