parameters: (point, edge, strict=False)
docstring: Return a vector from the point to its closest point on the edge.
  
      If `strict` is `True`, the vector will be returned
      only if its endpoint lies on the `edge`.
      Edge can also be a list of 2 points.
docstring_summary: Return a vector from the point to its closest point on the edge.
docstring_tokens: Return a vector from the point to its closest point on the edge .
function: def findDistance(point, edge, strict=False):
      """Return a vector from the point to its closest point on the edge.
  
      If `strict` is `True`, the vector will be returned
      only if its endpoint lies on the `edge`.
      Edge can also be a list of 2 points.
      """
      if isinstance(point, App.Vector):
          if isinstance(edge, list):
              segment = edge[1].sub(edge[0])
              chord = edge[0].sub(point)
              norm = segment.cross(chord)
              perp = segment.cross(norm)
              dist = DraftVecUtils.project(chord, perp)
  
              if not dist:
                  return None
  
              newpoint = point.add(dist)
  
              if dist.Length == 0:
                  return None
  
              if strict:
                  s1 = newpoint.sub(edge[0])
                  s2 = newpoint.sub(edge[1])
                  if (s1.Length <= segment.Length
                          and s2.Length <= segment.Length):
                      return dist
                  else:
                      return None
              else:
                  return dist
  
          elif geomType(edge) == "Line":
              segment = vec(edge)
              chord = edge.Vertexes[0].Point.sub(point)
              norm = segment.cross(chord)
              perp = segment.cross(norm)
              dist = DraftVecUtils.project(chord, perp)
  
              if not dist:
                  return None
  
              newpoint = point.add(dist)
  
              if (dist.Length == 0):
                  return None
  
              if strict:
                  s1 = newpoint.sub(edge.Vertexes[0].Point)
                  s2 = newpoint.sub(edge.Vertexes[-1].Point)
                  if (s1.Length <= segment.Length
                          and s2.Length <= segment.Length):
                      return dist
                  else:
                      return None
              else:
                  return dist
  
          elif geomType(edge) == "Circle":
              ve1 = edge.Vertexes[0].Point
              if len(edge.Vertexes) > 1:
                  ve2 = edge.Vertexes[-1].Point
              else:
                  ve2 = None
              center = edge.Curve.Center
              segment = center.sub(point)
  
              if segment.Length == 0:
                  return None
  
              ratio = (segment.Length - edge.Curve.Radius) / segment.Length
              dist = segment.multiply(ratio)
              newpoint = App.Vector.add(point, dist)
  
              if dist.Length == 0:
                  return None
  
              if strict and ve2:
                  # Note 1: DraftVecUtils.angle(App.Vector(1, 1, 0)) => -0.7854
                  # Note 2: Angles are in the +pi to -pi range.
                  ang1 = DraftVecUtils.angle(ve1.sub(center))
                  ang2 = DraftVecUtils.angle(ve2.sub(center))
                  angpt = DraftVecUtils.angle(newpoint.sub(center))
                  if ang1 >= ang2: # Arc does not cross the 9 o'clock point.
                      if ang1 >= angpt and angpt >= ang2:
                          return dist
                      else:
                          return None
                  elif ang1 >= angpt or angpt >= ang2:
                      return dist
                  else:
                      return None
              else:
                  return dist
  
          elif (geomType(edge) == "BSplineCurve"
                or geomType(edge) == "BezierCurve"):
              try:
                  pr = edge.Curve.parameter(point)
                  np = edge.Curve.value(pr)
                  dist = np.sub(point)
              except Part.OCCError:
                  print("DraftGeomUtils: Unable to get curve parameter "
                        "for point ", point)
                  return None
              else:
                  return dist
          else:
              print("DraftGeomUtils: Couldn't project point")
              return None
      else:
          print("DraftGeomUtils: Couldn't project point")
          return None
function_tokens: def findDistance ( point , edge , strict = False ) : if isinstance ( point , App . Vector ) : if isinstance ( edge , list ) : segment = edge [ 1 ] . sub ( edge [ 0 ] ) chord = edge [ 0 ] . sub ( point ) norm = segment . cross ( chord ) perp = segment . cross ( norm ) dist = DraftVecUtils . project ( chord , perp ) if not dist : return None newpoint = point . add ( dist ) if dist . Length == 0 : return None if strict : s1 = newpoint . sub ( edge [ 0 ] ) s2 = newpoint . sub ( edge [ 1 ] ) if ( s1 . Length <= segment . Length and s2 . Length <= segment . Length ) : return dist else : return None else : return dist elif geomType ( edge ) == "Line" : segment = vec ( edge ) chord = edge . Vertexes [ 0 ] . Point . sub ( point ) norm = segment . cross ( chord ) perp = segment . cross ( norm ) dist = DraftVecUtils . project ( chord , perp ) if not dist : return None newpoint = point . add ( dist ) if ( dist . Length == 0 ) : return None if strict : s1 = newpoint . sub ( edge . Vertexes [ 0 ] . Point ) s2 = newpoint . sub ( edge . Vertexes [ - 1 ] . Point ) if ( s1 . Length <= segment . Length and s2 . Length <= segment . Length ) : return dist else : return None else : return dist elif geomType ( edge ) == "Circle" : ve1 = edge . Vertexes [ 0 ] . Point if len ( edge . Vertexes ) > 1 : ve2 = edge . Vertexes [ - 1 ] . Point else : ve2 = None center = edge . Curve . Center segment = center . sub ( point ) if segment . Length == 0 : return None ratio = ( segment . Length - edge . Curve . Radius ) / segment . Length dist = segment . multiply ( ratio ) newpoint = App . Vector . add ( point , dist ) if dist . Length == 0 : return None if strict and ve2 : # Note 1: DraftVecUtils.angle(App.Vector(1, 1, 0)) => -0.7854 # Note 2: Angles are in the +pi to -pi range. ang1 = DraftVecUtils . angle ( ve1 . sub ( center ) ) ang2 = DraftVecUtils . angle ( ve2 . sub ( center ) ) angpt = DraftVecUtils . angle ( newpoint . sub ( center ) ) if ang1 >= ang2 : # Arc does not cross the 9 o'clock point. if ang1 >= angpt and angpt >= ang2 : return dist else : return None elif ang1 >= angpt or angpt >= ang2 : return dist else : return None else : return dist elif ( geomType ( edge ) == "BSplineCurve" or geomType ( edge ) == "BezierCurve" ) : try : pr = edge . Curve . parameter ( point ) np = edge . Curve . value ( pr ) dist = np . sub ( point ) except Part . OCCError : print ( "DraftGeomUtils: Unable to get curve parameter " "for point " , point ) return None else : return dist else : print ( "DraftGeomUtils: Couldn't project point" ) return None else : print ( "DraftGeomUtils: Couldn't project point" ) return None