Last active
July 17, 2023 22:08
-
-
Save madhephaestus/91c6cabb475e250474d0c8beaf2284e7 to your computer and use it in GitHub Desktop.
slice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eu.mihosoft.vrl.v3d.CSG | |
import eu.mihosoft.vrl.v3d.Cube | |
import eu.mihosoft.vrl.v3d.Extrude | |
import eu.mihosoft.vrl.v3d.Polygon | |
import eu.mihosoft.vrl.v3d.Slice | |
import eu.mihosoft.vrl.v3d.Transform | |
import eu.mihosoft.vrl.v3d.svg.SVGExporter | |
import eu.mihosoft.vrl.v3d.svg.SVGLoad | |
def base = new Cube(20).toCSG() | |
.difference(new Cube(5,10,20).toCSG()) | |
.difference(new Cube(10,5,20).toCSG()) | |
.rotz(5) | |
.toZMin() | |
.movex(-10) | |
List<Polygon> polys = Slice.slice(base,new Transform(),0).collect{it.transformed(new Transform().movez(10))} | |
String url = "https://gist.github.com/91c6cabb475e250474d0c8beaf2284e7.git" | |
String filename="slice.svg" | |
File earCoreFile = ScriptingEngine.fileFromGit(url, | |
filename); | |
SVGExporter svg = new SVGExporter(); | |
for( Polygon p: polys){ | |
svg.toPolyLine(p); | |
svg.colorTick(); | |
} | |
println "Pushing changes" | |
//ScriptingEngine.pushCodeToGit(url, "master", filename, svg.make(), "Making Cached SVG "+filename, true) | |
ArrayList<Polygon> list=new ArrayList<Polygon>(); | |
SVGLoad l=new SVGLoad(earCoreFile.toURI()) | |
for(String s:l.getLayers()) { | |
list.addAll(l.getPolygonByLayers().get(s)) | |
} | |
return [base.movez(20),polys,list] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment