<?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: Algorithm - Does plane intersect solid? in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/algorithm-does-plane-intersect-solid/m-p/10788035#M131825</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10297025"&gt;@aelqabbany&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try this approach (this is the Ilogic version):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;Main&lt;/SPAN&gt;()
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPartDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartDocument&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveDocument&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oCompDef&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartComponentDefinition&lt;/SPAN&gt; = &lt;SPAN&gt;oPartDoc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;Solid1&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;SurfaceBody&lt;/SPAN&gt; = &lt;SPAN&gt;oCompDef&lt;/SPAN&gt;.&lt;SPAN&gt;SurfaceBodies&lt;/SPAN&gt;(1)
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;workPlane&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;WorkPlane&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;CommandManager&lt;/SPAN&gt;.&lt;SPAN&gt;Pick&lt;/SPAN&gt;(&lt;SPAN&gt;SelectionFilterEnum&lt;/SPAN&gt;.&lt;SPAN&gt;kAllPlanarEntities&lt;/SPAN&gt;, &lt;SPAN&gt;"Select Plane"&lt;/SPAN&gt;)
	
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;context&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;NameValueMap&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;TransientObjects&lt;/SPAN&gt;.&lt;SPAN&gt;CreateNameValueMap&lt;/SPAN&gt;
	&lt;SPAN&gt;context&lt;/SPAN&gt;.&lt;SPAN&gt;Add&lt;/SPAN&gt;(&lt;SPAN&gt;IntersectionFound&lt;/SPAN&gt;,&lt;SPAN&gt;true&lt;/SPAN&gt;)
	
    &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;contextValueForIntersection&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Double&lt;/SPAN&gt;
  	&lt;SPAN&gt;contextValueForIntersection&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;MeasureTools&lt;/SPAN&gt;.&lt;SPAN&gt;GetMinimumDistance&lt;/SPAN&gt;(&lt;SPAN&gt;Solid1&lt;/SPAN&gt;, &lt;SPAN&gt;workPlane&lt;/SPAN&gt;.&lt;SPAN&gt;Plane&lt;/SPAN&gt;, , , &lt;SPAN&gt;context&lt;/SPAN&gt;)
	
	&lt;SPAN&gt;If&lt;/SPAN&gt; (&lt;SPAN&gt;contextValueForIntersection&lt;/SPAN&gt; = 0) &lt;SPAN&gt;Then&lt;/SPAN&gt;
		&lt;SPAN&gt;MessageBox&lt;/SPAN&gt;.&lt;SPAN&gt;Show&lt;/SPAN&gt;(&lt;SPAN&gt;"Intersection is found"&lt;/SPAN&gt;)
	&lt;SPAN&gt;Else&lt;/SPAN&gt; 
		&lt;SPAN&gt;MessageBox&lt;/SPAN&gt;.&lt;SPAN&gt;Show&lt;/SPAN&gt;(&lt;SPAN&gt;"No intersection"&lt;/SPAN&gt;)
	&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;	
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Check out my Add-Ins&lt;/STRONG&gt;:&amp;nbsp;&lt;A href="https://apps.autodesk.com/INVNTOR/en/Detail/Index?id=713745016472190898&amp;amp;appLang=en&amp;amp;os=Win64" target="_blank" rel="noopener"&gt;Place Fasteners AddIn&lt;/A&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;A href="https://apps.autodesk.com/INVNTOR/en/Detail/Index?id=5454556850521421748&amp;amp;appLang=en&amp;amp;os=Win64" target="_blank" rel="noopener"&gt;Quick Section View AddIn&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@2A0F083D272D63CF5E4A44A10756DF5D/emoticons/1f600.png" alt=":grinning_face:" title=":grinning_face:" /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Nov 2021 12:48:37 GMT</pubDate>
    <dc:creator>artemglushchenko21</dc:creator>
    <dc:date>2021-11-29T12:48:37Z</dc:date>
    <item>
      <title>Algorithm - Does plane intersect solid?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/algorithm-does-plane-intersect-solid/m-p/10787222#M131814</link>
      <description>&lt;P&gt;I am trying to write an algorithm (subroutine) to determine if a plane intersects a solid. I have prepared the code below which measures the minimum distance between each solid face to the plane, and it works, but it is very slow, especially as parts get larger and more complex.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have an idea for a faster solution?&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Sub Main()
	Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
	Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
	Dim Solid1 As SurfaceBody = oCompDef.SurfaceBodies(1)
	Dim Plane As WorkPlane = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllPlanarEntities, "Select Plane")
	MessageBox.Show(PlaneIntersectSolid(Solid1,Plane),"Does Plane intersect solid 1?")
	
End Sub

Function PlaneIntersectSolid(Solid1 As SurfaceBody, Plane As WorkPlane) As Boolean
	For Each oFace As Face In Solid1.Faces
		If ThisApplication.MeasureTools.GetMinimumDistance(Plane, oFace) = 0 Then
			PlaneIntersectSolid = True
			Exit Function
		End If
	Next
	PlaneIntersectSolid = False
End Function&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 29 Nov 2021 01:56:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/algorithm-does-plane-intersect-solid/m-p/10787222#M131814</guid>
      <dc:creator>aelqabbany</dc:creator>
      <dc:date>2021-11-29T01:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Algorithm - Does plane intersect solid?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/algorithm-does-plane-intersect-solid/m-p/10787678#M131822</link>
      <description>&lt;P&gt;Can you provide some performance counters?&lt;/P&gt;&lt;P&gt;Faces count:&lt;/P&gt;&lt;P&gt;Vertices count:&lt;/P&gt;&lt;P&gt;Measured time:&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 08:51:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/algorithm-does-plane-intersect-solid/m-p/10787678#M131822</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2021-11-29T08:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Algorithm - Does plane intersect solid?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/algorithm-does-plane-intersect-solid/m-p/10788035#M131825</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10297025"&gt;@aelqabbany&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try this approach (this is the Ilogic version):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;Main&lt;/SPAN&gt;()
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPartDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartDocument&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveDocument&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oCompDef&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartComponentDefinition&lt;/SPAN&gt; = &lt;SPAN&gt;oPartDoc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;Solid1&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;SurfaceBody&lt;/SPAN&gt; = &lt;SPAN&gt;oCompDef&lt;/SPAN&gt;.&lt;SPAN&gt;SurfaceBodies&lt;/SPAN&gt;(1)
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;workPlane&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;WorkPlane&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;CommandManager&lt;/SPAN&gt;.&lt;SPAN&gt;Pick&lt;/SPAN&gt;(&lt;SPAN&gt;SelectionFilterEnum&lt;/SPAN&gt;.&lt;SPAN&gt;kAllPlanarEntities&lt;/SPAN&gt;, &lt;SPAN&gt;"Select Plane"&lt;/SPAN&gt;)
	
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;context&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;NameValueMap&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;TransientObjects&lt;/SPAN&gt;.&lt;SPAN&gt;CreateNameValueMap&lt;/SPAN&gt;
	&lt;SPAN&gt;context&lt;/SPAN&gt;.&lt;SPAN&gt;Add&lt;/SPAN&gt;(&lt;SPAN&gt;IntersectionFound&lt;/SPAN&gt;,&lt;SPAN&gt;true&lt;/SPAN&gt;)
	
    &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;contextValueForIntersection&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Double&lt;/SPAN&gt;
  	&lt;SPAN&gt;contextValueForIntersection&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;MeasureTools&lt;/SPAN&gt;.&lt;SPAN&gt;GetMinimumDistance&lt;/SPAN&gt;(&lt;SPAN&gt;Solid1&lt;/SPAN&gt;, &lt;SPAN&gt;workPlane&lt;/SPAN&gt;.&lt;SPAN&gt;Plane&lt;/SPAN&gt;, , , &lt;SPAN&gt;context&lt;/SPAN&gt;)
	
	&lt;SPAN&gt;If&lt;/SPAN&gt; (&lt;SPAN&gt;contextValueForIntersection&lt;/SPAN&gt; = 0) &lt;SPAN&gt;Then&lt;/SPAN&gt;
		&lt;SPAN&gt;MessageBox&lt;/SPAN&gt;.&lt;SPAN&gt;Show&lt;/SPAN&gt;(&lt;SPAN&gt;"Intersection is found"&lt;/SPAN&gt;)
	&lt;SPAN&gt;Else&lt;/SPAN&gt; 
		&lt;SPAN&gt;MessageBox&lt;/SPAN&gt;.&lt;SPAN&gt;Show&lt;/SPAN&gt;(&lt;SPAN&gt;"No intersection"&lt;/SPAN&gt;)
	&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;	
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Check out my Add-Ins&lt;/STRONG&gt;:&amp;nbsp;&lt;A href="https://apps.autodesk.com/INVNTOR/en/Detail/Index?id=713745016472190898&amp;amp;appLang=en&amp;amp;os=Win64" target="_blank" rel="noopener"&gt;Place Fasteners AddIn&lt;/A&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;A href="https://apps.autodesk.com/INVNTOR/en/Detail/Index?id=5454556850521421748&amp;amp;appLang=en&amp;amp;os=Win64" target="_blank" rel="noopener"&gt;Quick Section View AddIn&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@2A0F083D272D63CF5E4A44A10756DF5D/emoticons/1f600.png" alt=":grinning_face:" title=":grinning_face:" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 12:48:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/algorithm-does-plane-intersect-solid/m-p/10788035#M131825</guid>
      <dc:creator>artemglushchenko21</dc:creator>
      <dc:date>2021-11-29T12:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Algorithm - Does plane intersect solid?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/algorithm-does-plane-intersect-solid/m-p/10788900#M131836</link>
      <description>&lt;P&gt;Wow, just wow.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ran my script and yours in a part with 319 faces.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My script took 3.97 seconds and yours took less than 0.01 seconds.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you explain to me how you used the&amp;nbsp;NameValueMap type to get the measurements so quickly? Did Inventor still have to take 319 distance measurements?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 18:44:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/algorithm-does-plane-intersect-solid/m-p/10788900#M131836</guid>
      <dc:creator>aelqabbany</dc:creator>
      <dc:date>2021-11-29T18:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: Algorithm - Does plane intersect solid?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/algorithm-does-plane-intersect-solid/m-p/10789005#M131838</link>
      <description>&lt;P&gt;I think some more optimal algorithms are used for measurements in this case (maybe not even actual distance measurments to the faces)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the NameValueMap is simple. You create an object and pass as an argument to MeasureTools.GetMinimumDistance method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please check Inventor Api for this method:&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-240D2F92-2701-4D9D-BCE7-02759538E2FC" target="_blank"&gt;https://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-240D2F92-2701-4D9D-BCE7-02759538E2FC&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a good article as well:&lt;/P&gt;&lt;P&gt;&lt;A href="https://adndevblog.typepad.com/manufacturing/2014/01/vector-of-minimum-distance.html" target="_blank"&gt;https://adndevblog.typepad.com/manufacturing/2014/01/vector-of-minimum-distance.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 19:47:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/algorithm-does-plane-intersect-solid/m-p/10789005#M131838</guid>
      <dc:creator>artemglushchenko21</dc:creator>
      <dc:date>2021-11-29T19:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: Algorithm - Does plane intersect solid?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/algorithm-does-plane-intersect-solid/m-p/10789015#M131839</link>
      <description>Thank you very much!</description>
      <pubDate>Mon, 29 Nov 2021 19:50:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/algorithm-does-plane-intersect-solid/m-p/10789015#M131839</guid>
      <dc:creator>aelqabbany</dc:creator>
      <dc:date>2021-11-29T19:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Algorithm - Does plane intersect solid?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/algorithm-does-plane-intersect-solid/m-p/10789048#M131840</link>
      <description>&lt;P&gt;I find it very interesting that this code is working without throwing any errors, because according to the &lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-240D2F92-2701-4D9D-BCE7-02759538E2FC" target="_blank" rel="noopener"&gt;online help page for that method&lt;/A&gt;, a SurfaceBody object is not listed as a valid type of input entity.&amp;nbsp; It certainly is nice that it is working here though.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 20:03:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/algorithm-does-plane-intersect-solid/m-p/10789048#M131840</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2021-11-29T20:03:00Z</dc:date>
    </item>
  </channel>
</rss>

