.dwg文件的读取。拥有RealDWG或者ObjectARX不必多说。
安装RealDWG后RealDWG目录下的Samples看看。
新建工程配置好Inc,Lib,附加依赖等。
不必多说。
需要将AcDbHostApplicationServices实现一遍。
sample自带的即可,也可自己按照自己的来写。
1 int Verbose = 0; 2 int Copy = 0; 3 int Header = 0; 4 int Tables = 0; 5 int doExtents = 0; 6 int showErased = 0; 7 int resolveXrefs = 0; 8 9 class DumpDwgHostApp : public AcDbHostApplicationServices 10 { 11 public: 12 ~DumpDwgHostApp(); 13 Acad::ErrorStatus findFile(TCHAR* pcFullPathOut, int nBufferLength, 14 const TCHAR* pcFilename, AcDbDatabase* pDb = NULL, 15 AcDbHostApplicationServices::FindFileHint = kDefault); 16 // These two functions return the full path to the root folder where roamable/local 17 // customizable files were installed. Note that the user may have reconfigured 18 // the location of some the customizable files using the Options Dialog 19 // therefore these functions should not be used to locate customizable files. 20 // To locate customizable files either use the findFile function or the 21 // appropriate system variable for the given file type. 22 // 23 Acad::ErrorStatus getRoamableRootFolder(const TCHAR*& folder); 24 Acad::ErrorStatus getLocalRootFolder(const TCHAR*& folder); 25 26 //URL related services 27 Adesk::Boolean isURL(const TCHAR* pszURL) const; 28 Adesk::Boolean isRemoteFile(const TCHAR* pszLocalFile, TCHAR* pszURL, size_t nUrlSize) const; 29 Acad::ErrorStatus getRemoteFile(const TCHAR* pszURL, TCHAR* pszLocalFile, size_t nFilePath, Adesk::Boolean bIgnoreCache) const; 30 31 // make sure you implement getAlternateFontName. In case your findFile implementation 32 // fails to find a font you should return a font name here that is guaranteed to exist. 33 virtual TCHAR * getAlternateFontName() const 34 { 35 return _T("txt.shx"); //findFile will be called again with this name 36 } 37 private: 38 mutable CMapStringToString m_localToUrl; 39 }; 40 DumpDwgHostApp::~DumpDwgHostApp() 41 { 42 CString local,url; 43 for (POSITION pos = m_localToUrl.GetStartPosition();pos!=NULL;) 44 { 45 m_localToUrl.GetNextAssoc(pos,local,url); 46 DeleteUrlCacheEntry(url); 47 } 48 } 49 // Return the Install directory for customizable files 50 Acad::ErrorStatus 51 DumpDwgHostApp::getRoamableRootFolder(const TCHAR*& folder) 52 { 53 Acad::ErrorStatus ret = Acad::eOk; 54 static TCHAR buf[MAX_PATH] = _T("