Intro to Python Scripting: 19 Simple Class
This is a very simple and somewhat useless class definition to create a line from two points. It does cover some basics of class creation in Python and is a stepping stone to some more interesting classes we will create later. You can find more info about classes in the Python documentation.
import rhinoscriptsyntax as rs class MyLine: def __init__(self, pt1, pt2): self.pt1 = pt1 self.pt2 = pt2 def makeLine(self): rs.AddLine(self.pt1,self.pt2) line1 = MyLine([0,0,0], [2,2,2]) line1.makeLine() line2 = MyLine([2,0,0], [2,2,2]) line2.makeLine()
Want to Contribute?
Want to be an author? Drop us a line here we'd love to have you.
Already have a video you'd like to post? Send us a link and we'll get you going.