Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fusion 360 crashes after clicking Cancel button in NEST Preparation dialog

15 REPLIES 15
SOLVED
Reply
Message 1 of 16
vijay.shindeSLE5F
1184 Views, 15 Replies

Fusion 360 crashes after clicking Cancel button in NEST Preparation dialog

Steps to reproduce crash:

  1. Open any input file having CAM data
  2. Switch to Manufacturing workspace
  3. Fire TextCommand "Commands.Start MSFNestAuthoringCmd"
  4. Click Cancel button in dialog

Crash log :
      20211012T144155 E 22460 The recent operations of commands/requests are as following:
      Command end: MSFNestAuthoringCmd
      Command begin: CancelCommand
      processChangeRequest: first asset is FusionAssetName
      executeRequests: MSFNestAuthoringCmd

 

PFA screenshot and log file for more details.

 

@@spencer.hardcastle   

15 REPLIES 15
Message 2 of 16

Hi @vijay.shindeSLE5F 

I can able to replicate the problem I have reported this issue to the corresponding team. but i don't know what you are trying to do  with this workflow. If could explain what you want that would be helpful.

 


Boopathi Sivakumar
Senior Technology Consultant

Message 3 of 16

@boopathi.sivakumar  We want to set specific values to some of the inputs in the dialog. 

 

We have also observed crash in below scenarios for C++ AddIn

#

Command

Trigger Command In Design Workspace

Trigger Command In Manufacture Workspace

1

m_Application->executeTextCommand("Commands.Start MSFNestAuthoringCmd");

Nest Preparation dlg is opened and closed immediately

Crash  after dlg is opened

2

m_Application->executeTextCommand("Commands.Start MSFNestPrepareNestCmd");

Crash  after clicking Cancel button in Create Nest Study dlg

No issue

Message 4 of 16

@vijay.shindeSLE5F We are really trying to understand your goal with modifying the inputs to the nest related dialogs.  Please explain your goals so we can improve the experience.


-I'm having success using text command Commands.Start MSFNestAuthoringCmd in design workspace.

-MSFNestAuthoringCmd  is only supported from design workspace at this time. There is some discussion about supporting it from manufacture workspace but it is not clear if that will ever happen.  It is important to understand that in design workspace we are using the design asset - in manufacture workspace there is a different asset in use, which is the reason for the crash.

-Likewise, the Nest Study command is only supported in the manufacture workspace.  The proper asset might not even exist if you try to use it without having entered the mfg workspace.


Matt Wynn
Senior Manager, Software Development, Fusion Fabrication
Message 5 of 16

@vijay.shindeSLE5F Also, the proper way to execute a command from API is not using a text command, you should get the command definition:

 

Ptr<CommandDefinitions> commandDefinitions = ui->commandDefinitions();

Ptr<CommandDefinition> myCommand = commandDefinitions->(CommandID);

myCommand->execute();

 

You can do more interesting things with the command using its CommandDefinition.


Matt Wynn
Senior Manager, Software Development, Fusion Fabrication
Message 6 of 16

@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?

Message 7 of 16

@MattWynn Thanks for confirming the API behaviour with different workspaces. I agree that some command needs specific asset which is available with particular workspace but still application should not crash if we trigger command in other workspace. As a workaround we have added check for current workspace before triggering a command.

Message 8 of 16

MSFNestAuthoringCmd was never designed to be started by API.  The documentation for CommandDefinition.execute(input)  states "The values supported are unique for each command. and not all commands support input values."

 

We do have plans to add MSFNestAuthoringCmd from manufacture workspace, so when that happens the crash will go away.

Fusion Nesting is in active development, and we have other requests to create an API.  Please describe what you are trying to achieve so that we can improve your experience. 


Matt Wynn
Senior Manager, Software Development, Fusion Fabrication
Message 9 of 16

Thanks @MattWynn for your reply.

 

Do you mean to say that currently we can't set input values to MSFNestAuthoringCmd command?

Can we get list of Commands/Dialogs that supports Input values? Also is there any documentation regarding CommandDefinition and it's supported NamedValues?

 

We are working on achieving some level of automation with Design & CAM operations. We want to set specific values to some of the parameters in Dialogs(NEST Preparation, Setup, Create NEST Study, Pocket & 2D Contour). Doing so, user won't have to update values manually in dialog and can proceed with calculation easily.

Message 10 of 16

The API team tells me that they don't think the named values for commands was actually implemented for anything.  They are going to modify the help to say that argument is currently not used to avoid the confusion.

 

We are also working on increasing the level of automation for CAM operations (for example the automatic creation of setups from nests, and the select same plane faces for geometry selection in 2D profile and 2D contour).  What do you think are the biggest pain points in CAM and nesting?  I don't want you to spend time trying things only to find that it has been added by us.  


Matt Wynn
Senior Manager, Software Development, Fusion Fabrication
Message 11 of 16

@MattWynn Can you share the documentation link for the same?

So, as per API team we should not use CommandDefinitions; correct?

 

As alternative to CommandDefinition can we rely on executeTextCommand? 

Please refer to below forum post for reliability of these two. 

  1. Comment from BrianEkins regarding TextCommands
  2. Comment from Ekinsb regarding CommandDefinition
  3. Comment from GeorgeRoberts regarding API update
  4. Comment from scottmoyse regarding API update

Need your opinion for CommandDefinition & TextCommand to proceed with Design & CAM Automation we are trying to achieve. 

Message 12 of 16

If you have a CommandID I think it is always better to use CommandDefinition.execute() than m_Application->executeTextCommand("Commands.Start CommandID").  Use executeTextCommand() only for things that only a text command can do, and be aware that text commands, especially hidden ones, can change without warning.

 

CommandDefinition.execute() is documented at 

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-7ffc950f-92e8-47bc-8228-54b67ae8e2c8 
but it had not been updated as of today

 


Matt Wynn
Senior Manager, Software Development, Fusion Fabrication
Message 13 of 16

@MattWynn Thanks for your reply.

 

So, you suggest to use CommandDefinition over TextCommand and at the same time you mention that CommandDefinition aren't updated as of today.
Also in last reply you mentioned that "The API team tells me that they don't think the named values for commands was actually implemented for anything. argument is currently not used". 

 

Considering this, I have concern about achieving automation using Fusion360 API's. TextCommand aren't reliable and CommandDefinition input isn't working.

 

Can you conclude on this and suggest the best possible way to proceed with automation here?  
 

Message 14 of 16

The Fusion 360 API is not complete.  There are many things you can do in Fusion that the API does not support. In a few cases, there are workarounds but in most, there are not and it means you cannot automate those commands with a program.  This is unfortunate and in an ideal world, you would be able to do everything through the API but that's not where we're at.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 15 of 16

@BrianEkins is the best reference for Fusion API.

 

Since there is no API for Fusion nesting, and no plans for creating one, I don't think there is any way to control the two dialogs you mention in your original post.


Matt Wynn
Senior Manager, Software Development, Fusion Fabrication
Message 16 of 16

@BrianEkins Thanks for information.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report