How to call a custom function, for example, I defined a name called angle myself_ between_ Points function, and I want to call it in the fiter function. How should I call it。
@objc.python_method
def angle_between_points(point1, point2):
dx = point2.x - point1.x
dy = point2.y - point1.y
return math.degrees(math.atan2(dy, dx))
@objc.python_method
def fiter(point1, point2):
a = angle_between_points(point1, point2)
return a
If you define the method in the same object from where you are calling it, you need to add self.
:
a = self.angle_between_points(point1, point2)
Yes, I have already resolved it. Thank you
When both functions call other functions, an error is reported as follows:
File “plugin.py”, line 28, in
class Fontbold(FilterWithDialog):
objc.BadPrototypeError: Objective-C expects 1 arguments, Python argument has 2 arguments for <unbound selector Calculate_slope of Fontbold at 0x124b40b90>
Only the filter function can call other functions, and other functions can only be called, right
Python methods expect the first parameter to be the self object. For example:
def angle_between_points(self, point1, point2):