def distanceFrom(self,other): if self.pos: try: if type(other) is Transformer: #if transformer, return the smallest distance from all elements in the transformer. return other.distanceFrom(self) elif type(other) is Branch: #if the other is a line, return DC.lineToLine(self.pos, other.pos)[0] else: return DC.pointToLine(self.pos, other.getPos())[0] except NoneType: return None else: return None
def distanceFrom(self, other): try: if type(other) is not type(self): return other.distanceFrom(self) else: return DC.pointToPoint(self.getPos(), other.getPos()) except (TypeError, AttributeError): return None