ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DWG preview

0 REPLIES 0
Reply
Message 1 of 1
Nick1983
764 Views, 0 Replies

DWG preview

I use function

Acad::ErrorStatus open_save_close(const ACHAR *DWGFileName)
{ 
	struct resbuf DWGMode;
	int nRetVal = acedGetVar(_T("SDI"), &DWGMode);
	if ( RTNORM != nRetVal) return Acad::eKeyNotFound;
	if (DWGMode.resval.rint != 0)
		return Acad::eCantOpenFile;
			
	Acad::ErrorStatus es = Acad::eOk;
	CComPtr<AutoCAD::IAcadDocument> IDoc;
			
	CComPtr<AutoCAD::IAcadApplication> IApp;
	CComPtr<AutoCAD::IAcadDocuments> IDocs;
	CComPtr<IDispatch> pDisp = acedGetAcadWinApp()->GetIDispatch(TRUE);
	if(!pDisp) return Acad::eCantOpenFile;
	HRESULT hr = pDisp->QueryInterface(AutoCAD::IID_IAcadApplication,(void**)&IApp);
	if (FAILED(hr)) return Acad::eCantOpenFile;	

	hr = IApp->get_Documents(&IDocs);
	if(FAILED(hr)) return Acad::eCantOpenFile;

	_variant_t b(VARIANT_FALSE);
	hr = IDocs->Open(_bstr_t(DWGFileName),b,b,&IDoc);
	if(FAILED(hr)) return Acad::eCantOpenFile;

	hr = IApp->ZoomExtents();
	if(FAILED(hr)) return Acad::eCantOpenFile;

	VARIANT saveChanges, fileName; 
	saveChanges.vt = VT_BOOL;
	saveChanges.boolVal = VARIANT_FALSE;
	fileName.vt = VT_ERROR;
	fileName.scode = DISP_E_PARAMNOTFOUND;
	IDoc->Save();
	IDoc->Close(saveChanges, fileName);
	return Acad::eOk;
}

 to force autocad to create a preview bitmap of the drawing named DWGFileName.

it worked fine for autocad 2008-2014 (32\64bit), but now, i have 2 installed autocads 2013 32bit, which refuse to generate preview (if i create drawing using objectarx, put something to it, close it, then use function open_save_close.) when i open such drawing there is no preview bitmap in open dialog window. but if i SAVE it using autocad native menu command and reopen it, preview is generated.

the question is why preview is not generated using my function for those 2 autocads, but save command generates it fine?

---
#define QUESTION(b) (2*b)||(!(2*b)) © William Shakespeare
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost