Calling Navisworks Commands using Command ID

Calling Navisworks Commands using Command ID

alexisDVJML
Collaborator Collaborator
700 Views
6 Replies
Message 1 of 7

Calling Navisworks Commands using Command ID

alexisDVJML
Collaborator
Collaborator

Seems similar question has been asked in the past, without reply:
https://forums.autodesk.com/t5/navisworks-api/call-navis-commands-from-our-add-in-ribbon/m-p/8014920

 

However it would be very useful, so asking again 😉 with a little bit extra details.

 

RoamerCommands.xml file contains a list of Roamer commands, exemple:

<Command ID="RoamerGUI_EDIT_RESET_COLOUR" />


So the question is simple,  how to run a CanExecute and an Execute using a Command ID string?
I really try hard to find before reverting to asking, hoping we can get help on this.

Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
0 Likes
Accepted solutions (1)
701 Views
6 Replies
Replies (6)
Message 2 of 7

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @alexisDVJML ,

 

Please take a look at the below link
https://www.houseofbim.com/posts/naviworks-net-executecommand-method/ 

Here is the sample code that worked for me

private void MyCode(Document doc)
        {
            string commandId = "RoamerGUI_EDIT_RESET_COLOUR";
            string commandId2 = "RoamerGUI_EDIT_OVERRIDE_TRANSPARENCY";
            Autodesk.Navisworks.Api.Interop.LcUCIPExecutionContext av = Autodesk.Navisworks.Api.Interop.LcUCIPExecutionContext.eTOOLBAR;
            try
            {               
                Autodesk.Navisworks.Api.Interop.LcRmFrameworkInterface.ExecuteCommand(commandId2, av);
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("This tool does not appear to be supported");
            }
        }

Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 7

alexisDVJML
Collaborator
Collaborator

@naveen.kumar.t  Excellent, Thanks!

Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
0 Likes
Message 4 of 7

alexisDVJML
Collaborator
Collaborator

@naveen.kumar.t Tested, working, thanks!

Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
0 Likes
Message 5 of 7

BIM-ZhagnXuetao
Explorer
Explorer

Hi, there is a problem I got. I want to post the parameter to the commond. However I have no idea how to post.

Below is my code.

 

string commandId2 = "RoamerGUI_OM_MEASURE_PT_TO_PT";
Autodesk.Navisworks.Api.Interop.LcUCIPExecutionContext av = Autodesk.Navisworks.Api.Interop.LcUCIPExecutionContext.eTOOLBAR;
try
{
    Autodesk.Navisworks.Api.Interop.LcRmFrameworkInterface.ExecuteCommand(commandId2, av);
}
catch
{
    System.Windows.Forms.MessageBox.Show("This tool does not appear to be supported");
}
0 Likes
Message 6 of 7

BIM-ZhagnXuetao
Explorer
Explorer
string commandId2 = "RoamerGUI_OM_MEASURE_PT_TO_PT";
Autodesk.Navisworks.Api.Interop.LcUCIPExecutionContext av = Autodesk.Navisworks.Api.Interop.LcUCIPExecutionContext.eTOOLBAR;
try
{
    Autodesk.Navisworks.Api.Interop.LcRmFrameworkInterface.ExecuteCommand(commandId2, av);
}
catch
{
    System.Windows.Forms.MessageBox.Show("This tool does not appear to be supported");
}
0 Likes
Message 7 of 7

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @BIM-ZhagnXuetao ,

Please follow the steps outlined in this link

public class MainClass : AddInPlugin
    {
        public override int Execute(params string[] parameters)
        {
            //Place the code here
            return 0;
        }
    }

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes