Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Add a ribbon button with click mode pressed behavior in ribbon panel ( Ribbon item )

3 REPLIES 3
Reply
Message 1 of 4
abdechafi.neji
294 Views, 3 Replies

How to Add a ribbon button with click mode pressed behavior in ribbon panel ( Ribbon item )

abdechafi.neji
Contributor
Contributor

I'm using the inventor APi and I would like to add a custom ribbon button (ribbon item ) to my ribbon Panel , once the user clicks on the button , it should be pressed , and when click on another button it should be pressed and the first button should be released.

 

How can I achieve this?

 

 

 

        private void CreateButtonRibbonPanel(RibbonPanel ribbonPanel, List<CommadProperties> commandButtonPropList)
        {
            if (ribbonPanel != null && commandButtonPropList.Count > 0)
            {
                for (int i = 0; i < commandButtonPropList.Count; i++)
                {
                    BtnIndex++;
                    commandButtonPropList[i].SetProperties();
                    CreateButtonToSamePanel(ribbonPanel.CommandControls, commandButtonPropList[i].CommandImage, commandButtonPropList[i].CommandName, commandButtonPropList[i].CommandClientId);
                }
            }
        }




        private void CreateButtonToSamePanel(CommandControls CmdCtrlsForOnePanel, string ImageName, string DisplayName, string ClientID)
        {
            if (m_CommandMgr == null || m_CtrlDefs == null || CmdCtrlsForOnePanel == null)
                return;

            stdole.IPictureDisp standardIconIPictureDisp = null;

            if (ImageName.CompareTo("") != 0)
            {
                string Rooticon = Path.Combine(ResourcesDir, ImageName);

                Bitmap standardbitmap = new Bitmap(Rooticon);

                standardIconIPictureDisp = PictureDispConverter.ToIPictureDisp(standardbitmap);
            }
            else
            {
                standardIconIPictureDisp = null;
            }

            object vtAddInId = ClientID;
            ButtonDef = null;

            string InternalName = DisplayName + BtnIndex.ToString();

            ButtonDef = m_CtrlDefs.AddButtonDefinition(DisplayName, InternalName, CommandTypesEnum.kQueryOnlyCmdType, vtAddInId, DisplayName, DisplayName,
                standardIconIPictureDisp, standardIconIPictureDisp, ButtonDisplayEnum.kDisplayTextInLearningMode);
            
            if (ButtonDef != null)
            {
                _ButtonDefEvents = new ButtonDefEvents(this, BtnIndex);
               CommandControl CmdCtrl = CmdCtrlsForOnePanel.AddButton(ButtonDef, true, true, "", false);
                
                if (CmdCtrl != null)
                {
                }
            }
        }

 

 

0 Likes

How to Add a ribbon button with click mode pressed behavior in ribbon panel ( Ribbon item )

I'm using the inventor APi and I would like to add a custom ribbon button (ribbon item ) to my ribbon Panel , once the user clicks on the button , it should be pressed , and when click on another button it should be pressed and the first button should be released.

 

How can I achieve this?

 

 

 

        private void CreateButtonRibbonPanel(RibbonPanel ribbonPanel, List<CommadProperties> commandButtonPropList)
        {
            if (ribbonPanel != null && commandButtonPropList.Count > 0)
            {
                for (int i = 0; i < commandButtonPropList.Count; i++)
                {
                    BtnIndex++;
                    commandButtonPropList[i].SetProperties();
                    CreateButtonToSamePanel(ribbonPanel.CommandControls, commandButtonPropList[i].CommandImage, commandButtonPropList[i].CommandName, commandButtonPropList[i].CommandClientId);
                }
            }
        }




        private void CreateButtonToSamePanel(CommandControls CmdCtrlsForOnePanel, string ImageName, string DisplayName, string ClientID)
        {
            if (m_CommandMgr == null || m_CtrlDefs == null || CmdCtrlsForOnePanel == null)
                return;

            stdole.IPictureDisp standardIconIPictureDisp = null;

            if (ImageName.CompareTo("") != 0)
            {
                string Rooticon = Path.Combine(ResourcesDir, ImageName);

                Bitmap standardbitmap = new Bitmap(Rooticon);

                standardIconIPictureDisp = PictureDispConverter.ToIPictureDisp(standardbitmap);
            }
            else
            {
                standardIconIPictureDisp = null;
            }

            object vtAddInId = ClientID;
            ButtonDef = null;

            string InternalName = DisplayName + BtnIndex.ToString();

            ButtonDef = m_CtrlDefs.AddButtonDefinition(DisplayName, InternalName, CommandTypesEnum.kQueryOnlyCmdType, vtAddInId, DisplayName, DisplayName,
                standardIconIPictureDisp, standardIconIPictureDisp, ButtonDisplayEnum.kDisplayTextInLearningMode);
            
            if (ButtonDef != null)
            {
                _ButtonDefEvents = new ButtonDefEvents(this, BtnIndex);
               CommandControl CmdCtrl = CmdCtrlsForOnePanel.AddButton(ButtonDef, true, true, "", false);
                
                if (CmdCtrl != null)
                {
                }
            }
        }

 

 

Labels (2)
3 REPLIES 3
Message 2 of 4

CattabianiI
Collaborator
Collaborator
0 Likes

Message 3 of 4
CattabianiI
in reply to: CattabianiI

CattabianiI
Collaborator
Collaborator

You should manage the property in the buttonDefinition.OnExecute event. With a global variable to store the previous button to unpressed.

If you do not have a OnExecute handler you could try to set the Pressed property in the UserInputEvents.OnActivateCommand event.

0 Likes

You should manage the property in the buttonDefinition.OnExecute event. With a global variable to store the previous button to unpressed.

If you do not have a OnExecute handler you could try to set the Pressed property in the UserInputEvents.OnActivateCommand event.

Message 4 of 4

abdechafi.neji
Contributor
Contributor

That's what I did after adding other codes with the using of ButtonDefs OnExecute event, but I'm just search for another solution that is integrated with the Inventor API , what I'm talking about is something like this :

https://stackoverflow.com/questions/1846647/wpf-ribbon-change-main-content-when-ribbontab-is-selecte...

 

I mean that ribbon buttons will be ribbon items , and it will be have the same behavior of items , Datagrid row ...

 

 

0 Likes

That's what I did after adding other codes with the using of ButtonDefs OnExecute event, but I'm just search for another solution that is integrated with the Inventor API , what I'm talking about is something like this :

https://stackoverflow.com/questions/1846647/wpf-ribbon-change-main-content-when-ribbontab-is-selecte...

 

I mean that ribbon buttons will be ribbon items , and it will be have the same behavior of items , Datagrid row ...

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report