addam / Export-Paper-Model-from-Blender

Python addon for creating paper models in Blender (development version)
https://blenderartists.org/t/export-paper-model/476597
405 stars 53 forks source link

Add support for JSON export #60

Open manthrax opened 6 years ago

manthrax commented 6 years ago

It would be super useful to have a JSON export! This would pave the way for post processing with offline tools.. for instance generating GCODE for laser cutters or CNC machines... Custom plotting/resizing for different output devices.. It would also facilitate making a viewer in other 3d rendering engines..

A list of exterior line segments (cutting lines) and interior line segments (scoring lines).. Something like this perhaps? (I'm not exactly sure how uv coordinates would best fit into this model but I think they could probably be a separate unique sets of UVs per triangle?)

{
    "vertices":[
       {x:100,y:100},
       {x:105,y:100},
       {x:105,y:105},
       {x:100,y:105},

       {x:200,y:200},
       {x:205,y:200},
       {x:205,y:205},
       {x:200,y:205},
    ],
    "islands":[
        {
             "exterior":[0,1,1,2,2,3,3,0],
             "interior":[2,3]
         },
        {
             "exterior":[4,5,5,6,6,7,7,4],
             "interior":[6,7]
         }
    ],
    "faces":[
       {"vertices":[0,1,2],"uvs":[{x:0,y:0},{x:1,y:0},{x:1,y:1}]},
       {"vertices":[1,3,2],"uvs":[{x:1,y:1},{x:0,y:1},{x:0,y:0}]}
    ],
}
manthrax commented 6 years ago

I've thought about this a bit more, and noticed the SVG file looks pretty easy to parse, So maybe I should just write a converter rather than changing the exporter:)

alpharesearch commented 6 years ago

FYI - Inkscape can process SVG and there are multiple GCODE plugins to build upon.