1+ //
2+ // SPDX-License-Identifier: CC0-1.0
3+ //
4+ // This example code file is released to the public under Creative Commons CC0.
5+ // See https://creativecommons.org/publicdomain/zero/1.0/legalcode
6+ //
7+ // To the extent possible under law, LEAP 71 has waived all copyright and
8+ // related or neighboring rights to this PicoGK example code file.
9+ //
10+ // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
11+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
16+ // THE SOFTWARE.
17+ //
18+
19+ using PicoGK ;
20+
21+ namespace PicoGKExamples
22+ {
23+ class ShowCLI
24+ {
25+ public ShowCLI ( string strCLIFile )
26+ {
27+ m_strCLIFile = strCLIFile ;
28+ }
29+
30+ public void Task ( )
31+ {
32+ // Load all CLI slices
33+ CliIo . Result oResult = CliIo . oSlicesFromCliFile ( m_strCLIFile ) ;
34+
35+ // Add all slices to the viewer
36+ oResult . oSlices . AddToViewer ( Library . oViewer ( ) ) ;
37+
38+ // Write out all slice as SVGs
39+ // Create a subdirectory, to not spam the CLI file folder
40+
41+ string strDir = Path . GetDirectoryName ( m_strCLIFile ) ?? Library . strLogFolder ;
42+ string strName = Path . GetFileNameWithoutExtension ( m_strCLIFile ) ;
43+ string strSubDir = Path . Combine ( strDir , strName + "_SVGs" ) ;
44+ Directory . CreateDirectory ( strSubDir ) ;
45+
46+ // Iterate throug all slices and save as SVGs
47+ for ( int n = 0 ; n < oResult . oSlices . nCount ( ) ; n ++ )
48+ {
49+ PolySlice oSlice = oResult . oSlices . oSliceAt ( n ) ;
50+ oSlice . SaveToSvgFile ( Path . Combine ( strSubDir , strName + $ "_{ n : 00000} .svg") , true ) ;
51+ }
52+ }
53+
54+ string m_strCLIFile ;
55+ }
56+ }
0 commit comments