<?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 Betreff: Wrong ModelPosition with SelectEvents.OnSelect with a Boundary Patch in front of it? in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10560570#M46739</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp; Ok, thanks anyway &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Aug 2021 11:26:18 GMT</pubDate>
    <dc:creator>Jo_Perturbable</dc:creator>
    <dc:date>2021-08-20T11:26:18Z</dc:date>
    <item>
      <title>Wrong ModelPosition with SelectEvents.OnSelect with a Boundary Patch in front of it?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10552473#M46734</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how do I make the ModelPosition of &lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-FDEFEC63-5ADB-4F9F-A19E-5D30C4BD5361" target="_blank" rel="noopener"&gt;InteractionEvents.SelectEvents.OnSelect&lt;/A&gt; to be on the clicked ComponentOccurrence, if there is a Boundary Patch in front of the ComponentOccurrence?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use the &lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-FDEFEC63-5ADB-4F9F-A19E-5D30C4BD5361" target="_blank" rel="noopener"&gt;InteractionEvents.SelectEvents.OnSelect&lt;/A&gt; to select a ComponentOccurrence and get the ModelPosition of the mouse-click on the ComponentOccurrence (SelectionFilterEnum.kAssemblyOccurrenceFilter). The ModelPosition is the correct mouse-click position on the ComponentOccurrence as long as there is nothing in front of it. But if there is a Boundary Patch in front of the ComponentOccurrence, the ModelPosition seems to be the base point of the Boundary Patch.&lt;/P&gt;&lt;P&gt;Am I missing some kind of setting to get the ModelPosition on the ComponentOccurrence?&lt;BR /&gt;(I will provide example code tomorrow.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Autodesk Inventor Professional 2022.1 Build 234 64-Bit Edition&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 16:32:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10552473#M46734</guid>
      <dc:creator>Jo_Perturbable</dc:creator>
      <dc:date>2021-08-17T16:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong ModelPosition with SelectEvents.OnSelect with a Boundary Patch in front of it?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10552549#M46735</link>
      <description>&lt;P&gt;Very interesting situation &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8397728"&gt;@Jo_Perturbable&lt;/a&gt;.&amp;nbsp; Just thinking here how you might be able to test this further...I know it may not seem necessary, since you say you are using a selection filter, but are you checking the Count property of the returned ObjectsEnumerator, and are you checking the Type of object(s) within it, in your code?&amp;nbsp; Since it says right in the documentation that this ModelPosition is from 'projecting' the click point, we don't really know how this may be getting processed in the background (the way Autodesk programmed it).&amp;nbsp; This situation may not be avoidable.&amp;nbsp; This may be one that only someone from Autodesk may know the real answer to.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 16:47:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10552549#M46735</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2021-08-17T16:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong ModelPosition with SelectEvents.OnSelect with a Boundary Patch in front of it?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10555419#M46736</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt; for your interest.&lt;BR /&gt;The Count property is 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried to narrow down the problem: I have a ComponentOccurrence with a BoundaryPatch and another ComponentOccurrence with an Extrusion behind the BoundaryPatch. The first ComponentOccurrence is ignored in my PreSelect, so that only the second one is highlighted and the OnSelect is only called for the second one. It's all in C#. I've tried to reproduce this in VB, but the ModelPosition is correct. Anyway, the iam and the ipt are attached.&lt;/P&gt;&lt;P&gt;I will provide some C# tomorrow.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 15:57:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10555419#M46736</guid>
      <dc:creator>Jo_Perturbable</dc:creator>
      <dc:date>2021-08-18T15:57:49Z</dc:date>
    </item>
    <item>
      <title>Betreff: Wrong ModelPosition with SelectEvents.OnSelect with a Boundary Patch in front of it?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10558000#M46737</link>
      <description>&lt;P&gt;I created and attached a C# AddIn, that shows the wrong ModelPosition in the StatusBar.&lt;BR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;Am I missing something or could it be a bug in Inventor?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Excerpt from DrawSlotButton.cs in my C# AddIn:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;override protected void ButtonDefinition_OnExecute(NameValueMap context)
		{
			try
			{
				_InteractionEvents = _App.CommandManager.CreateInteractionEvents();
				_InteractionEvents.InteractionDisabled = false;
				_InteractionEvents.StatusBarText = "Select something";

				_SelectEvents = _InteractionEvents.SelectEvents;
				_SelectEvents.AddSelectionFilter(SelectionFilterEnum.kAssemblyOccurrenceFilter);


				_SelectEvents.OnPreSelect += _SelectEvents_OnPreSelect;

				_SelectEvents.OnSelect += _SelectEvents_OnSelect;

				_InteractionEvents.Start();
			}
			catch (Exception e)
			{
				MessageBox.Show(e.ToString());
			}
		}

		private void _SelectEvents_OnSelect(ObjectsEnumerator JustSelectedEntities, SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View)
		{
			_InteractionEvents.StatusBarText = $"OnSelect {nameof(ModelPosition)} {ModelPosition.X} {ModelPosition.Y} {ModelPosition.Z} " +
				$" &amp;lt;- versus -&amp;gt; {nameof(_ModelPositionPreSelect)} {_ModelPositionPreSelect.X} {_ModelPositionPreSelect.Y} {_ModelPositionPreSelect.Z}";
		}

		private void _SelectEvents_OnPreSelect(ref object PreSelectEntity, out bool DoHighlight, ref ObjectCollection MorePreSelectEntities, SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View)
		{
			if (PreSelectEntity is ComponentOccurrence occ &amp;amp;&amp;amp; occ.Name.Equals("ModelPosition of OnSelect 02:1"))
			{
				DoHighlight = true;
				MorePreSelectEntities = _CommandManager.Parent.TransientObjects.CreateObjectCollection();
				MorePreSelectEntities.Add(PreSelectEntity);

				_ModelPositionPreSelect = ModelPosition;

				//_InteractionEvents.StatusBarText = $"OnPreSelect ModelPosition {ModelPosition.X} {ModelPosition.Y} {ModelPosition.Z} ";
			}
			else
				DoHighlight = false;
		}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;How to reproduce&lt;/STRONG&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Either copy the attached AddIn to %AppData%\Autodesk\ApplicationPlugins or compile the AddIn yourself with the attached Visual Studio solution (based on the sample SimpleAddInCS by Autodesk).&lt;/LI&gt;&lt;LI&gt;Download and open the iam and the ipt of my previous post.&lt;/LI&gt;&lt;LI&gt;Click on the block on a position where the BoundaryPatch is in front of the block. This results in a ModelPosition (printed to StatusBar) that could be the insertion point of the ipt with the block. Whereas the ModelPosition of the PreSelect seems to be correct.&lt;BR /&gt;Following screenshot for reference:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ModelPosition of OnSelect 01.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/954799iC4E595D13A509BC9/image-size/large?v=v2&amp;amp;px=999" role="button" title="ModelPosition of OnSelect 01.png" alt="ModelPosition of OnSelect 01.png" /&gt;&lt;/span&gt;&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Thu, 19 Aug 2021 13:34:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10558000#M46737</guid>
      <dc:creator>Jo_Perturbable</dc:creator>
      <dc:date>2021-08-19T13:34:37Z</dc:date>
    </item>
    <item>
      <title>Betreff: Wrong ModelPosition with SelectEvents.OnSelect with a Boundary Patch in front of it?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10558408#M46738</link>
      <description>&lt;P&gt;Sorry &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8397728"&gt;@Jo_Perturbable&lt;/a&gt;,&amp;nbsp;but I'm not very good with C# right now, and I can't really test your Add-in stuff either.&amp;nbsp; Where I work, there is a 'corporate' policy that no employees (at any level) can have 'administrative rights' on their own computers, so creating Inventor Add-ins hasn't been an option for me.&amp;nbsp; If the C# is pretty basic, I can sometimes manage to convert it to vb.net, so that I can better follow/understand it.&amp;nbsp; Hopefully some of the other brilliant members here on the forum can help you out here.&amp;nbsp; Good luck.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 15:32:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10558408#M46738</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2021-08-19T15:32:21Z</dc:date>
    </item>
    <item>
      <title>Betreff: Wrong ModelPosition with SelectEvents.OnSelect with a Boundary Patch in front of it?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10560570#M46739</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp; Ok, thanks anyway &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 11:26:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10560570#M46739</guid>
      <dc:creator>Jo_Perturbable</dc:creator>
      <dc:date>2021-08-20T11:26:18Z</dc:date>
    </item>
    <item>
      <title>Betreff: Wrong ModelPosition with SelectEvents.OnSelect with a Boundary Patch in front of it?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10584231#M46740</link>
      <description>&lt;P&gt;Both values (&lt;STRONG&gt;Select&lt;/STRONG&gt; and &lt;STRONG&gt;PreSelect&lt;/STRONG&gt;) in the picture you provided seem to be on the bar (extruded part):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="OnSelect1.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/958844iDCBBE942CFFEB7DC/image-size/large?v=v2&amp;amp;px=999" role="button" title="OnSelect1.png" alt="OnSelect1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Any point on the occurrence of the boundary patch would have a &lt;STRONG&gt;Z&lt;/STRONG&gt; with some kind of numerical representation of&lt;STRONG&gt; 0&lt;/STRONG&gt; (inc -1.1xxxE-13)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="OnSelect2.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/958845i895B25FB2C133887/image-size/large?v=v2&amp;amp;px=999" role="button" title="OnSelect2.png" alt="OnSelect2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The &lt;STRONG&gt;ModelPosition&lt;/STRONG&gt; value of &lt;STRONG&gt;OnPreSelect&lt;/STRONG&gt; provides the position of the mouse when it first hits the object, whereas the value in&amp;nbsp;&lt;STRONG&gt;OnSelect&amp;nbsp;&lt;/STRONG&gt;is when the left mouse button got clicked - that's why they can be different.&lt;/P&gt;
&lt;P&gt;Attached is the assembly including a &lt;STRONG&gt;VBA&lt;/STRONG&gt; project with a function named "&lt;STRONG&gt;TestSelection&lt;/STRONG&gt;" that lets you and others test without an add-in.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 10:31:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10584231#M46740</guid>
      <dc:creator>adam.nagy</dc:creator>
      <dc:date>2021-08-30T10:31:00Z</dc:date>
    </item>
    <item>
      <title>Betreff: Wrong ModelPosition with SelectEvents.OnSelect with a Boundary Patch in front of it?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10587100#M46741</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/339467"&gt;@adam.nagy&lt;/a&gt;&amp;nbsp; Thanks for your response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please take a look at my &lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10558000#M127891" target="_blank" rel="noopener"&gt;C#-Addin of above comment&lt;/A&gt;?&lt;/P&gt;&lt;P&gt;You are correct, that the ModelPosition can't be on the BoundaryPatch (would be Z 0), but it seems to be the &lt;STRONG&gt;Center Point of the bar&lt;/STRONG&gt;, if the bar is clicked where the BoundaryPatch is in front of it. Note, that I only set DoHighlight to true in OnPreSelect, if the ComponentOccurrence is the one with the bar ("ModelPosition of OnSelect 02:1"). The VBA Editor has correct values for the ModelPosition (see attached zip), but the ModelPosition in the C#-Addin doesn't.&lt;/P&gt;&lt;P&gt;Screenshot of the ModelPosition of the C#-Addin and of the measurement of the Center Point of the bar:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ModelPosition of OnSelect 04.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/959308i8BD4CCDC32A9D6AD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ModelPosition of OnSelect 04.png" alt="ModelPosition of OnSelect 04.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Screenshot of the important part of the C#-Addin with the ModelPositions shown in Debug &lt;EM&gt;Watch 1&lt;/EM&gt;:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ModelPosition of OnSelect 05.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/959305i968CE3F33178C7CF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ModelPosition of OnSelect 05.png" alt="ModelPosition of OnSelect 05.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 10:56:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10587100#M46741</guid>
      <dc:creator>Jo_Perturbable</dc:creator>
      <dc:date>2021-08-31T10:56:09Z</dc:date>
    </item>
    <item>
      <title>Betreff: Wrong ModelPosition with SelectEvents.OnSelect with a Boundary Patch in front of it?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10587314#M46742</link>
      <description>&lt;P&gt;You don't need this - that seems to be causing the problem:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;MorePreSelectEntities = _CommandManager.Parent.TransientObjects.CreateObjectCollection();
MorePreSelectEntities.Add(PreSelectEntity);&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Selection1.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/959336i4713DE82F25F3F8C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Selection1.png" alt="Selection1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Not sure if it's a problem for you, but in this case, the &lt;STRONG&gt;ModelPosition&lt;/STRONG&gt; in &lt;STRONG&gt;OnSelect&lt;/STRONG&gt; will be the same as in &lt;STRONG&gt;OnPreSelect&lt;/STRONG&gt; if the mouse button is clicked in the area where the bar is behind the boundary patch.&lt;/P&gt;
&lt;P&gt;If instead of driving the value of &lt;STRONG&gt;DoHighlight&lt;/STRONG&gt; in &lt;STRONG&gt;OnPreSelect&lt;/STRONG&gt;, you restrict the selection to a given occurrence using&amp;nbsp;&lt;STRONG&gt;RestrictSelectionToOccurrence&lt;/STRONG&gt;, that seems to have the best result.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Selection2.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/959340i3784CACF4C682B3F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Selection2.png" alt="Selection2.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 12:37:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10587314#M46742</guid>
      <dc:creator>adam.nagy</dc:creator>
      <dc:date>2021-08-31T12:37:10Z</dc:date>
    </item>
    <item>
      <title>Betreff: Wrong ModelPosition with SelectEvents.OnSelect with a Boundary Patch in front of it?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10587391#M46743</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/339467"&gt;@adam.nagy&lt;/a&gt;&amp;nbsp; Thank you very much. This was the problem. It is good to know, that the ModelPosition in OnPreSelect depends on the&amp;nbsp;SelectEvents.RestrictSelectionToOccurrence.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 13:07:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/wrong-modelposition-with-selectevents-onselect-with-a-boundary/m-p/10587391#M46743</guid>
      <dc:creator>Jo_Perturbable</dc:creator>
      <dc:date>2021-08-31T13:07:48Z</dc:date>
    </item>
  </channel>
</rss>

