- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, this is strange.
When I normally try to get this variable (CLAYER) using acedGetVar, everything works fine. But, when I open current user layer (for write) and then try to read this variable, acedGetVar returns error RTERROR.
Now, when I read variable ERRNO I get the result: "Value out of range"
This is part of my code for retrieving variables(it isn't really interesting):
template<typename T>
inline T GetVariable(const std::wstring & name)
{
ResBufWrapperPtr pResBuf(new ResBufWrapper());
int res = acedGetVar(name.c_str(), pResBuf->GetFirstResBuf());
if(res != RTNORM)
{
ResBufWrapperPtr pErrNo(new ResBufWrapper());
acedGetVar(L"ERRNO", pErrNo->GetFirstResBuf());
AcString msg;
msg.format(L"Could not get system variable: %s. Error %d", name.c_str(), res);
throw CLAAS_EXCEPTION(msg.constPtr());
}
return GetVariableData<T>(*pResBuf->GetFirstResBuf());
}
And this is my code that wants to know the value of CLAYER:
//first lock the document AcAp::DocLockMode lm = m_pDoc->lockMode(true); //next open layer for write AcDbObjectPointer<AcDbObject> pObj(id, AcDb::kForWrite);
Now, when I call acedGetVar("CLAYER") before opening the object, everything works fine. But when I call it after opening the object, I get the error. But to receive this error, the object that you're opening must be really current user layer. So you can create a layer and set it as user layer (acedSetVar). And then open this object and call acedGetVar("CLAYER")
Is that an Autocad bug or do I do something wrong? I noticed this error on Autocad 2014, but it exists on other versions as well (2015, 2016)
Solved! Go to Solution.

