Input parameter of CommandDefinition execute method

Input parameter of CommandDefinition execute method

siliconlad
Contributor Contributor
526 Views
3 Replies
Message 1 of 4

Input parameter of CommandDefinition execute method

siliconlad
Contributor
Contributor

According to the Fusion 360 API documentation, the execute() method on a CommandDefinition accepts an input parameter.

How do I access the values in the command that's being called?

I have the following snippet here in one of my commands:

cmd = ui.commandDefinitions.itemById(CMD_ID)
x = adsk.core.NamedValues.create()
x.add('message', adsk.core.ValueInput.createByString('hey'))
cmd.execute(x)

How do I access `message` and `hey` when my other command (with `CMD_ID`) is created?

Accepted solutions (1)
527 Views
3 Replies
Replies (3)
Message 2 of 4

kandennti
Mentor
Mentor

Hi @siliconlad -San.

 

I am not sure I understand what you want to do, but I have little information on the arguments of the CommandDefinition.execute method.

 

There is a possibility that you can do what you want by using a text command.

https://github.com/kantoku-code/Fusion360_Small_Tools_for_Developers/tree/master/TextCommands 

 

However, it is more difficult to develop than the normal API.

0 Likes
Message 3 of 4

siliconlad
Contributor
Contributor

I've figured out a way around this. I was just curious how I could use the argument for `CommandDefinition.execute` because it looked like it would provide a cleaner solution to what I wanted to achieve. It's weird that it's in the API documentation, but there's indicatino of how to use it?

0 Likes
Message 4 of 4

BrianEkins
Mentor
Mentor
Accepted solution

That argument was added for possible future use. The Inventor API has similar functionality, and I thought it could also be useful in Fusion. It was never intended as a way to provide all of the required input for all commands, but can be useful in a few fringe cases. It would primarily be used for commands that display a dialog. For example, in Inventor, you could provide the filename and execute the component insert command, and it would bypass the dialog, using the provided filename, and go into the next step where the user can move the mouse around to position the component. Nothing has been done in Fusion to take advantage of this yet.

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