<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: acedGetVar with CLAYER returns error: Value out of range in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/acedgetvar-with-clayer-returns-error-value-out-of-range/m-p/6840809#M8838</link>
    <description>&lt;P&gt;I've not check your code but think that function acadGetVar(L"CLAYER",...) also trying то open AcDbLayerTableRecord of current layer in order to get it name, but if this AcDbLayerTableRecord was already opened ForWrite so acadGetVar can not open AcDbLayerTableRecord second time and so return error code.&lt;/P&gt;</description>
    <pubDate>Mon, 30 Jan 2017 16:43:46 GMT</pubDate>
    <dc:creator>Alexander.Rivilis</dc:creator>
    <dc:date>2017-01-30T16:43:46Z</dc:date>
    <item>
      <title>acedGetVar with CLAYER returns error: Value out of range</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acedgetvar-with-clayer-returns-error-value-out-of-range/m-p/6840309#M8837</link>
      <description>&lt;P&gt;Hi, this is strange.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Now, when I read variable ERRNO I get the result: "Value out of range"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is part of my code for retrieving variables(it isn't really interesting):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;template&amp;lt;typename T&amp;gt;
inline T GetVariable(const std::wstring &amp;amp; name)
{
	ResBufWrapperPtr pResBuf(new ResBufWrapper());		
	int res = acedGetVar(name.c_str(), pResBuf-&amp;gt;GetFirstResBuf());
	if(res != RTNORM)
	{
		ResBufWrapperPtr pErrNo(new ResBufWrapper());
		acedGetVar(L"ERRNO", pErrNo-&amp;gt;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&amp;lt;T&amp;gt;(*pResBuf-&amp;gt;GetFirstResBuf());
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this is my code that wants to know the value of CLAYER:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;//first lock the document
AcAp::DocLockMode lm = m_pDoc-&amp;gt;lockMode(true);

//next open layer for write
AcDbObjectPointer&amp;lt;AcDbObject&amp;gt; pObj(id, AcDb::kForWrite);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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)&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 14:28:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acedgetvar-with-clayer-returns-error-value-out-of-range/m-p/6840309#M8837</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-01-30T14:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: acedGetVar with CLAYER returns error: Value out of range</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acedgetvar-with-clayer-returns-error-value-out-of-range/m-p/6840809#M8838</link>
      <description>&lt;P&gt;I've not check your code but think that function acadGetVar(L"CLAYER",...) also trying то open AcDbLayerTableRecord of current layer in order to get it name, but if this AcDbLayerTableRecord was already opened ForWrite so acadGetVar can not open AcDbLayerTableRecord second time and so return error code.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 16:43:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acedgetvar-with-clayer-returns-error-value-out-of-range/m-p/6840809#M8838</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2017-01-30T16:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: acedGetVar with CLAYER returns error: Value out of range</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acedgetvar-with-clayer-returns-error-value-out-of-range/m-p/6842650#M8839</link>
      <description>&lt;P&gt;Not only this seems logical, but also it's true. I've checked it. Thanks for reply &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 08:47:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acedgetvar-with-clayer-returns-error-value-out-of-range/m-p/6842650#M8839</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-01-31T08:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: acedGetVar with CLAYER returns error: Value out of range</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acedgetvar-with-clayer-returns-error-value-out-of-range/m-p/9450973#M8840</link>
      <description>&lt;P&gt;Can you please Help? I am trying to import GPS coordinates, gamma strengths, icon sizes, ect. from Script file and also command line paste. The script file is fine (I have a sample from a friend to compare), but I keep getting, "enter new value for clayer", "Cannot set value for clayer" or "specify point". I am pulling my hair out. Paul: 305-699-8071 , Key West&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 15:42:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acedgetvar-with-clayer-returns-error-value-out-of-range/m-p/9450973#M8840</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-17T15:42:31Z</dc:date>
    </item>
  </channel>
</rss>

