<?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: Addin-Command with Alias in specific work environment in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13124572#M173550</link>
    <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4757919"&gt;@bindlmi&lt;/a&gt;.&amp;nbsp; I don't know why I did not think of this earlier, but I think I see an even better way to enable the functionality that you are looking for.&amp;nbsp; The clue is right in the image you posted, but I could not read the words in your image because they are in a language that I can not read.&amp;nbsp; But basically that one column is named "Category" (in English), and I think I know how to 'control' that.&lt;/P&gt;
&lt;P&gt;Under the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-CommandManager" target="_blank" rel="noopener"&gt;CommandManager&lt;/A&gt; (ThisApplication.CommandManager), is the collection for not only the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=CommandManager_ControlDefinitions" target="_blank" rel="noopener"&gt;ControlDefinitions&lt;/A&gt;, but also for the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=CommandManager_CommandCategories" target="_blank" rel="noopener"&gt;CommandCategories&lt;/A&gt;.&amp;nbsp; We can use that &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-CommandCategories" target="_blank" rel="noopener"&gt;CommandCategories&lt;/A&gt; collection object to see all existing categories, or add some custom ones.&amp;nbsp; Then the individual&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-CommandCategory" target="_blank" rel="noopener"&gt;CommandCategory&lt;/A&gt;&amp;nbsp;object lets us either see all the commands that are in that category, or &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=CommandCategory_Add" target="_blank" rel="noopener"&gt;Add&lt;/A&gt; / &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=CommandCategory_Remove" target="_blank" rel="noopener"&gt;Remove&lt;/A&gt; a command from it.&amp;nbsp; It says we can not delete any of the built-in categories, and it says we can not add a 'built-in' command into a custom category, so not entirely as flexible as we may want.&amp;nbsp; It might be possible to use this route to set / change the category of a command, that way, if the two commands are in different categories, then maybe it will allow the same shortcut.&amp;nbsp; Just a thought at this point though.&lt;/P&gt;</description>
    <pubDate>Fri, 01 Nov 2024 14:54:31 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2024-11-01T14:54:31Z</dc:date>
    <item>
      <title>Addin-Command with Alias in specific work environment</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13122137#M173492</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have created my own command via an addin. Now I would like to assign the shortcut “B” to this command. The problem is that “B” is already used by another command (HoleFeature) (see 1. in the picture).&lt;/P&gt;&lt;P&gt;I know that it is possible to assign the same shortcut to multiple commands, as long as they are in different environments (see 2. in the picture).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bindlmi_0-1730379313666.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1428102i92860E036563A32E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bindlmi_0-1730379313666.png" alt="bindlmi_0-1730379313666.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I make my command a “drawing only” command?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 12:56:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13122137#M173492</guid>
      <dc:creator>bindlmi</dc:creator>
      <dc:date>2024-10-31T12:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Addin-Command with Alias in specific work environment</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13122261#M173496</link>
      <description>&lt;P&gt;You can use the UserInteraceEvents.OnEnviromentChange event to enable/disable your commands based on the current environment. A disabled command doesn't trigger the extra up/arrow arrow key selection for duplicate shortcuts. There's the added benefit of preventing the "Repeat &amp;lt;last command&amp;gt;" context menu commands from executing when they shouldn't.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 13:45:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13122261#M173496</guid>
      <dc:creator>jjstr8</dc:creator>
      <dc:date>2024-10-31T13:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Addin-Command with Alias in specific work environment</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13122371#M173502</link>
      <description>&lt;P&gt;Okay, I think I can attach my code to the event. But what exactly is the “command”? Is that the ButtonDefinition?&lt;BR /&gt;If you have a small example of how I can access the environment and disable the command, it would help me a lot. Otherwise, I'll do my own research next week.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 14:31:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13122371#M173502</guid>
      <dc:creator>bindlmi</dc:creator>
      <dc:date>2024-10-31T14:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Addin-Command with Alias in specific work environment</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13124403#M173542</link>
      <description>&lt;P&gt;It's under InventorApplication.CommandManager.ControlDefinitions["command name"].Enabled. InventorApplication is your field/property for the Application object. The command name is the internal name you used in AddButtonDefinition. Here's a C# example. This goes in your ApplicationAddinServer implementation.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;private void UserInterfaceEvents_OnEnvironmentChange(Inventor.Environment environment, EnvironmentStateEnum environmentState, EventTimingEnum beforeOrAfter, NameValueMap context, out HandlingCodeEnum handlingCode)
{

    if ((environmentState == EnvironmentStateEnum.kActivateEnvironmentState || environmentState == EnvironmentStateEnum.kResumeEnvironmentState) &amp;amp;&amp;amp; beforeOrAfter == EventTimingEnum.kAfter)
    {
        switch (environment.InternalName)
        {
            case "AMxAssemblyEnvironment":
            case "AMxWeldmentEnvironment":
                InventorApplication.CommandManager.ControlDefinitions["myAddin:myAssemblyCmdBtn"].Enabled = true;
                InventorApplication.CommandManager.ControlDefinitions["myAddin:myPartCmdBtn"].Enabled = false;
                break;

            case "PMxPartEnvironment":
            case "MBxSheetMetalEnvironment":
                InventorApplication.CommandManager.ControlDefinitions["myAddin:myAssemblyCmdBtn"].Enabled = false;
                InventorApplication.CommandManager.ControlDefinitions["myAddin:myPartCmdBtn"].Enabled = true;
                break;
            case "FWxMainFrameEnvironment":
            case "DLxDrawingEnvironment":
            case "DXxPresentationEnvironment":
            default:
                InventorApplication.CommandManager.ControlDefinitions["myAddin:myAssemblyCmdBtn"].Enabled = false;
                InventorApplication.CommandManager.ControlDefinitions["myAddin:myPartCmdBtn"].Enabled = false;
        } 
    }
    handlingCode = HandlingCodeEnum.kEventNotHandled;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2024 13:34:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13124403#M173542</guid>
      <dc:creator>jjstr8</dc:creator>
      <dc:date>2024-11-01T13:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: Addin-Command with Alias in specific work environment</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13124466#M173545</link>
      <description>&lt;P&gt;Hi guys.&amp;nbsp; Not sure that customize dialog would recognize that you have some code to enable or disable specific commands when specific&amp;nbsp; environment changes happen.&amp;nbsp; It seems to me like the following would be the proper way to handle that.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=Environment_DisabledCommandList" target="_blank" rel="noopener"&gt;Environment.DisabledCommandList&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-DisabledCommandList" target="_blank" rel="noopener"&gt;DisabledCommandList&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=DisabledCommandList_Add" target="_blank" rel="noopener"&gt;DisabledCommandList.Add&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=DisabledCommandList_Remove" target="_blank" rel="noopener"&gt;DisabledCommandList.Remove&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That way the Environment itself knows which ones are not relevant while it is active.&lt;/P&gt;
&lt;P&gt;There is also the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=Environment_DisabledCommandTypes" target="_blank" rel="noopener"&gt;Environment.DisabledCommandTypes&lt;/A&gt;&amp;nbsp;for broader terms.&lt;/P&gt;
&lt;P&gt;And you can control the RadialMarkingMenus in that Environment (&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=Environment_RadialMarkingMenus" target="_blank" rel="noopener"&gt;Environment.RadialMarkingMenus&lt;/A&gt;), if you want to make sure a specific command is not in any of them by default, but that should not have anything to do with shortcuts in the customize dialog.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2024 14:06:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13124466#M173545</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-11-01T14:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: Addin-Command with Alias in specific work environment</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13124531#M173548</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;- That certainly looks like the cleaner way to do it. I wasn't aware that it existed. I'll have to revisit the way I've been doing it. I may have some commands that conditions other than just the environment.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2024 14:32:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13124531#M173548</guid>
      <dc:creator>jjstr8</dc:creator>
      <dc:date>2024-11-01T14:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: Addin-Command with Alias in specific work environment</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13124572#M173550</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4757919"&gt;@bindlmi&lt;/a&gt;.&amp;nbsp; I don't know why I did not think of this earlier, but I think I see an even better way to enable the functionality that you are looking for.&amp;nbsp; The clue is right in the image you posted, but I could not read the words in your image because they are in a language that I can not read.&amp;nbsp; But basically that one column is named "Category" (in English), and I think I know how to 'control' that.&lt;/P&gt;
&lt;P&gt;Under the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-CommandManager" target="_blank" rel="noopener"&gt;CommandManager&lt;/A&gt; (ThisApplication.CommandManager), is the collection for not only the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=CommandManager_ControlDefinitions" target="_blank" rel="noopener"&gt;ControlDefinitions&lt;/A&gt;, but also for the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=CommandManager_CommandCategories" target="_blank" rel="noopener"&gt;CommandCategories&lt;/A&gt;.&amp;nbsp; We can use that &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-CommandCategories" target="_blank" rel="noopener"&gt;CommandCategories&lt;/A&gt; collection object to see all existing categories, or add some custom ones.&amp;nbsp; Then the individual&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-CommandCategory" target="_blank" rel="noopener"&gt;CommandCategory&lt;/A&gt;&amp;nbsp;object lets us either see all the commands that are in that category, or &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=CommandCategory_Add" target="_blank" rel="noopener"&gt;Add&lt;/A&gt; / &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=CommandCategory_Remove" target="_blank" rel="noopener"&gt;Remove&lt;/A&gt; a command from it.&amp;nbsp; It says we can not delete any of the built-in categories, and it says we can not add a 'built-in' command into a custom category, so not entirely as flexible as we may want.&amp;nbsp; It might be possible to use this route to set / change the category of a command, that way, if the two commands are in different categories, then maybe it will allow the same shortcut.&amp;nbsp; Just a thought at this point though.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2024 14:54:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13124572#M173550</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-11-01T14:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Addin-Command with Alias in specific work environment</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13130528#M173645</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;that would be the perfect solution, but I'm afraid it won't work.&lt;BR /&gt;I was able to add my command to the CommandCategorey.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;            // Create my Drawing-Button
            ButtonDefinition oBtnDef = oCommandManager.ControlDefinitions.AddButtonDefinition(...);
            // Get CommandCategory for Drawings
            CommandCategory cmdCategoryDrawing = oCommandManager.CommandCategories["ucxdrawingmanagercategory"];
            // Add my button to this category
            cmdCategoryDrawing.Add(oBtnDef);&lt;/LI-CODE&gt;&lt;P&gt;Here you can see the result:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bindlmi_0-1730793022983.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1429729iED579E550D2C3897/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bindlmi_0-1730793022983.png" alt="bindlmi_0-1730793022983.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I had assumed that once my command is in there, Inventor will take care of the “active” commands on its own, but my command is still active in other environments as well &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@F462EEC827775DA92CB03B7FC147D389/emoticons/1f61e.png" alt=":disappointed_face:" title=":disappointed_face:" /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bindlmi_1-1730793081361.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1429730i9ED040925FDB235D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bindlmi_1-1730793081361.png" alt="bindlmi_1-1730793081361.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Should I have done more?&lt;BR /&gt;I will test the other suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 07:52:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13130528#M173645</guid>
      <dc:creator>bindlmi</dc:creator>
      <dc:date>2024-11-05T07:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Addin-Command with Alias in specific work environment</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13130671#M173647</link>
      <description>&lt;P&gt;Regarding the proposal with the DisabledCommandList:&lt;BR /&gt;I looked at the example on the help page and you have to disable the command in all unwanted environments.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bindlmi_0-1730797430382.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1429766iD083336107C168A5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bindlmi_0-1730797430382.png" alt="bindlmi_0-1730797430382.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So I tried my best:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;            foreach (Inventor.Environment oTempEnv in Plugin.m_inventorApplication.Environments)
            {
                if (oTempEnv.InternalName != "DLxDrawingEnvironment")
                {
                    try
                    {

                        oTempEnv.DisabledCommandList.Add((ControlDefinition)Btn.ButtonDefinition);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show($"Evn: {oTempEnv.DisplayName}\n\n{ex}");
                    }
                }
            }&lt;/LI-CODE&gt;&lt;P&gt;But I get the following error message:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bindlmi_1-1730797537621.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1429770iBB83F159213E4C2F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bindlmi_1-1730797537621.png" alt="bindlmi_1-1730797537621.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I am not sure if the problem is that I am converting my ButtonDefinition to a ControlDefinition.&lt;/P&gt;&lt;P&gt;I think that the DisabledCommandList does not exist... in the VBA editor it looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bindlmi_2-1730797697268.png" style="width: 682px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1429773iB57CBDA634131116/image-dimensions/682x203?v=v2" width="682" height="203" role="button" title="bindlmi_2-1730797697268.png" alt="bindlmi_2-1730797697268.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 09:09:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13130671#M173647</guid>
      <dc:creator>bindlmi</dc:creator>
      <dc:date>2024-11-05T09:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: Addin-Command with Alias in specific work environment</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13130814#M173650</link>
      <description>&lt;P&gt;The proposal with the UserInterfaceEvents:&lt;BR /&gt;This works very well, even if it doesn't look as elegant as the other suggestions.&lt;BR /&gt;Here is the code for the UserInterfaceEvent:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    public class Plugin : ApplicationAddInServer
    {
        public static Inventor.Application m_inventorApplication;
        public static ControlDefinitions m_ConDefs;
        private UserInterfaceEvents m_UserInterfaceEvents;

        public void Activate(ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            try
            {
                // define globals
                m_inventorApplication = addInSiteObject.Application;
                m_ConDefs = m_inventorApplication.CommandManager.ControlDefinitions;
                m_UserInterfaceEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents;

                // attach to UserInterfaceEvent
                m_UserInterfaceEvents.OnEnvironmentChange += UserInterfaceEvents_OnEnvironmentChange;

            }
            catch
            {
            }

        }

        private void UserInterfaceEvents_OnEnvironmentChange(Inventor.Environment environment, EnvironmentStateEnum environmentState, EventTimingEnum beforeOrAfter, NameValueMap context, out HandlingCodeEnum handlingCode)
        {
            handlingCode = HandlingCodeEnum.kEventNotHandled;

            try
            {
                if ((environmentState == EnvironmentStateEnum.kActivateEnvironmentState || environmentState == EnvironmentStateEnum.kResumeEnvironmentState) &amp;amp;&amp;amp; beforeOrAfter == EventTimingEnum.kAfter)
                {
                    switch (environment.InternalName)
                    {
                        // activate my commmand only in drawings
                        case "DLxDrawingEnvironment":
                            m_ConDefs["myDrawingButtonInternalName"].Enabled = true;
                            break;
                        default:
                            m_ConDefs["myDrawingButtonInternalName"].Enabled = false;
                            break;
                    }
                }
            }
            catch
            {
            }
        }

        public void Deactivate()
        {
            m_UserInterfaceEvents.OnEnvironmentChange -= UserInterfaceEvents_OnEnvironmentChange;
        }
	}&lt;/LI-CODE&gt;&lt;P&gt;Many thanks for your help. If you have any ideas about the other suggestions, I'd be happy to test them.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 10:18:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13130814#M173650</guid>
      <dc:creator>bindlmi</dc:creator>
      <dc:date>2024-11-05T10:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Addin-Command with Alias in specific work environment</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13131328#M173660</link>
      <description>&lt;P&gt;ButtonDefinition is not derived from ControlDefinition, so you can't cast to it. Get it by name in the ControlDefinitions collection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;oTempEnv.DisabledCommandList.Add(Plugin.m_inventorApplication.CommandManager.ControlDefinitions["myDrawingButtonInternalName"]);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 14:15:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13131328#M173660</guid>
      <dc:creator>jjstr8</dc:creator>
      <dc:date>2024-11-05T14:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Addin-Command with Alias in specific work environment</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13131350#M173661</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4757919"&gt;@bindlmi&lt;/a&gt;.&amp;nbsp; The 'category' idea was just a 'portion' of the overall process I had in mind, along with the disabled commands list idea.&amp;nbsp; But honestly add-ins and controlling the scope of an add-in's influence within Inventor are not really my area of expertise.&amp;nbsp; Judging by the image of the error message, and the line I highlighted below, it appears to be encountering a problem 'getting' the DisabledCommandList for some reason.&amp;nbsp; Since that property is ReadOnly, that means we can not set another list as its value directly, so the only way to 'add' or 'remove' commands from that list is to 'get' the existing list object first, then use that list to add or remove them, so encountering an error while just getting it does not seem logical.&amp;nbsp; You may need to enclose it in a Try...Catch...End Try statement.&amp;nbsp; Or, maybe we can only modify it while that environment is 'active', not sure.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="WCrihfield_0-1730815880770.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1429907i17986F126D6683AD/image-size/large?v=v2&amp;amp;px=999" role="button" title="WCrihfield_0-1730815880770.png" alt="WCrihfield_0-1730815880770.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Anyways, I'm glad you found something that seems to be working OK for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 14:23:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13131350#M173661</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-11-05T14:23:20Z</dc:date>
    </item>
    <item>
      <title>Betreff: Addin-Command with Alias in specific work environment</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13131375#M173662</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;yeah, this seems to be the problem. Even if I change my code as jjstr8 suggested, this line throws the exception:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bindlmi_0-1730816878019.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1429916iC43985E65111D533/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bindlmi_0-1730816878019.png" alt="bindlmi_0-1730816878019.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also had the same idea to make my own DisabeldCommandList, but I get the following error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bindlmi_1-1730817002582.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1429919iBA503921F17E4D38/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bindlmi_1-1730817002582.png" alt="bindlmi_1-1730817002582.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;in english: &lt;SPAN&gt;Cannot create an instance of the abstract class or interface 'interface'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(I'm not so good with interfaces and abstract classes)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 14:33:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13131375#M173662</guid>
      <dc:creator>bindlmi</dc:creator>
      <dc:date>2024-11-05T14:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: Addin-Command with Alias in specific work environment</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13131477#M173665</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4757919"&gt;@bindlmi&lt;/a&gt;: Use the collection from Plugin.m_inventorApplication.UserInterfaceManager.Environments in your foreach&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 15:03:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13131477#M173665</guid>
      <dc:creator>jjstr8</dc:creator>
      <dc:date>2024-11-05T15:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Addin-Command with Alias in specific work environment</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13132951#M173689</link>
      <description>&lt;P&gt;Awesome, that's it! &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@B4D44A73814D7FC0D950DEDFACB97081/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt; And it even works with the ButtonDefinition &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@7B4B80143EBEB4F250CEEC82342F6CA1/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;            // disable new button in all environments except drawings
            foreach (Inventor.Environment oTempEnv in Plugin.m_inventorApplication.UserInterfaceManager.Environments)
            {
                if (oTempEnv.InternalName != "DLxDrawingEnvironment")
                {
                    try
                    {
                        //ControlDefinition myDrawingCommand = Plugin.m_ConDefs[InternalName];
                        //oTempEnv.DisabledCommandList.Add(myDrawingCommand);
                        oTempEnv.DisabledCommandList.Add((ControlDefinition)Btn.ButtonDefinition);
                    }
                    catch
                    {
                    }
                }
            }&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 06 Nov 2024 06:02:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-command-with-alias-in-specific-work-environment/m-p/13132951#M173689</guid>
      <dc:creator>bindlmi</dc:creator>
      <dc:date>2024-11-06T06:02:59Z</dc:date>
    </item>
  </channel>
</rss>

