// second parameter is 0 for current database.
AcDbRasterVariables * pRasterVariables = AcDbRasterVariables::openRasterVariables(AcDb::kForWrite, 0);
pRasterVariables->setImageFrame(AcDbRasterVariables::FrameSettings::kImageFrameOff);
pRasterVariables->close();
This is frustrating. I can read raster varaibles just fine but any attempt to
change them crashes AutoCAD. Would you mind taking a look at this? acdbCurDb()
is a function I wrote to return the database of the active document.
lockdocument() locks the active document using the kAutoWrite parameter.
The get_ImageFrame works perfectly. The put_ImageFrame crashes AutoCAD without
fail. What am I doing wrong?
STDMETHODIMP CAcadRasterVariables::get_ImageFrame(vbxFrameSettings *pVal)
{
HRESULT hReturn = S_OK;
AcDbRasterVariables* pImageVars =
AcDbRasterVariables::openRasterVariables(AcDb::kForRead, acdbCurDb());
*pVal = (vbxFrameSettings)pImageVars->imageFrame();
return hReturn;
}
STDMETHODIMP CAcadRasterVariables::put_ImageFrame(vbxFrameSettings newVal)
{
HRESULT hReturn = S_OK;
if (lockDocument() != Acad::eOk)
hReturn = ReportError("Could not lock document.", E_ACCESSDENIED);
{
AcDbRasterVariables* pImageVars =
AcDbRasterVariables::openRasterVariables(AcDb::kForWrite, acdbCurDb());
if(pImageVars->setImageFrame((AcDbRasterVariables::FrameSettings)newVal) !=
Acad::eOk)
hReturn = ReportError("Could not change frame property.", E_FAIL);
}
return hReturn;
}
—
http://www.acadx.com
Win a free autographed copy of
"AutoCAD 2000 VBA Programmer's Reference"
输入imageframe命令,将参数值改为0;