<?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 Can not connvert int to AcDbObjectIdArray error when NULL is assign to AcDbObjectIdArray variable in ObjectARX 2023. in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11435945#M2241</link>
    <description>&lt;P&gt;Please resolve this issue.&lt;/P&gt;&lt;P&gt;If I assign&amp;nbsp;NULL to AcDbObjectIdArray variable in ObjectARX 2023 in visual studio 2019 it is giving error can not convert from int to&amp;nbsp;AcDbObjectIdArray. Screen shot is attached with this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example :&amp;nbsp;&lt;/P&gt;&lt;P&gt;AcDbObjectIdArray arrObj = NULL;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this giving error can not convert from int to&amp;nbsp;AcDbObjectIdArray.&lt;/P&gt;</description>
    <pubDate>Wed, 21 Sep 2022 12:10:13 GMT</pubDate>
    <dc:creator>nkokate052</dc:creator>
    <dc:date>2022-09-21T12:10:13Z</dc:date>
    <item>
      <title>Can not connvert int to AcDbObjectIdArray error when NULL is assign to AcDbObjectIdArray variable in ObjectARX 2023.</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11435945#M2241</link>
      <description>&lt;P&gt;Please resolve this issue.&lt;/P&gt;&lt;P&gt;If I assign&amp;nbsp;NULL to AcDbObjectIdArray variable in ObjectARX 2023 in visual studio 2019 it is giving error can not convert from int to&amp;nbsp;AcDbObjectIdArray. Screen shot is attached with this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example :&amp;nbsp;&lt;/P&gt;&lt;P&gt;AcDbObjectIdArray arrObj = NULL;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this giving error can not convert from int to&amp;nbsp;AcDbObjectIdArray.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 12:10:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11435945#M2241</guid>
      <dc:creator>nkokate052</dc:creator>
      <dc:date>2022-09-21T12:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: Can not connvert int to AcDbObjectIdArray error when NULL is assign to AcDbObjectIdArray variable in ObjectARX 2023.</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11436041#M2242</link>
      <description>&lt;P&gt;Just write&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;AcDbObjectIdArray arrObj;&lt;/FONT&gt;&amp;nbsp; &amp;nbsp;to get an empty array.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 12:48:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11436041#M2242</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2022-09-21T12:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: Can not connvert int to AcDbObjectIdArray error when NULL is assign to AcDbObjectIdArray variable in ObjectARX 2023.</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11436063#M2243</link>
      <description>&lt;P&gt;but i have to set default value to AcDbObjectIdArray variable in function declaration.&lt;/P&gt;&lt;P&gt;What can I do to set default value?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 12:59:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11436063#M2243</guid>
      <dc:creator>nkokate052</dc:creator>
      <dc:date>2022-09-21T12:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: Can not connvert int to AcDbObjectIdArray error when NULL is assign to AcDbObjectIdArray variable in ObjectARX 2023.</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11436323#M2244</link>
      <description>&lt;P&gt;&lt;FONT face="courier new,courier"&gt;AcDbObjectIdArray&lt;/FONT&gt; has a very nice default constructor that creates an empty array of &lt;FONT face="courier new,courier"&gt;AcDbObjectId&lt;/FONT&gt;s. You just don't need a default value. If you insist in assigning a default value (i.e. for syntactical reasons) you can do something like this:&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;AcDbObjectIdArray emptyIdArray; // global variable

void fkt() {
    AcDbObjectIdArray ids1 = emptyIdArray;
    AcDbObjectIdArray ids2 = AcDbObjectIdArray();
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;AcDbObjectIdArray&amp;nbsp;&lt;/FONT&gt;is a typedef:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; typedef AcArray&amp;lt;AcDbObjectId&amp;gt; AcDbObjectIdArray;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The assignment operator of &lt;FONT face="courier new,courier"&gt;AcArray&lt;/FONT&gt;&amp;lt;T,R&amp;gt; only accepts another &lt;FONT face="courier new,courier"&gt;AcArray&lt;/FONT&gt;:&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;    AcArray&amp;lt;T,R&amp;gt;&amp;amp;         operator =  (const AcArray&amp;lt;T,R&amp;gt;&amp;amp;);
    AcArray&amp;lt;T,R&amp;gt;&amp;amp;         operator =  (AcArray&amp;lt;T,R&amp;gt;&amp;amp;&amp;amp;);
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 14:22:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11436323#M2244</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2022-09-21T14:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: Can not connvert int to AcDbObjectIdArray error when NULL is assign to AcDbObjectIdArray variable in ObjectARX 2023.</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11437366#M2245</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5352324"&gt;@nkokate052&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;but i have to set default value to AcDbObjectIdArray variable in function declaration.&lt;/P&gt;
&lt;P&gt;What can I do to set default value?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It sounds like you might be passing the array by value, as in:&amp;nbsp; &lt;STRONG&gt;myfunc(AcDbObjectIdArray idArr)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;That's not usually the best practice, because it can cause unnecessary copying of the array during func calls.&lt;/P&gt;
&lt;P&gt;If the array is not being modified, you can pass a const ref, as in:&amp;nbsp; &lt;STRONG&gt;myfunc(const AcDbObjectIdArray &amp;amp; idArr)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;And if it *is* being modified, then pass it as a non-const ref:&amp;nbsp;&lt;STRONG&gt;myfunc(AcDbObjectIdArray &amp;amp; idArr)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Or, if the array arg is optional, you can make it a ptr :&amp;nbsp; &lt;STRONG&gt;myfunc(const AcDbObjectIdArray *pArr = nullptr);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 22:22:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11437366#M2245</guid>
      <dc:creator>autodaug</dc:creator>
      <dc:date>2022-09-21T22:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Can not connvert int to AcDbObjectIdArray error when NULL is assign to AcDbObjectIdArray variable in ObjectARX 2023.</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11437552#M2246</link>
      <description>&lt;P&gt;looks like you're trying to do an optional argument, you can pass by pointer.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;    static void Foo()
    {
        AcDbObjectIdArray ids;
        func(10, &amp;amp;ids);
        acutPrintf(_T("\nfoo %ld"), ids.length());
    }

    static void Far()
    {
        AcDbObjectIdArray ids;
        func(10);
        acutPrintf(_T("\nfar = %ld"), ids.length());
    }

    static void foobar()
    {
        std::unique_ptr&amp;lt;AcDbObjectIdArray&amp;gt; pids; //is null
        func(10, pids.get());
        if (pids)
            acutPrintf(_T("\nfoobar = %ld"), pids-&amp;gt;length());
        else
            acutPrintf(_T("\nfoobar = %ld"), 0);
    }

    static void furbar()
    {
        std::unique_ptr&amp;lt;AcDbObjectIdArray&amp;gt; pids(new AcDbObjectIdArray());
        func(10, pids.get());
        if (pids)
            acutPrintf(_T("\nfurbar = %ld"), pids-&amp;gt;length());
        else
            acutPrintf(_T("\nfurbar = %ld"), 0);

    }

    static void func(size_t cnt, AcDbObjectIdArray* ids = nullptr)
    {
        if (ids != nullptr)
        {
            for (size_t idx = 0; idx &amp;lt; cnt; idx++)
                ids-&amp;gt;append(AcDbObjectId::kNull);
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2022 01:02:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11437552#M2246</guid>
      <dc:creator>daniel_cadext</dc:creator>
      <dc:date>2022-09-22T01:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: Can not connvert int to AcDbObjectIdArray error when NULL is assign to AcDbObjectIdArray variable in ObjectARX 2023.</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11438016#M2247</link>
      <description>&lt;P&gt;As I suggested before you can pass a default value to a function like this:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;int defArr(AcDbObjectIdArray arr = AcDbObjectIdArray());&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;or like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;//Header file:
extern AcDbObjectIdArray defaultIdArray; // global variable
int defArr2(AcDbObjectIdArray arr=defaultIdArray);


//CPP file:
AcDbObjectIdArray defaultIdArray;

int defArr2(AcDbObjectIdArray arr) {
    return arr.length(); //i.e.
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/415386"&gt;@autodaug&lt;/a&gt;'s&amp;nbsp;approach is a little more efficient.&lt;/P&gt;
&lt;P&gt;But if you don't want to change function signatures you can do it like this.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2022 07:11:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11438016#M2247</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2022-09-22T07:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Can not connvert int to AcDbObjectIdArray error when NULL is assign to AcDbObjectIdArray variable in ObjectARX 2023.</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11439297#M2248</link>
      <description>&lt;P&gt;I agree, if you want to pass the array by value, and have a default parameter, then it should be &lt;STRONG&gt;= AcDbObjectIdArray()&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The second approach with the global &lt;STRONG&gt;defaultIdArray&lt;/STRONG&gt; object is more complicated and less flexible, imo.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2022 16:09:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11439297#M2248</guid>
      <dc:creator>autodaug</dc:creator>
      <dc:date>2022-09-22T16:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Can not connvert int to AcDbObjectIdArray error when NULL is assign to AcDbObjectIdArray variable in ObjectARX 2023.</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11440127#M2249</link>
      <description>&lt;P&gt;I assumed it was an [in][out] parameter, with a global or a new there's no way to know since there's no null.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2022 22:41:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/can-not-connvert-int-to-acdbobjectidarray-error-when-null-is/m-p/11440127#M2249</guid>
      <dc:creator>daniel_cadext</dc:creator>
      <dc:date>2022-09-22T22:41:36Z</dc:date>
    </item>
  </channel>
</rss>

