<?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: Fatal Error when using Solid3d.GetSection in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/fatal-error-when-using-solid3d-getsection/m-p/7327216#M29965</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1868845"&gt;@zputman&lt;/a&gt; wrote:&lt;BR /&gt;... Forgot to mention: I am using AutoCAD 2016 ...&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This bug was fixed in AutoCAD 2017.&amp;nbsp; With AutoCAD 2017 in this situation exception &lt;STRONG&gt;eNoIntersections&lt;/STRONG&gt; is thrown:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="0_1517d2_61cce49b_orig.png" style="width: 446px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/393970i29662C1E742C829A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0_1517d2_61cce49b_orig.png" alt="0_1517d2_61cce49b_orig.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In AutoCAD 2016 as workaround you can use &lt;STRONG&gt;Section.GenerateSectionGeometry&lt;/STRONG&gt;. Example: &lt;A href="http://through-the-interface.typepad.com/through_the_interface/2008/05/sectioning-an-a.html&amp;nbsp;" target="_blank"&gt;http://through-the-interface.typepad.com/through_the_interface/2008/05/sectioning-an-a.html&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Aug 2017 21:14:30 GMT</pubDate>
    <dc:creator>Alexander.Rivilis</dc:creator>
    <dc:date>2017-08-24T21:14:30Z</dc:date>
    <item>
      <title>Fatal Error when using Solid3d.GetSection</title>
      <link>https://forums.autodesk.com/t5/net-forum/fatal-error-when-using-solid3d-getsection/m-p/7324443#M29961</link>
      <description>&lt;P&gt;When using the Solid3d.GetSection method with a plane that doesn't intersect the solid or only intersects the solid at a point or line, I get a Region object that throws System.AccessViolationException on most of its properties. &amp;nbsp;The documentation says I should get null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone else getting this? &amp;nbsp;Is there a way of testing the Region object that doesn't throw the exception (which needs extra measures to catch because it is a Corrupted State Exception)? &amp;nbsp;The Region.IsNull property also throws the exception, so no go there...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Meanwhile, I have worked around this by offsetting the plane slightly into the solid and checking the bounds of the solid before trying the method. &amp;nbsp;These countermeasures break however if the solid has gaps, is small, doesn't line up with the coordinate system, etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Forgot to mention: I am using AutoCAD 2016&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 04:30:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/fatal-error-when-using-solid3d-getsection/m-p/7324443#M29961</guid>
      <dc:creator>zputman</dc:creator>
      <dc:date>2017-08-24T04:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: Fatal Error when using Solid3d.GetSection</title>
      <link>https://forums.autodesk.com/t5/net-forum/fatal-error-when-using-solid3d-getsection/m-p/7324664#M29962</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1868845"&gt;@zputman&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;When using the Solid3d.GetSection method with a plane that doesn't intersect the solid or only intersects the solid at a point or line, I get a Region object that throws System.AccessViolationException on most of its properties. &amp;nbsp;The documentation says I should get null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone else getting this? &amp;nbsp;Is there a way of testing the Region object that doesn't throw the exception (which needs extra measures to catch because it is a Corrupted State Exception)? &amp;nbsp;The Region.IsNull property also throws the exception, so no go there...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Meanwhile, I have worked around this by offsetting the plane slightly into the solid and checking the bounds of the solid before trying the method. &amp;nbsp;These countermeasures break however if the solid has gaps, is small, doesn't line up with the coordinate system, etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Forgot to mention: I am using AutoCAD 2016&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;According to the native docs for &lt;A href="http://help.autodesk.com/view/OARX/2018/ENU/?guid=OREF-AcDb3dSolid__getSection_AcGePlane__AcDbRegion___const" target="_blank"&gt;AcDb3dSolid::getSection()&lt;/A&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;FONT color="#999999"&gt;If the solid has no ShapeManager object, or the plane doesn't intersect the solid, or the intersection is not a valid region (for example, it intersects at a point, along a bounding face of the solid, and so on), then sectionRegion will be set to NULL and Acad::eOk will be returned.&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to what I see in the disassembly for the Solid3d.GetSection() method, the only thing it does is check the errorstatus returned by AcDb3dSolid::getSection(), and doesn't bother checking to see if the pointer to the AcDbRegion is NULL, and just returns a managed wrapper with a null pointer to an unmanaged object.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know if we can call that a bug or not, but it seems that it could have been handled better (e.g, throw an exception if an AcDbRegion wasn't created).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case, this should tell you what you need to know:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Region region = solid3d.GetSection(....)

if(region.UnmanagedObject != IntPtr.Zero)
{
   // Got a valid region.
}
else
{
    // something went wrong.
}&lt;/PRE&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, 24 Aug 2017 06:34:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/fatal-error-when-using-solid3d-getsection/m-p/7324664#M29962</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-08-24T06:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Fatal Error when using Solid3d.GetSection</title>
      <link>https://forums.autodesk.com/t5/net-forum/fatal-error-when-using-solid3d-getsection/m-p/7324966#M29963</link>
      <description>&lt;P&gt;I had the same problem with Solid3d.Slice() which is similar to Solid3d.Section() in a recent project. I ended up to call the SLICE command with Editor.Command() this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ed.Command(
   "_SLICE", 
  solid3dId, 
  "", 
  "_S", // Surface
 surfaceId,
  "_B" // (keep Both solids). We cannot select the side, so we keep both
);&lt;/PRE&gt;
&lt;P&gt;You can do the same with the SECTION command and the 3 points option. To get the region which will be may be created, you can put an handler on the Database.ObjectAppended event before calling the command and remove it after.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem with the Solid3d method is that if the slice/section fails, AutoCAD &amp;nbsp;crashes soon after. But may be it was because I've not think to the clever way of testing if the object is valid proposed by &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4476837"&gt;@ActivistInvestor&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 08:41:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/fatal-error-when-using-solid3d-getsection/m-p/7324966#M29963</guid>
      <dc:creator>FRFR1426</dc:creator>
      <dc:date>2017-08-24T08:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: Fatal Error when using Solid3d.GetSection</title>
      <link>https://forums.autodesk.com/t5/net-forum/fatal-error-when-using-solid3d-getsection/m-p/7326769#M29964</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4591287"&gt;@Activist_Investor&lt;/a&gt; wrote:&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1868845"&gt;@zputman&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;When using the Solid3d.GetSection method with a plane that doesn't intersect the solid or only intersects the solid at a point or line, I get a Region object that throws System.AccessViolationException on most of its properties. &amp;nbsp;The documentation says I should get null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone else getting this? &amp;nbsp;Is there a way of testing the Region object that doesn't throw the exception (which needs extra measures to catch because it is a Corrupted State Exception)? &amp;nbsp;The Region.IsNull property also throws the exception, so no go there...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Meanwhile, I have worked around this by offsetting the plane slightly into the solid and checking the bounds of the solid before trying the method. &amp;nbsp;These countermeasures break however if the solid has gaps, is small, doesn't line up with the coordinate system, etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Forgot to mention: I am using AutoCAD 2016&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;According to the native docs for &lt;A href="http://help.autodesk.com/view/OARX/2018/ENU/?guid=OREF-AcDb3dSolid__getSection_AcGePlane__AcDbRegion___const" target="_blank"&gt;AcDb3dSolid::getSection()&lt;/A&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;FONT color="#999999"&gt;If the solid has no ShapeManager object, or the plane doesn't intersect the solid, or the intersection is not a valid region (for example, it intersects at a point, along a bounding face of the solid, and so on), then sectionRegion will be set to NULL and Acad::eOk will be returned.&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to what I see in the disassembly for the Solid3d.GetSection() method, the only thing it does is check the errorstatus returned by AcDb3dSolid::getSection(), and doesn't bother checking to see if the pointer to the AcDbRegion is NULL, and just returns a managed wrapper with a null pointer to an unmanaged object.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know if we can call that a bug or not, but it seems that it could have been handled better (e.g, throw an exception if an AcDbRegion wasn't created).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case, this should tell you what you need to know:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Region region = solid3d.GetSection(....)

if(region.UnmanagedObject != IntPtr.Zero)
{
   // Got a valid region.
}
else
{
    // something went wrong.
}&lt;/PRE&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;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I tried this and the Region.UnmanagedObject is not zero for me and it still has the AccessViolationExceptions and it crashes AutoCAD.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 18:34:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/fatal-error-when-using-solid3d-getsection/m-p/7326769#M29964</guid>
      <dc:creator>zputman</dc:creator>
      <dc:date>2017-08-24T18:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Fatal Error when using Solid3d.GetSection</title>
      <link>https://forums.autodesk.com/t5/net-forum/fatal-error-when-using-solid3d-getsection/m-p/7327216#M29965</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1868845"&gt;@zputman&lt;/a&gt; wrote:&lt;BR /&gt;... Forgot to mention: I am using AutoCAD 2016 ...&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This bug was fixed in AutoCAD 2017.&amp;nbsp; With AutoCAD 2017 in this situation exception &lt;STRONG&gt;eNoIntersections&lt;/STRONG&gt; is thrown:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="0_1517d2_61cce49b_orig.png" style="width: 446px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/393970i29662C1E742C829A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0_1517d2_61cce49b_orig.png" alt="0_1517d2_61cce49b_orig.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In AutoCAD 2016 as workaround you can use &lt;STRONG&gt;Section.GenerateSectionGeometry&lt;/STRONG&gt;. Example: &lt;A href="http://through-the-interface.typepad.com/through_the_interface/2008/05/sectioning-an-a.html&amp;nbsp;" target="_blank"&gt;http://through-the-interface.typepad.com/through_the_interface/2008/05/sectioning-an-a.html&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 21:14:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/fatal-error-when-using-solid3d-getsection/m-p/7327216#M29965</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2017-08-24T21:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: Fatal Error when using Solid3d.GetSection</title>
      <link>https://forums.autodesk.com/t5/net-forum/fatal-error-when-using-solid3d-getsection/m-p/7327412#M29966</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1868845"&gt;@zputman&lt;/a&gt; wrote:&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I tried this and the Region.UnmanagedObject is not zero for me and it still has the AccessViolationExceptions and it crashes AutoCAD.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;That's a different bug altogether. &amp;nbsp;According to the code I saw, and the simple test I did, GetRegions() tried to create a managed wrapper for a Region, and that failed (the managed runtime doesn't allow it), so that isn't the problem. In your case, it is returning something, but it's not usable&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 22:45:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/fatal-error-when-using-solid3d-getsection/m-p/7327412#M29966</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-08-24T22:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: Fatal Error when using Solid3d.GetSection</title>
      <link>https://forums.autodesk.com/t5/net-forum/fatal-error-when-using-solid3d-getsection/m-p/7327439#M29967</link>
      <description>&lt;P&gt;The section I was looking at was probably touching the solid at a point, so maybe that is why it returned an unusable region instead of a wrapper around a null pointer. &amp;nbsp;It looks like my best options are to upgrade AutoCAD or to use the Section class instead. &amp;nbsp;For now, I will keep with my countermeasures since they will probably work every time for my current use case and revisit this code when we upgrade so it works more generally.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks everyone for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 23:00:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/fatal-error-when-using-solid3d-getsection/m-p/7327439#M29967</guid>
      <dc:creator>zputman</dc:creator>
      <dc:date>2017-08-24T23:00:53Z</dc:date>
    </item>
  </channel>
</rss>

