# Code generation?

**URL:** https://forum.makecode.com/t/code-generation/4050
**Category:** PXT
**Created:** [October 23, 2020, 8:46pm UTC](https://forum.makecode.com/t/code-generation/4050 "2020-10-23T20:46:04Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jfo8000](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jfo8000/32/1038_2.png) [@jfo8000](https://forum.makecode.com/u/jfo8000)
#### Post date: [October 23, 2020, 8:46pm UTC](https://forum.makecode.com/t/code-generation/4050/1 "2020-10-23T20:46:04Z")

</div>

For my PXT target ([https://makecode.buildbee.com](https://makecode.buildbee.com)) 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!  
JFo

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [October 23, 2020, 9:58pm UTC](https://forum.makecode.com/t/code-generation/4050/2 "2020-10-23T21:58:23Z")

</div>

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](https://github.com/microsoft/pxt-arcade/blob/master/editor/extension.ts#L319)). The full list of contribution points is [here](https://github.com/microsoft/pxt/blob/master/pxteditor/editor.ts#L390); I think the `resourceImporter` is what you want.

---

<div class="post-metadata">

### Author: ![jfo8000](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jfo8000/32/1038_2.png) [@jfo8000](https://forum.makecode.com/u/jfo8000)
#### Post date: [October 31, 2020, 2:45am UTC](https://forum.makecode.com/t/code-generation/4050/3 "2020-10-31T02:45:11Z")

</div>

Neato! Will take a look. Thanks again!! 🙂

---

<div class="post-metadata">

### Author: ![khayliang](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/khayliang/32/2437_2.png) [@khayliang](https://forum.makecode.com/u/khayliang)
#### Post date: [November 23, 2020, 8:37am UTC](https://forum.makecode.com/t/code-generation/4050/4 "2020-11-23T08:37:24Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jfo8000](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jfo8000/32/1038_2.png) [@jfo8000](https://forum.makecode.com/u/jfo8000)
#### Post date: [November 23, 2020, 8:51am UTC](https://forum.makecode.com/t/code-generation/4050/5 "2020-11-23T08:51:52Z")

</div>

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.

> **[microsoft/pxt](https://github.com/microsoft/pxt/search?q=LZMA)**
>
> Microsoft MakeCode (PXT - Programming eXperience Toolkit) - microsoft/pxt

JFo

---

<div class="post-metadata">

### Author: ![peli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/peli/32/12_2.png) [@peli](https://forum.makecode.com/u/peli)
#### Post date: [November 23, 2020, 9:19am UTC](https://forum.makecode.com/t/code-generation/4050/6 "2020-11-23T09:19:26Z")

</div>

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

```auto
pxt extract <path to hex/mkcd/uf2>

```

See [Command Line Tool (makecode.com)](https://makecode.com/cli)
