@MattWynn Thanks for your reply. The code you have shared works properly.
In our case don't want to just start the command but also to set parameter values in the command.
Refer to below code sample for function we have to pass NamedValues to a CommandDefinition. It results in opening a Nest Preparation dialog but checkbox 'Automatic (Sheet metal)' is not ticked on. We have verified execute API with input parameter for different dialogs and parameters but it doesn't set value to a parameter in dialog.
Can you please confirm this scenario? Also is there any other API to set NamedValues to CommandDefinition?
void executeCommandWithParameter()
{
try
{
Ptr<CommandDefinitions> commandDefinitions = m_UserInterface->commandDefinitions();
if (commandDefinitions != nullptr)
{
Ptr<CommandDefinition> commandDefinition = commandDefinitions->itemById("MSFNestAuthoringCmd");
if (commandDefinition != nullptr)
{
//Create input to be passed to CommandDefinition
Ptr<NamedValues> input = adsk::core::NamedValues::create();
Ptr<ValueInput> valueInput = adsk::core::ValueInput::createByBoolean(true);
input->add("infoIgnoreAutoSheetmetal", valueInput);
input->add("executeImmediately", adsk::core::ValueInput::createByString("true"));
// Execute the command definition.
bool bResult = commandDefinition->execute(input);
// Prevent this module from being terminated when the script returns, because we are waiting for event handlers to fire.
adsk::doEvents();
//To allow the script to continue to run so it can react the event, adsk.autoTerminate(false) will need to call at the end of run fuction.
//The argument False indicates Fusion that the script should continue to run in the background.
adsk::autoTerminate(false);
//Refresh active viewport
Ptr<Viewport> activeViewport = m_Application->activeViewport();
if (activeViewport == nullptr)
{
activeViewport->refresh();
}
}
}
}
catch (const std::exception& e)
{
m_UserInterface->messageBox(e.what(), "ExecuteCommandWithParameter", MessageBoxButtonTypes::OKButtonType, MessageBoxIconTypes::CriticalIconType);
}
}
@boopathi.sivakumar Any thoughts on this?