<?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: EventHandlers Glitching Inventor - Cant Edit Sketches / Open Components in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/eventhandlers-glitching-inventor-cant-edit-sketches-open/m-p/13112894#M173359</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12191678"&gt;@C_Haines_ENG&lt;/a&gt;.&amp;nbsp; When we create event handlers, we often need to design in more than one way to remove / eliminate that event handler.&amp;nbsp; In your case, the only way out is for your variable 'oFrame' to get a value assigned to it.&amp;nbsp; Well, if you run that rule, but then exit out of selection mode with the Escape key (or equivalent), without ever selecting anything, then that may never happen, which may cause the event handler to continue running in the background until you restart Inventor.&amp;nbsp; In theory, your action of pressing the escape key should terminate the 'interaction' mode, but that may have not released the reference to those resources.&amp;nbsp; In your code, that release would have only happened after 'oFrame' had been assigned a value.&amp;nbsp; You may want to at lease 'handle' the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=InteractionEvents_OnTerminate" target="_blank" rel="noopener"&gt;InteractionEvents.OnTerminate&lt;/A&gt;&amp;nbsp;Event, in addition to the OnSelect Event.&amp;nbsp; That way, when you terminate interaction mode, the event handler for that action will have a chance to stop things, and negate object references.&amp;nbsp; I also generally recommend using the [&lt;A href="https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/addhandler-statement" target="_blank" rel="noopener"&gt;AddHandler&lt;/A&gt; Object.Event, AddressOf Object_Event] way of specifying event handlers, instead of using the keywords ['&lt;A href="https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/modifiers/withevents" target="_blank" rel="noopener"&gt;WithEvents&lt;/A&gt;' &amp;amp; '&lt;A href="https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/handles-clause" target="_blank" rel="noopener"&gt;Handles&lt;/A&gt;'] to do that, when first getting into creating event handlers, because this gives you an added way to 'remove' them, using the [&lt;A href="https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/removehandler-statement" target="_blank" rel="noopener"&gt;RemoveHandler&lt;/A&gt; Object.Event, AddressOf Object_Event] phrase.&amp;nbsp; Often, when you create an event handler with an iLogic rule, if you did not include extra code in that original rule that creates it, then you will not be able to stop it again, until you quit and/or restart Inventor.&amp;nbsp; You can not simply edit the rule that created &amp;amp; launched it, to change its behavior, while it is running in the background, because that code is being held in Inventor's memory now, so you usually need to restart Inventor before editing that rule.&amp;nbsp; And hopefully that rule has not already been ran again automatically by the time you can get to it for editing it.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Oct 2024 13:39:10 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2024-10-28T13:39:10Z</dc:date>
    <item>
      <title>EventHandlers Glitching Inventor - Cant Edit Sketches / Open Components</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/eventhandlers-glitching-inventor-cant-edit-sketches-open/m-p/13112789#M173351</link>
      <description>&lt;P&gt;Good Morning everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have actually had this issue for quite a while, but Interaction events / Event Handles are causing my Inventor to stop functioning properly. See my code below:&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;oAsm&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;AssemblyDocument&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oSelect&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;New&lt;/SPAN&gt; &lt;SPAN&gt;oSelectClass&lt;/SPAN&gt;
	
	&lt;SPAN&gt;oSelect&lt;/SPAN&gt;.&lt;SPAN&gt;Pick&lt;/SPAN&gt;(&lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;)
	
	&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oSelect&lt;/SPAN&gt;.&lt;SPAN&gt;oFrame&lt;/SPAN&gt; &lt;SPAN&gt;Is&lt;/SPAN&gt; &lt;SPAN&gt;Nothing&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt; &lt;SPAN&gt;Exit&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;

	&lt;SPAN&gt;Logger&lt;/SPAN&gt;.&lt;SPAN&gt;Info&lt;/SPAN&gt;(&lt;SPAN&gt;oSelect&lt;/SPAN&gt;.&lt;SPAN&gt;oFrame&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt;)
	&lt;SPAN&gt;Logger&lt;/SPAN&gt;.&lt;SPAN&gt;Info&lt;/SPAN&gt;(&lt;SPAN&gt;oSelect&lt;/SPAN&gt;.&lt;SPAN&gt;oModelPoint&lt;/SPAN&gt;.&lt;SPAN&gt;X&lt;/SPAN&gt;)
	
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;

&lt;SPAN&gt;Class&lt;/SPAN&gt; &lt;SPAN&gt;oSelectClass&lt;/SPAN&gt;

	&lt;SPAN&gt;Private&lt;/SPAN&gt; &lt;SPAN&gt;WithEvents&lt;/SPAN&gt; &lt;SPAN&gt;oInteractEvents&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;InteractionEvents&lt;/SPAN&gt;
	&lt;SPAN&gt;Private&lt;/SPAN&gt; &lt;SPAN&gt;WithEvents&lt;/SPAN&gt; &lt;SPAN&gt;oSelectEvents&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;SelectEvents&lt;/SPAN&gt;

	&lt;SPAN&gt;Public&lt;/SPAN&gt; &lt;SPAN&gt;oFrame&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ComponentOccurrence&lt;/SPAN&gt;
	&lt;SPAN&gt;Public&lt;/SPAN&gt; &lt;SPAN&gt;oModelPoint&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Point&lt;/SPAN&gt;

	&lt;SPAN&gt;Public&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;Pick&lt;/SPAN&gt;(&lt;SPAN&gt;oApp&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN&gt;Application&lt;/SPAN&gt;)

		&lt;SPAN&gt;oInteractEvents&lt;/SPAN&gt; = &lt;SPAN&gt;oApp&lt;/SPAN&gt;.&lt;SPAN&gt;CommandManager&lt;/SPAN&gt;.&lt;SPAN&gt;CreateInteractionEvents&lt;/SPAN&gt;
		&lt;SPAN&gt;oInteractEvents&lt;/SPAN&gt;.&lt;SPAN&gt;StatusBarText&lt;/SPAN&gt; = &lt;SPAN&gt;"SELECT FRAME, ESC TO EXIT"&lt;/SPAN&gt;

		&lt;SPAN&gt;oSelectEvents&lt;/SPAN&gt; = &lt;SPAN&gt;oInteractEvents&lt;/SPAN&gt;.&lt;SPAN&gt;SelectEvents&lt;/SPAN&gt;
		&lt;SPAN&gt;oSelectEvents&lt;/SPAN&gt;.&lt;SPAN&gt;AddSelectionFilter&lt;/SPAN&gt;(&lt;SPAN&gt;kAssemblyLeafOccurrenceFilter&lt;/SPAN&gt;)

		&lt;SPAN&gt;oInteractEvents&lt;/SPAN&gt;.&lt;SPAN&gt;Start&lt;/SPAN&gt;() : &lt;SPAN&gt;AppActivate&lt;/SPAN&gt;(&lt;SPAN&gt;oApp&lt;/SPAN&gt;.&lt;SPAN&gt;Caption&lt;/SPAN&gt;)

		&lt;SPAN&gt;Do&lt;/SPAN&gt; &lt;SPAN&gt;While &lt;/SPAN&gt;&lt;SPAN&gt;oFrame&lt;/SPAN&gt; &lt;SPAN&gt;Is&lt;/SPAN&gt; &lt;SPAN&gt;Nothing&lt;/SPAN&gt;
			&lt;SPAN&gt;oApp&lt;/SPAN&gt;.&lt;SPAN&gt;UserInterfaceManager&lt;/SPAN&gt;.&lt;SPAN&gt;DoEvents&lt;/SPAN&gt;
		&lt;SPAN&gt;Loop&lt;/SPAN&gt;
		
		&lt;SPAN&gt;oInteractEvents&lt;/SPAN&gt;.&lt;SPAN&gt;Stop&lt;/SPAN&gt; : &lt;SPAN&gt;oApp&lt;/SPAN&gt;.&lt;SPAN&gt;CommandManager&lt;/SPAN&gt;.&lt;SPAN&gt;StopActiveCommand&lt;/SPAN&gt;

		&lt;SPAN&gt;oSelectEvents&lt;/SPAN&gt; = &lt;SPAN&gt;Nothing &lt;/SPAN&gt;: &lt;SPAN&gt;oInteractEvents&lt;/SPAN&gt; = &lt;SPAN&gt;Nothing&lt;/SPAN&gt;

	&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;

	&lt;SPAN&gt;Private&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;oSelectEvents_OnSelect&lt;/SPAN&gt;(&lt;SPAN&gt;oFrames&lt;/SPAN&gt;, &lt;SPAN&gt;oDevice&lt;/SPAN&gt;, &lt;SPAN&gt;oPoint&lt;/SPAN&gt;, &lt;SPAN&gt;oView2D&lt;/SPAN&gt;, &lt;SPAN&gt;oView&lt;/SPAN&gt;) &lt;SPAN&gt;Handles&lt;/SPAN&gt; &lt;SPAN&gt;oSelectEvents&lt;/SPAN&gt;.&lt;SPAN&gt;OnSelect&lt;/SPAN&gt;
		&lt;SPAN&gt;oFrame&lt;/SPAN&gt; = &lt;SPAN&gt;oFrames&lt;/SPAN&gt;(1)
		&lt;SPAN&gt;oModelPoint&lt;/SPAN&gt; = &lt;SPAN&gt;oPoint&lt;/SPAN&gt;
	&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;

&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Class&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I suspect it has something to do with Interaction events not actually "stopping" when using InteractionEvents.Stop. It causes other interaction events such as editing a sketch to not allow you to change anything, and having the "save sketch" feature greyed out, or being unable to select a component occurrence to open it individually.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone knows anything about this and could fix my nightmare, that would be appreciated.&amp;nbsp; While "&lt;SPAN&gt;oApp&lt;/SPAN&gt;.&lt;SPAN&gt;CommandManager&lt;/SPAN&gt;.&lt;SPAN&gt;StopActiveCommand" does exit you out, it seems to have more consequences than I thought.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To test this issue, simply run the command a few times, maybe click on items in an assembly. Then try to edit a sketch and see how it doesn't work anymore! This could also have something to do with loops but I doubt it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2024 12:56:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/eventhandlers-glitching-inventor-cant-edit-sketches-open/m-p/13112789#M173351</guid>
      <dc:creator>C_Haines_ENG</dc:creator>
      <dc:date>2024-10-28T12:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: EventHandlers Glitching Inventor - Cant Edit Sketches / Open Components</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/eventhandlers-glitching-inventor-cant-edit-sketches-open/m-p/13112880#M173357</link>
      <description>&lt;P&gt;I'm not able to duplicate your issue. I ran the rule four or five times, selecting a component. I was able to edit an assembly sketch. What version are you on? I'm back on 2019.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2024 13:34:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/eventhandlers-glitching-inventor-cant-edit-sketches-open/m-p/13112880#M173357</guid>
      <dc:creator>jjstr8</dc:creator>
      <dc:date>2024-10-28T13:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: EventHandlers Glitching Inventor - Cant Edit Sketches / Open Components</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/eventhandlers-glitching-inventor-cant-edit-sketches-open/m-p/13112889#M173358</link>
      <description>&lt;P&gt;I'm also in 2019 and am having trouble replicating it as well, it seems almost random when it becomes an issue. Im 90% sure its due to a "do loop" section that I am not exiting correctly because its waiting for oFrame to be Nothing, which it never is.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2024 13:39:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/eventhandlers-glitching-inventor-cant-edit-sketches-open/m-p/13112889#M173358</guid>
      <dc:creator>C_Haines_ENG</dc:creator>
      <dc:date>2024-10-28T13:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: EventHandlers Glitching Inventor - Cant Edit Sketches / Open Components</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/eventhandlers-glitching-inventor-cant-edit-sketches-open/m-p/13112894#M173359</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12191678"&gt;@C_Haines_ENG&lt;/a&gt;.&amp;nbsp; When we create event handlers, we often need to design in more than one way to remove / eliminate that event handler.&amp;nbsp; In your case, the only way out is for your variable 'oFrame' to get a value assigned to it.&amp;nbsp; Well, if you run that rule, but then exit out of selection mode with the Escape key (or equivalent), without ever selecting anything, then that may never happen, which may cause the event handler to continue running in the background until you restart Inventor.&amp;nbsp; In theory, your action of pressing the escape key should terminate the 'interaction' mode, but that may have not released the reference to those resources.&amp;nbsp; In your code, that release would have only happened after 'oFrame' had been assigned a value.&amp;nbsp; You may want to at lease 'handle' the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=InteractionEvents_OnTerminate" target="_blank" rel="noopener"&gt;InteractionEvents.OnTerminate&lt;/A&gt;&amp;nbsp;Event, in addition to the OnSelect Event.&amp;nbsp; That way, when you terminate interaction mode, the event handler for that action will have a chance to stop things, and negate object references.&amp;nbsp; I also generally recommend using the [&lt;A href="https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/addhandler-statement" target="_blank" rel="noopener"&gt;AddHandler&lt;/A&gt; Object.Event, AddressOf Object_Event] way of specifying event handlers, instead of using the keywords ['&lt;A href="https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/modifiers/withevents" target="_blank" rel="noopener"&gt;WithEvents&lt;/A&gt;' &amp;amp; '&lt;A href="https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/handles-clause" target="_blank" rel="noopener"&gt;Handles&lt;/A&gt;'] to do that, when first getting into creating event handlers, because this gives you an added way to 'remove' them, using the [&lt;A href="https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/removehandler-statement" target="_blank" rel="noopener"&gt;RemoveHandler&lt;/A&gt; Object.Event, AddressOf Object_Event] phrase.&amp;nbsp; Often, when you create an event handler with an iLogic rule, if you did not include extra code in that original rule that creates it, then you will not be able to stop it again, until you quit and/or restart Inventor.&amp;nbsp; You can not simply edit the rule that created &amp;amp; launched it, to change its behavior, while it is running in the background, because that code is being held in Inventor's memory now, so you usually need to restart Inventor before editing that rule.&amp;nbsp; And hopefully that rule has not already been ran again automatically by the time you can get to it for editing it.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2024 13:39:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/eventhandlers-glitching-inventor-cant-edit-sketches-open/m-p/13112894#M173359</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-10-28T13:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: EventHandlers Glitching Inventor - Cant Edit Sketches / Open Components</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/eventhandlers-glitching-inventor-cant-edit-sketches-open/m-p/13112935#M173361</link>
      <description>&lt;P&gt;&amp;nbsp;OnTerminate has been added in, and now the script reliably exits and stops the interaction event. I don't know if this will fix the issue I'm having yet, so I will monitor it and if it doesn't happen again ill come back to mark your response as the answer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2024 13:58:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/eventhandlers-glitching-inventor-cant-edit-sketches-open/m-p/13112935#M173361</guid>
      <dc:creator>C_Haines_ENG</dc:creator>
      <dc:date>2024-10-28T13:58:22Z</dc:date>
    </item>
  </channel>
</rss>

