5 SketchPointId = 'SketchPoint'
6 SketchLineId = 'SketchLine'
7 SketchArcId = 'SketchArc'
8 SketchConstraintCoincidenceId = 'SketchConstraintCoincidence'
9 SketchConstraintParallelId = 'SketchConstraintParallel'
10 SketchConstraintTangentId = 'SketchConstraintTangent'
11 SketchConstraintEqualId = 'SketchConstraintEqual'
13 # Test split on line with one point
15 partSet = model.moduleDocument()
16 Part_1 = model.addPart(partSet)
17 Part_1_doc = Part_1.document()
18 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
19 SketchLine_1 = Sketch_1.addLine(0, 50, 100, 50)
20 SketchPoint_1 = Sketch_1.addPoint(50, 50)
21 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_1.result())
22 Sketch_1.addSplit(SketchLine_1, SketchPoint_1.coordinates(), SketchLine_1.endPoint())
25 Sketch_1_feature = featureToCompositeFeature(Sketch_1.feature())
27 for index in range(Sketch_1_feature.numberOfSubs()):
28 idList.append(Sketch_1_feature.subFeature(index).getKind())
30 assert(idList.count(SketchLineId) == 2)
31 assert(idList.count(SketchPointId) == 1)
32 assert(idList.count(SketchConstraintCoincidenceId) == 3)
33 assert(idList.count(SketchConstraintParallelId) == 1)
36 # Test split on line with two points
37 Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
38 SketchLine_2_1 = Sketch_2.addLine(0, 50, 100, 50)
39 SketchPoint_2_1 = Sketch_2.addPoint(25, 50)
40 SketchPoint_2_2 = Sketch_2.addPoint(75, 50)
41 SketchConstraintCoincidence_2_1 = Sketch_2.setCoincident(SketchPoint_2_1.coordinates(), SketchLine_2_1.result())
42 SketchConstraintCoincidence_2_2 = Sketch_2.setCoincident(SketchPoint_2_2.coordinates(), SketchLine_2_1.result())
43 Sketch_2.addSplit(SketchLine_2_1, SketchPoint_2_1.coordinates(), SketchPoint_2_2.coordinates())
46 Sketch_2_feature = featureToCompositeFeature(Sketch_2.feature())
48 for index in range(Sketch_2_feature.numberOfSubs()):
49 idList.append(Sketch_2_feature.subFeature(index).getKind())
51 assert(idList.count(SketchLineId) == 3)
52 assert(idList.count(SketchPointId) == 2)
53 assert(idList.count(SketchConstraintCoincidenceId) == 6)
54 assert(idList.count(SketchConstraintParallelId) == 2)
57 # Test split on circle with two points
58 Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
59 SketchCircle_3_1 = Sketch_3.addCircle(50, 50, 50)
60 SketchPoint_3_1 = Sketch_3.addPoint(50, 0)
61 SketchPoint_3_2 = Sketch_3.addPoint(50, 100)
62 SketchConstraintCoincidence_3_1 = Sketch_3.setCoincident(SketchPoint_3_1.coordinates(), SketchCircle_3_1.results()[1])
63 SketchConstraintCoincidence_3_2 = Sketch_3.setCoincident(SketchPoint_3_2.coordinates(), SketchCircle_3_1.results()[1])
64 Sketch_3.addSplit(SketchCircle_3_1, SketchPoint_3_1.coordinates(), SketchPoint_3_2.coordinates())
67 Sketch_3_feature = featureToCompositeFeature(Sketch_3.feature())
69 for index in range(Sketch_3_feature.numberOfSubs()):
70 idList.append(Sketch_3_feature.subFeature(index).getKind())
72 assert(idList.count(SketchArcId) == 2)
73 assert(idList.count(SketchPointId) == 2)
74 assert(idList.count(SketchConstraintCoincidenceId) == 6)
75 assert(idList.count(SketchConstraintTangentId) == 1)
78 # Test split on arc with one point
79 Sketch_4 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
80 SketchArc_4_1 = Sketch_4.addArc(50, 50, 50, 0, 0, 50, False)
81 Sketch_4.setFixed(SketchArc_4_1.startPoint())
82 Sketch_4.setFixed(SketchArc_4_1.endPoint())
83 Sketch_4.setRadius(SketchArc_4_1, 50)
84 SketchPoint_4_1 = Sketch_4.addPoint(50, 100)
85 SketchConstraintCoincidence_4_1 = Sketch_4.setCoincident(SketchPoint_4_1.coordinates(), SketchArc_4_1.results()[1])
86 Sketch_4.addSplit(SketchArc_4_1, SketchPoint_4_1.coordinates(), SketchArc_4_1.endPoint())
89 Sketch_4_feature = featureToCompositeFeature(Sketch_4.feature())
91 for index in range(Sketch_4_feature.numberOfSubs()):
92 idList.append(Sketch_4_feature.subFeature(index).getKind())
94 assert(idList.count(SketchArcId) == 2)
95 assert(idList.count(SketchPointId) == 1)
96 assert(idList.count(SketchConstraintCoincidenceId) == 3)
97 assert(idList.count(SketchConstraintEqualId) == 1)
98 assert(idList.count(SketchConstraintTangentId) == 1)
101 # Test split on arc with two points
102 Sketch_5 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
103 SketchArc_5_1 = Sketch_5.addArc(50, 50, 93.30127018922, 75, 0, 50, False)
104 Sketch_5.setFixed(SketchArc_5_1.startPoint())
105 Sketch_5.setFixed(SketchArc_5_1.endPoint())
106 Sketch_5.setRadius(SketchArc_5_1, 50)
107 SketchLine_5_1 = Sketch_5.addLine(25, 93.301270189222, 75, 93.301270189222)
108 SketchConstraintCoincidence_5_1 = Sketch_5.setCoincident(SketchLine_5_1.startPoint(), SketchArc_5_1.results()[1])
109 SketchConstraintCoincidence_5_2 = Sketch_5.setCoincident(SketchLine_5_1.endPoint(), SketchArc_5_1.results()[1])
110 SketchConstraintHorizontal_5_1 = Sketch_5.setHorizontal(SketchLine_5_1.result())
111 SketchConstraintLength_5_1 = Sketch_5.setLength(SketchLine_5_1.result(), 50)
112 Sketch_5.addSplit(SketchArc_5_1, SketchLine_5_1.startPoint(), SketchLine_5_1.endPoint())
115 Sketch_5_feature = featureToCompositeFeature(Sketch_5.feature())
117 for index in range(Sketch_5_feature.numberOfSubs()):
118 idList.append(Sketch_5_feature.subFeature(index).getKind())
120 assert(idList.count(SketchArcId) == 3)
121 assert(idList.count(SketchPointId) == 0)
122 assert(idList.count(SketchConstraintCoincidenceId) == 6)
123 assert(idList.count(SketchConstraintEqualId) == 2)
124 assert(idList.count(SketchConstraintTangentId) == 2)
129 assert(model.checkPythonDump())