## 3 Method
### Data Generation
#### 3.1.2 SketchGraph  
Unlike the Pillow approach, the SketchGraph uses another way of creating symbols, similar to a sketcher in CAD programs. At first, a command sequence is generated that contains all the relevant information for creating the sketch. SketchGraph distinguishes between node and edge operations and their associated properties. The sequence is then converted into a sketch object, which interacts with Onshape's API. This link is necessary because Onshape works as a geometric constraint solver and generates the final sketch. The solved sketch can then be rendered with various settings. There is an option to select a \"hand-drawn\" mode, which alters the lines of the sketch to mimic a hand-drawn sketch. The general program flow is again listed in Algorithm 2.  
```
Data: number of images n, number of symbols s, doRealistic, hand drawn factor hf Result: Dataset with images and labels for\(i\in n\)do \(seq\) = createSketch (\(node\)); while\(i<\)drawSymbolPlanetGear(3,\(s\))do if\(doRealistic\)then \(sym[i]=\) chooseSym(\(symPair\)); \(sym[i+1]=\) chooseSym(\(symPair\)); \(seq\) = drawSymSeq(\(seq,sym[i,i+1]\)); \(i\gets i+2\); for\(c\in s-1\)do \(seq\) = drawConnection(\(seq\)); \(sym[i]=\) chooseSym(\(symclass\)); ifinstPlanetGear(\(sym\)) > 1 &&\(sym[i]==\) PlanetGear then break; else \(seq\) = drawSymSeq(\(seq,sym\)); \(i\gets i+1\) ; \(solvedSketch=\) SG_SketchFromSeq(\(seq\)); for\(j\in\) drawSymbolowPlanetGear(\(3\),\(s\))do \(BB[j]=\) getBBfromSketch(\(solvedSketch\)); \(image\) = renderSketch(\(solvedSketch\),\(hf\)); saveBBxml(\(BB\)); saveImage(\(image\));
```  
Figure 6: Example plots of the Pillow and SketchGraph data generation methods.  
Another difference is the possibility to improve the imitation of sketches. Based on the real sketches, symbol pairs are initially formed using previously defined rules, e.g., two gear symbols are directly placed next to each other. In addition, connecting lines between similar domain symbols are also generated, for example, between a rotary joint and a fixed bearing. The selection of contact partners and associated symbols is randomized, taking into account the location of existing symbols for the connecting lines to avoid overlap. As in the previous approach, symbol selection, positioning and variation are randomised, with collision checking performed in each object class. The individual symbol classes employ general rules for the structure of the respective symbol. A special rule was added for the planetary gear, since this symbol requires a lot of space compared to the others. During the creation of the sketch, the number of planetary gears is checked and reduced to one symbol per sketch in order to leave enough space for the other symbols. In addition to the many minor factors, two major elements can be set in the dataset generation: hand-drawn symbols and more realistic sketch representation. Therefore, all possible combinations are used for the training, which results in four different training datasets (SketchGraph 1: no additions, SketchGraph 2: hand-drawn, SketchGraph 3: realistic and SketchGraph 4: hand-drawn + realisitic). The gray framed example images in Figure 6 illustrate the results for the four combinations.  
The disadvantage of this method is that it significantly increases the amount of time it takes to generate the data. Although multiprocessing and multiple Onshape documents are used to generate the sketches, the required time is still high. On average, the creation of a sketch with the SketchGraph method takes about 0.7-1 s, whereas the Pillow approach only needs 0.001 s.