<?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 Is this behaviour of get_ActiveDocument by design? in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/is-this-behaviour-of-get-activedocument-by-design/m-p/4326640#M129689</link>
    <description>&lt;P&gt;If I call this function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;CComPtr&amp;lt;Document&amp;gt; pDoc;&lt;BR /&gt;HRESULT hRes = pInvApp-&amp;gt;get_ActiveDocument(&amp;amp;pDoc);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I get an S_OK result even if no document is open.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does that mean that I should always check both the &lt;EM&gt;hRes&lt;/EM&gt; and the &lt;EM&gt;&amp;amp;p...&lt;/EM&gt; in all get_ calls which initialize a pointer?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jul 2013 09:55:27 GMT</pubDate>
    <dc:creator>oransen</dc:creator>
    <dc:date>2013-07-11T09:55:27Z</dc:date>
    <item>
      <title>Is this behaviour of get_ActiveDocument by design?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/is-this-behaviour-of-get-activedocument-by-design/m-p/4326640#M129689</link>
      <description>&lt;P&gt;If I call this function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;CComPtr&amp;lt;Document&amp;gt; pDoc;&lt;BR /&gt;HRESULT hRes = pInvApp-&amp;gt;get_ActiveDocument(&amp;amp;pDoc);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I get an S_OK result even if no document is open.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does that mean that I should always check both the &lt;EM&gt;hRes&lt;/EM&gt; and the &lt;EM&gt;&amp;amp;p...&lt;/EM&gt; in all get_ calls which initialize a pointer?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2013 09:55:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/is-this-behaviour-of-get-activedocument-by-design/m-p/4326640#M129689</guid>
      <dc:creator>oransen</dc:creator>
      <dc:date>2013-07-11T09:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: Is this behaviour of get_ActiveDocument by design?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/is-this-behaviour-of-get-activedocument-by-design/m-p/4326936#M129690</link>
      <description>&lt;P&gt;&lt;SPAN&gt;get_ActiveDocument&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;will put&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;NULL&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;in pDoc if there is no document open. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Yes, you have to check that as well as hRes&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2013 13:32:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/is-this-behaviour-of-get-activedocument-by-design/m-p/4326936#M129690</guid>
      <dc:creator>jdkriek</dc:creator>
      <dc:date>2013-07-11T13:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Is this behaviour of get_ActiveDocument by design?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/is-this-behaviour-of-get-activedocument-by-design/m-p/4327885#M129691</link>
      <description>&lt;P&gt;And in general all the get_... fuctions which pass back a pointer I suppose?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2013 08:41:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/is-this-behaviour-of-get-activedocument-by-design/m-p/4327885#M129691</guid>
      <dc:creator>oransen</dc:creator>
      <dc:date>2013-07-12T08:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Is this behaviour of get_ActiveDocument by design?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/is-this-behaviour-of-get-activedocument-by-design/m-p/4328025#M129692</link>
      <description>&lt;P&gt;That's correct&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2013 12:24:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/is-this-behaviour-of-get-activedocument-by-design/m-p/4328025#M129692</guid>
      <dc:creator>jdkriek</dc:creator>
      <dc:date>2013-07-12T12:24:24Z</dc:date>
    </item>
    <item>
      <title>Re: Is this behaviour of get_ActiveDocument by design?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/is-this-behaviour-of-get-activedocument-by-design/m-p/4328110#M129693</link>
      <description>&lt;P&gt;I just found another! Just want to be sure...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// Get the sketch in the part by name...
CComPtr&amp;lt;PlanarSketch&amp;gt; pSketch = NULL;
hRes = pPartCompDef-&amp;gt;Sketches-&amp;gt;get_Item(CComVariant(L"MAIN_TUBE_CIRCS"), &amp;amp;pSketch);
if (FAILED(hRes) || (pSketch == NULL)) { 
    ReportCOMError (hRes,L"AddSolid but could not 'get' sketch\n");
    return (false) ;
}&lt;/PRE&gt;&lt;P&gt;Even in this case I should check pSketch as well as hRes?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does FAILED(hRes) mean &lt;STRONG&gt;"I've understood your question..."&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;And does pSketch == NULL mean &lt;STRONG&gt;"..but I cannot answer it"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;?&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>Fri, 12 Jul 2013 13:48:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/is-this-behaviour-of-get-activedocument-by-design/m-p/4328110#M129693</guid>
      <dc:creator>oransen</dc:creator>
      <dc:date>2013-07-12T13:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: Is this behaviour of get_ActiveDocument by design?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/is-this-behaviour-of-get-activedocument-by-design/m-p/4340868#M129694</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;&lt;A id="link_1400f476f24" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1206331" target="_self"&gt;oransen&lt;/A&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;FAILED(hRes) returnes the status of calling the method. If all goes without any failure/error, it returns Succeed. But even if succeeds, there may be possiblity the object the method returns may be NULL due to specific reasons.This depends on how the inner logic of the method is written. So it is a safer way to check the object as well. Normally, if you are confident in the method, it is OK to check status only.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Hope this makes sense.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2013 06:10:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/is-this-behaviour-of-get-activedocument-by-design/m-p/4340868#M129694</guid>
      <dc:creator>xiaodong_liang</dc:creator>
      <dc:date>2013-07-24T06:10:18Z</dc:date>
    </item>
  </channel>
</rss>

