I am making class for phyton script to manipulate AutoCAD. I had different function before for each action but I decided to make it as object to be more readable in script. I found myself repeating part of the code all the time and I was wondering how I can code this different way so that each function get LAYER and LINETYPE_SCALE automatically so I do not need to rewrite it all the time because there will be much more functions and all of them will have that part of code. Also I want to be able to change the code in one place if I need to. Thank you
class Draw:
def Rectangle(X, Y, WIDTH, HEIGHT, LAYER=0, LINETYPE_SCALE=1):
rectangle = acad.model.AddLightWeightPolyline(aDouble(
X, Y,
X, Y + HEIGHT,
X + WIDTH, Y + HEIGHT,
X + WIDTH, Y,
X, Y
))
rectangle.Layer = LAYER
rectangle.LinetypeScale = LINETYPE_SCALE
return rectangle
def Square(X, Y, WIDTH, LAYER=0, LINETYPE_SCALE=1):
square = acad.model.AddLightWeightPolyline(aDouble(
X, Y,
X, Y + WIDTH,
X + WIDTH, Y + WIDTH,
X + WIDTH, Y,
X, Y
))
square.Layer = LAYER
square.LinetypeScale = LINETYPE_SCALE
return square
def Circle(X, Y, RADIUS, LAYER=0, LINETYPE_SCALE=1):
circle = acad.model.AddCircle(APoint(X, Y), RADIUS)
circle.Layer = LAYER
circle.LinetypeScale = LINETYPE_SCALE
return circle
def Polyline(POINTS, LAYER=0, LINETYPE_SCALE=1):
polyline = acad.model.AddLightWeightPolylin(aDouble(POINTS))
polyline.Layer = LAYER
polyline.LinetypeScale = LINETYPE_SCALE
return polyline