Convert js to blocks in blockly

1,559 views
Skip to first unread message

Navaneethan

unread,
Jan 22, 2020, 8:43:25 AM1/22/20
to Blockly
Is there a way to generate blocks from javascript code in blockly (not a custom block)

Coda Highland

unread,
Jan 22, 2020, 9:16:27 AM1/22/20
to blo...@googlegroups.com
Sure. There are a couple ways to do it, and which one is more appropriate depends on your use case. You can either construct XML and load or append it to the workspace, or you can use the workspace and block API functions to create and connect blocks individually.

/s/ Adam

On Wed, Jan 22, 2020 at 7:43 AM Navaneethan <navane...@pillir.io> wrote:
Is there a way to generate blocks from javascript code in blockly (not a custom block)

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/9d41f2a1-d983-49a1-b9e0-a0b47e106ded%40googlegroups.com.

Navaneethan

unread,
Jan 27, 2020, 1:57:54 AM1/27/20
to Blockly
Hi, adam

Thank you for the quick response.

We are planning to construct XML from the javascript. Is there any example or sample for this scenario.


On Wednesday, January 22, 2020, at 7:46:27 PM UTC+5:30, Coda Highland wrote:
Sure. There are a couple ways to do it, and which one is more appropriate depends on your use case. You can either construct XML and load or append it to the workspace, or you can use the workspace and block API functions to create and connect blocks individually.

/s/ Adam

On Wed, Jan 22, 2020 at 7:43 AM Navaneethan <navane...@pillir.io> wrote:
Is there a way to generate blocks from javascript code in blockly (not a custom block)

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blo...@googlegroups.com.

Coda Highland

unread,
Jan 27, 2020, 4:47:44 PM1/27/20
to blo...@googlegroups.com
I can't think of any examples off the top of my head, but check out this function in the docs:


/s/ Adam

To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/43c3a225-73d6-41d4-8691-b3345ff2ec68%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages