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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Event when HTML is loaded and ready?

Message 1 of 5
163 Views, 4 Replies

Event when HTML is loaded and ready?

I tried to sendInfoToHTML within CommandEventHandler which triggers after CommandCreatedEvent but the Palette does not response. May be because it has not been loaded and ready to receive? 

I need to send data before user has a chance to click any thing on the palette.

I hope I don't have to spawn a task to poll for ready status.


Thank you 

Message 2 of 5
in reply to: sophiadoan

Hi @sophiadoan .


I interpreted the initial value of the palette display to mean that you want Fusion360 to send some data to be displayed.


On the JavaScript side, use the DOMContentLoaded event to call the adsk.fusionSendData function.
On the C++ side, pick up the DOM side call with the incomingFromHTML event and send the necessary data to the JavaScript side using HTMLEventArgs.returnData. 


The content is in python, but I also learned it here. 

Note that the new browser (QT Web Browser) is asynchronous.

Message 3 of 5
in reply to: sophiadoan

window.addEventListener('DOMContentLoaded', (event) => {
adsk.fusionSendData('domLoaded', '');

above event did fired, but this is what I see in the Console error output:

VM41 ImagePanel.html:104 Uncaught ReferenceError: adsk is not defined
at VM41 ImagePanel.html:104


and HTMLEventHandler never get called until some button is clicked on the palette.

Message 4 of 5
in reply to: sophiadoan

@sophiadoan .


We could not reproduce the same error here.


Does JavaScript give the same error when I do this?

document.addEventListener('DOMContentLoaded', () => {
	let adskWaiter = setInterval(() => {
		if (window.adsk) {
			adsk.fusionSendData('domLoaded', '');
Message 5 of 5
in reply to: kandennti


I did not use polling (setInterval), with it now it works!


Thank you very much

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