insert dwf file
AcDbObjectId CBlockUtil::InsertDwf(CString strFileFullPath, CString strFileName, AcGePoint3d insertPoint, double dbScale, double dbRotation){
AcDbDictionary *pNamedobj = NULL;
AcDbDictionary *pAPPDict = NULL;
AcDbDictionary *pDict = NULL;
AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase();
Acad::ErrorStatus es;
es = pDb->getNamedObjectsDictionary(pNamedobj, AcDb::kForWrite);
if (Acad::eOk != es) return false;
CString strAppName = TEXT("APP"), strFieldName = TEXT("PLOT");
if (pNamedobj->getAt(strAppName, (AcDbObject*&)pAPPDict, AcDb::kForWrite) == Acad::eKeyNotFound)
{
pAPPDict = new AcDbDictionary;
AcDbObjectId dictId;
pNamedobj->setAt(strAppName, pAPPDict, dictId);
}
pNamedobj->close();
if (pAPPDict->getAt(strFieldName, (AcDbObject*&)pDict, AcDb::kForWrite) == Acad::eKeyNotFound)
{
pDict = new AcDbDictionary;
AcDbObjectId dictId;
pAPPDict->setAt(strFieldName, pDict, dictId);
}
pAPPDict->close();
AcDbDwfDefinition *pDwfDef = new AcDbDwfDefinition;
pDwfDef->setSourceFileName(strFileFullPath);
AcDbObjectId entId;
es = pDict->setAt(strFileName, (AcDbObject*&)pDwfDef, entId);
pDict->close();
pDwfDef->close();
AcDbDwfReference *pDwfRef = new AcDbDwfReference;
es = pDwfRef->setDefinitionId(entId);
es = pDwfRef->setPosition(insertPoint);
es = pDwfRef->setRotation(dbRotation);
es = pDwfRef->setScaleFactors(dbScale);
es = pDwfRef->setIsOn(true);
es = pDwfRef->setFade(0);
AcDbObjectId idDwfRef = AcDbObjectId::kNull;
idDwfRef = CDwgDatabaseUtil::PostToModelSpace((AcDbEntity*)pDwfRef);
pDwfRef->close();
return idDwfRef;
} es = pDwfRef->setDefinitionId(entId);
es = pDwfRef->setNormal(AcGeVector3d::kZAxis);
es = pDwfRef->setPosition(insertPoint);
es = pDwfRef->setRotation(dbRotation); es = pDwfRef->setDefinitionId(entId);
es = pDwfRef->setNormal(AcGeVector3d::kZAxis);
es = pDwfRef->setPosition(insertPoint);
es = pDwfRef->setRotation(0.0);
AcGeMatrix3d rot;
rot.setToRotation(dbRotation, AcGeVector3d::kZAxis, insertPoint);
pDwfRef->transformBy(rot);
页:
[1]