Code generation?

For my PXT target ( I have a couple of scenarios where code generation might be helpful to my cause - so for example:

  1. There’s a popular C-like programming language out there that I would like to parse and convert to makecode and generate mkcd files.

It looks to me like the mkcd file is compressed JSON - with typescript and blockly xml. Could I get away with just generating one? Or would I have to generate both.

  1. There are cases where I want to load in external files and generate a series of blocks from it. Any thoughts how I could do that? So for example I would like to load STLs and SVGs into my editor for editing/extrusion. Any thoughts how I could do that?

Any thoughts or guidance would be lovely!

1 Like
  1. I would guess only need to generate one, we support importing loose typescript and blocks so I think everything should just work
  2. I think you can do this with editor extensions. To use them, you need to create a folder called editor in your target and inside have a file that defines initExtensionsAsync (we do it in pxt-arcade here). The full list of contribution points is here; I think the resourceImporter is what you want.

Neato! Will take a look. Thanks again!! :slight_smile:

Hello, how did you decode the mkcd file into JSON? would you mind sharing some code snippets for that?

I haven’t needed to do that yet - but you can rename the file .7zip then unpack it. You would need to use lzma to uncompress it.



To decode an MKCD file, you can use the PXT command line to extract a .mdcd, .hex or even shared game.

pxt extract <path to hex/mkcd/uf2>

See Command Line Tool (