parameters: (polyline, forceShape=False, num=None)
return_statement: return None
docstring: Return a Part shape (Wire, Face, or Shell) from a DXF polyline.
  
      It traverses the points of the polyline checking for straight edges,
      and for curvatures (bulges) between two points.
      Then it produces `Part.Edges` and `Part.Arcs`, and decides what to output
      at the end based on the options.
  
      Parameters
      ----------
      polyline : drawing.entities
          The DXF object of type `'polyline'` or `'lwpolyline'`.
  
      forceShape : bool, optional
          It defaults to `False`. If it is `True` it will try to produce
          a `Part.Wire`, otherwise it try to produce a `Draft Wire`.
  
      num : float, optional
          It defaults to `None`. A simple number that identifies this polyline.
  
      Returns
      -------
      Part::Part2DObject or Part::TopoShape ('Wire', 'Face', 'Shell')
          It returns `None` if it fails producing a shape.
  
      If the polyline has a `width` and the global variable
      `dxfRenderPolylineWidth` is set, it will try to return a face simulating
      a thick line. If the polyline is closed, it will cut the interior loop
      to produce the a shell.
  
      If the polyline doesn't have curvatures, and the global variables
      `dxfCreateDraft` or `dxfCreateSketch` are set, and `forceShape` is `False`
      it creates a straight `Draft Wire`.
  
      If the polyline is closed, and the global variable `dxfFillMode`
      is set, it will return a `Part.Face`, otherwise it will return
      a `Part.Wire`.
  
      See also
      --------
      drawBlock
  
      To do
      -----
      Use local variables, not global variables.
docstring_summary: Return a Part shape (Wire, Face, or Shell) from a DXF polyline.
docstring_tokens: Return a Part shape ( Wire Face or Shell ) from a DXF polyline .
function: def drawPolyline(polyline, forceShape=False, num=None):
      """Return a Part shape (Wire, Face, or Shell) from a DXF polyline.
  
      It traverses the points of the polyline checking for straight edges,
      and for curvatures (bulges) between two points.
      Then it produces `Part.Edges` and `Part.Arcs`, and decides what to output
      at the end based on the options.
  
      Parameters
      ----------
      polyline : drawing.entities
          The DXF object of type `'polyline'` or `'lwpolyline'`.
  
      forceShape : bool, optional
          It defaults to `False`. If it is `True` it will try to produce
          a `Part.Wire`, otherwise it try to produce a `Draft Wire`.
  
      num : float, optional
          It defaults to `None`. A simple number that identifies this polyline.
  
      Returns
      -------
      Part::Part2DObject or Part::TopoShape ('Wire', 'Face', 'Shell')
          It returns `None` if it fails producing a shape.
  
      If the polyline has a `width` and the global variable
      `dxfRenderPolylineWidth` is set, it will try to return a face simulating
      a thick line. If the polyline is closed, it will cut the interior loop
      to produce the a shell.
  
      If the polyline doesn't have curvatures, and the global variables
      `dxfCreateDraft` or `dxfCreateSketch` are set, and `forceShape` is `False`
      it creates a straight `Draft Wire`.
  
      If the polyline is closed, and the global variable `dxfFillMode`
      is set, it will return a `Part.Face`, otherwise it will return
      a `Part.Wire`.
  
      See also
      --------
      drawBlock
  
      To do
      -----
      Use local variables, not global variables.
      """
      if len(polyline.points) > 1:
          edges = []
          curves = False
          verts = []
          for p in range(len(polyline.points)-1):
              p1 = polyline.points[p]
              p2 = polyline.points[p+1]
              v1 = vec(p1)
              v2 = vec(p2)
              verts.append(v1)
              if not DraftVecUtils.equals(v1, v2):
                  if polyline.points[p].bulge:
                      curves = True
                      cv = calcBulge(v1, polyline.points[p].bulge, v2)
                      if DraftVecUtils.isColinear([v1, cv, v2]):
                          try:
                              edges.append(Part.LineSegment(v1, v2).toShape())
                          except Part.OCCError:
                              warn(polyline, num)
                      else:
                          try:
                              edges.append(Part.Arc(v1, cv, v2).toShape())
                          except Part.OCCError:
                              warn(polyline, num)
                  else:
                      try:
                          edges.append(Part.LineSegment(v1, v2).toShape())
                      except Part.OCCError:
                          warn(polyline, num)
          verts.append(v2)
          if polyline.closed:
              p1 = polyline.points[len(polyline.points)-1]
              p2 = polyline.points[0]
              v1 = vec(p1)
              v2 = vec(p2)
              cv = calcBulge(v1, polyline.points[-1].bulge, v2)
              if not DraftVecUtils.equals(v1, v2):
                  if DraftVecUtils.isColinear([v1, cv, v2]):
                      try:
                          edges.append(Part.LineSegment(v1, v2).toShape())
                      except Part.OCCError:
                          warn(polyline, num)
                  else:
                      try:
                          edges.append(Part.Arc(v1, cv, v2).toShape())
                      except Part.OCCError:
                          warn(polyline, num)
          if edges:
              try:
                  width = rawValue(polyline, 43)
                  if width and dxfRenderPolylineWidth:
                      w = Part.Wire(edges)
                      w1 = w.makeOffset(width/2)
                      if polyline.closed:
                          w2 = w.makeOffset(-width/2)
                          w1 = Part.Face(w1)
                          w2 = Part.Face(w2)
                          if w1.BoundBox.DiagonalLength > w2.BoundBox.DiagonalLength:
                              return w1.cut(w2)
                          else:
                              return w2.cut(w1)
                      else:
                          return Part.Face(w1)
                  elif (dxfCreateDraft or dxfCreateSketch) and (not curves) and (not forceShape):
                      ob = Draft.makeWire(verts)
                      ob.Closed = polyline.closed
                      ob.Placement = placementFromDXFOCS(polyline)
                      return ob
                  else:
                      if polyline.closed and dxfFillMode:
                          w = Part.Wire(edges)
                          w.Placement = placementFromDXFOCS(polyline)
                          return Part.Face(w)
                      else:
                          w = Part.Wire(edges)
                          w.Placement = placementFromDXFOCS(polyline)
                          return w
              except Part.OCCError:
                  warn(polyline, num)
      return None
function_tokens: def drawPolyline ( polyline , forceShape = False , num = None ) : if len ( polyline . points ) > 1 : edges = [ ] curves = False verts = [ ] for p in range ( len ( polyline . points ) - 1 ) : p1 = polyline . points [ p ] p2 = polyline . points [ p + 1 ] v1 = vec ( p1 ) v2 = vec ( p2 ) verts . append ( v1 ) if not DraftVecUtils . equals ( v1 , v2 ) : if polyline . points [ p ] . bulge : curves = True cv = calcBulge ( v1 , polyline . points [ p ] . bulge , v2 ) if DraftVecUtils . isColinear ( [ v1 , cv , v2 ] ) : try : edges . append ( Part . LineSegment ( v1 , v2 ) . toShape ( ) ) except Part . OCCError : warn ( polyline , num ) else : try : edges . append ( Part . Arc ( v1 , cv , v2 ) . toShape ( ) ) except Part . OCCError : warn ( polyline , num ) else : try : edges . append ( Part . LineSegment ( v1 , v2 ) . toShape ( ) ) except Part . OCCError : warn ( polyline , num ) verts . append ( v2 ) if polyline . closed : p1 = polyline . points [ len ( polyline . points ) - 1 ] p2 = polyline . points [ 0 ] v1 = vec ( p1 ) v2 = vec ( p2 ) cv = calcBulge ( v1 , polyline . points [ - 1 ] . bulge , v2 ) if not DraftVecUtils . equals ( v1 , v2 ) : if DraftVecUtils . isColinear ( [ v1 , cv , v2 ] ) : try : edges . append ( Part . LineSegment ( v1 , v2 ) . toShape ( ) ) except Part . OCCError : warn ( polyline , num ) else : try : edges . append ( Part . Arc ( v1 , cv , v2 ) . toShape ( ) ) except Part . OCCError : warn ( polyline , num ) if edges : try : width = rawValue ( polyline , 43 ) if width and dxfRenderPolylineWidth : w = Part . Wire ( edges ) w1 = w . makeOffset ( width / 2 ) if polyline . closed : w2 = w . makeOffset ( - width / 2 ) w1 = Part . Face ( w1 ) w2 = Part . Face ( w2 ) if w1 . BoundBox . DiagonalLength > w2 . BoundBox . DiagonalLength : return w1 . cut ( w2 ) else : return w2 . cut ( w1 ) else : return Part . Face ( w1 ) elif ( dxfCreateDraft or dxfCreateSketch ) and ( not curves ) and ( not forceShape ) : ob = Draft . makeWire ( verts ) ob . Closed = polyline . closed ob . Placement = placementFromDXFOCS ( polyline ) return ob else : if polyline . closed and dxfFillMode : w = Part . Wire ( edges ) w . Placement = placementFromDXFOCS ( polyline ) return Part . Face ( w ) else : w = Part . Wire ( edges ) w . Placement = placementFromDXFOCS ( polyline ) return w except Part . OCCError : warn ( polyline , num ) return None