+
+
+ # Macro functions combining geometry creation and constraints
+
+ def addPolyline (self, *coords):
+ """Add a poly-line to this Sketch.
+
+ The end of consecutive segments are defined as coincident.
+ """
+ c0 = coords[0]
+ c1 = coords[1]
+ polyline = []
+ line_1 = self.addLine(c0, c1)
+ polyline.append(line_1)
+ # Adding and connecting next lines
+ for c2 in coords[2:]:
+ line_2 = self.addLine(c1, c2)
+ self.setCoincident(line_1.endPointData(), line_2.startPointData())
+ polyline.append(line_2)
+ c1 = c2
+ line_1 = line_2
+ return polyline
+
+ def addPolygon (self, *coords):
+ """Add a polygon to this Sketch.
+
+ The end of consecutive segments are defined as coincident.
+ """
+ pg = self.addPolyline(*coords)
+ # Closing the poly-line supposed being defined by at least 3 points
+ c0 = coords[0]
+ cn = coords[len(coords) - 1]
+ ln = self.addLine(cn, c0)
+ self.setCoincident(
+ pg[len(coords) - 2].endPointData(), ln.startPointData()
+ )
+ self.setCoincident(
+ ln.endPointData(), pg[0].startPointData()
+ )
+ pg.append(ln)
+ return pg