How to create a `BrowserCommandInput` and populate it with initial data from Fusion?

How to create a `BrowserCommandInput` and populate it with initial data from Fusion?

jan_weidner
Contributor Contributor
621 Views
3 Replies
Message 1 of 4

How to create a `BrowserCommandInput` and populate it with initial data from Fusion?

jan_weidner
Contributor
Contributor

How to create a `BrowserCommandInput` and populate it with initial data from Fusion?

 

Generally, I can use `browserCommandInput.sendInfoToHTML(action, data)` to send data from Fusion360 to javascript.

However, it does not work for me if I do it in the CommandCreatedHandler, this function just returns false for me.

class MyCommandCreatedHandler(adsk.core.CommandCreatedEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args):
        try:
            # Get the command that was created.
            cmd = adsk.core.Command.cast(args.command)
            inputs: adsk.core.CommandInputs = cmd.commandInputs
            b = inputs.addBrowserCommandInput(...)
            b.sendInfoToHTML(...) # returns false, has no effect

What is the recommended way to create a `BrowserCommandInput` and populate it with initial data from Fusion?

0 Likes
Accepted solutions (1)
622 Views
3 Replies
Replies (3)
Message 2 of 4

kandennti
Mentor
Mentor
Accepted solution

Hi @jan_weidner -San.

 

I have created a sample script.

The attached script passes the name of the active document at the time of execution from python to javascript and displays it with BrowserCommandInput.

Message 3 of 4

jan_weidner
Contributor
Contributor

Thanks a lot I only now noticed your reply, I will look into it and come back to you.

0 Likes
Message 4 of 4

jan_weidner
Contributor
Contributor

Works for me, thanks!