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: 

Problem with Javascript: Palette.sendInfoToHTML returns no response

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
j.han97
210 Views, 6 Replies

Problem with Javascript: Palette.sendInfoToHTML returns no response

Hi all, 

 

I am developing a palette recently and it worked fine until just now. The Javascript suddenly just refused to return anything. 

 

To identify the problem, I have created a sample to replicate this problem. With a simple palette that connects to a HTML with only "Hello World" as plain text, this script then sends a simple 'hi' message to the HTML.

 

However, the same error persists and show 'response empty' message.

jhan97_0-1641372288029.png

 

I am not experienced in Javascript, hence have no idea how to debug this problem. I have restarted Fusion 360 as well, but no help in this issue.

 

Thank you in advance for your kind help.

 

 

6 REPLIES 6
Message 2 of 7
j.han97
in reply to: j.han97

Ok, now I think the Fusion 360 on my computer is broken. When I ran this script:

import adsk.core, adsk.fusion, adsk.cam, traceback

_app = adsk.core.Application.get()
_ui = _app.userInterface

def run(context):
    try:
        _ui.messageBox('Hello world')

    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def stop(context):
    if _ui:
        _ui.messageBox('Bye bye world')

 The 'Hello world' dialog popped out first, then followed by 'Bye bye world' immediately. Seems like Fusion 360 is rushing from run() to stop() recklessly. I will re-install and see if the problem goes away.

Message 3 of 7
j.han97
in reply to: j.han97

After a clean re-install, Fusion 360 is working normally now. (Although I don't know if it will snap again someday) 

 

As a side note, I am experiencing some connectivity issues to Autodesk servers (pure speculation), so the problem might be rooting from there (pure speculation).

 

Anyway, the problem is gone for now, so I will mark this post as solved.

Message 4 of 7
kandennti
in reply to: j.han97

Hi @j.han97 .

 

When sending data from python to Html, it is useful to set it with json.dumps against HTMLEventArgs.returnData property.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-DC2A4AB7-6A24-4A28-87A0-9952A0ABDF74 

 

I also have very little experience with JavaScript, but I learned it from @thomasa88  and @JeromeBriot.

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/i-want-to-set-the-initial-values-for-the-p... 

 

And I was able to publish this one.

https://github.com/kantoku-code/Fusion360_PerspectiveAngleController 

Message 5 of 7
j.han97
in reply to: j.han97

Thank you @kandennti for the useful information. I definitely need them to make my code more robust.

 

Besides that, the developer mode mentioned in your post sounds very interesting to me. Since the html is implemented in Fusion 360 (kind of indirect), plus I am not very familiar with Javascript, it is extremely frustrating for me to debug the script. With the developer tools I expect to develop my script more efficiently.

Message 6 of 7
j.han97
in reply to: kandennti

Thanks to the tips on the developer tools in Fusion 360, I was able to find the problem. There is a mistyped function at the beginning (variable declaration) of the Javascript, which caused the whole script to fail and not returning everything.

 

So lesson learnt: If Javascript gives empty response, check the script!!

 

 

Message 7 of 7
rishabsain723
in reply to: j.han97

Great! this is helpful, thanks for sharing.

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