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