- UID
- 432969
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2006-5-6
- 最后登录
- 1970-1-1
|
发表于 2006-7-1 12:46:07
|
显示全部楼层
别人的程序:
AcDbDatabase *pNewDb =new AcDbDatabase(Adesk::kFalse);
int es=pNewDb->readDwgFile(dwgpath , _SH_DENYNO, false);
if (es!=Acad::eOk)
{
acutPrintf("\nThe file %s cannot be opend",dwgpath);
return;
}
AcDbDatabase *pDb;
pDb =acdbHostApplicationServices ()->workingDatabase () ;*/
// pDb->insert( AcGeMatrix3d::kIdentity, pNewDb );
/*
CString pBlockName="TestBlock";
AcDbObjectId blockId;
if((es=pDb->insert(blockId, pBlockName,pNewDb, true))==Acad::eOk)
{
acutPrintf("\ninsert ok\n");
}
else
{
AfxMessageBox("Insert failed");
delete pNewDb;
return;
} */
/*
const AcGePoint3d& Pt=AcGePoint3d(0,0,0);
double Angle=0;
double XrefScale=0;
AcDbBlockReference *pBlkRef = new AcDbBlockReference;
pBlkRef->setBlockTableRecord(blockId);//指向blockId;
pBlkRef->setPosition(Pt);//设定位置
pBlkRef->setRotation(Angle);//设定转角
pBlkRef->setScaleFactors( XrefScale);//设定放大比例
AcDbBlockTable *pBlockTable;
pDb->getSymbolTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);
pBlockTable->close();
AcDbObjectId newEntId;
pBlockTableRecord->appendAcDbEntity(newEntId, pBlkRef);
pBlockTableRecord->close();
AcDbBlockTableRecord *pBlockDef;
acdbOpenObject(pBlockDef, blockId, AcDb::kForRead);
AcDbBlockTableRecordIterator *pIterator;
pBlockDef->newIterator(pIterator);
AcGePoint3d basePoint;
AcDbEntity *pEnt;
AcDbAttributeDefinition *pAttdef;
for (pIterator->start(); !pIterator->done();
pIterator->step())//将source.dwg中所有的Attibute进行遍历
{
pIterator->getEntity(pEnt, AcDb::kForRead);
pAttdef = AcDbAttributeDefinition::cast(pEnt);
if (pAttdef != NULL && !pAttdef->isConstant()) {
AcDbAttribute *pAtt = new AcDbAttribute();
pAtt->setPropertiesFrom(pAttdef);
pAtt->setInvisible(pAttdef->isInvisible());
basePoint = pAttdef->position();
basePoint += pBlkRef->position().asVector();
pAtt->setPosition(basePoint);
pAtt->setHeight(pAttdef->height());
pAtt->setRotation(pAttdef->rotation());
pAtt->setTag("Tag");
pAtt->setFieldLength(25);
char *pStr = pAttdef->tag();
pAtt->setTag(pStr);
// acutDelString(pStr);
pAtt->setFieldLength(pAttdef->fieldLength());
pAtt->setTextString("-");
AcDbObjectId attId;
pBlkRef->appendAttribute(attId, pAtt);
pAtt->close();
}
pEnt->close(); // use pEnt... pAttdef might be NULL
}
delete pIterator; |
|