Hi people,
I have just facing an issue I found that @property inheritance in Python is so complicated and it is not worth to type it. As far as I understand we can inherite all members easily except properties.
I am creating a general explanation about class members but Geometry.width dows not work as poroperty, Python think it is an argument. :
import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
# Python 2.7 does not support function overloading.
# Alternatively use this package: https://pypi.org/project/multipledispatch/
class Geometry(object):
# Constructor is not required
# Geometry properties: Width,Height,Name,ID,Colour,Fill colour etc.
@property
def width(self): # Property - Width
return self._width
@width.setter
def width(self, value):
self._width = value
@property
def heigh(self): # Property - Height
return self._height
@width.setter
def heigh(self, value):
self._height = value
@property
def name(self,string): # Property - Name
string = "Geometry"
@width.setter
def heigh(self, value):
self._height = value
# Functions:
def position(self): # Function - Position
position = rs.GetPoint ( "Position of the geometry", None, None, False )
def info(self): # Function - Info
text = "This is a two dimensional object."
print text
#
class Point(Geometry):
def Draw(self,XYZ):
pass
class Line(Geometry):
def Draw(self, Point1, Point2):
pass
class Oval(Geometry):
def Draw(self):
plane = rs.WorldXYPlane()
rs.AddEllipse ( plane, Geometry.width, Geometry.height )
class Rectangle(Geometry):
def Draw(self):
pass
class Triangle(Geometry):
def Draw(self):
pass