designcoding
Search
About Table of Contents Keywords Support designcoding!

Display Method for Vector Class

August 17, 2021 | Views: 2952
Design Mathematics | Linear Algebra | Rhino Python
object classes | vector

Let’s continue from the Vector class that started yesterday. Previously, I defined this class to store three numbers (coordinates), named as “components”. I defined a method named __init__ for this. Similarly, I am adding a display method to the Vector class today. Note that I am using Rhino 6 in this code, but it should also work in Rhino 5 or 7.

The code

import rhinoscriptsyntax as rs
class Vector:
	def __init__(self, point):
		self.components = point
	def display(self):
		line = rs.AddLine([0,0,0], self.components)
		rs.CurveArrows(line, 2)
v = Vector([2,2,0])
v.display()

Below is the line-by-line explanation of the method:

LineExplanation
1-4Already explained before.
5Start the definition of a new method named “display” within the Vector class. This method will not take any inputs yet. “self” is for syntax purposes, representing the object instance we are working with.
6Here, we define a variable named “line”. This variable will hold the result of a command executed in “rs”, which is the library of commands in Rhino. From the rs module, we are firing the “AddLine” method. To get help about the methods inside the rs module: you can use this reference. As you see, the AddLine method has two inputs. The first input is the list of numbers, representing the starting point of the line. In our case, the starting point is the origin ([0,0,0]). The second input is the coordinate we hold in our vector object, which can be accessed by self.components.
7Since the result of the above operation draws a line in Rhino viewport, it also puts the ID number of the line object in a variable we named as “line”. Now, we are using this ID number to access that line and add an arrowhead to it by utilizing another rs method “CurveArrows”. If you look at the reference of this method, it also takes two inputs: the curve object, and an index number representing the placement of the arrow. Note that, checking the reference is an important habit. Because, we cannot understand what is that “2”, otherwise.

Testing the method

The last two lines of the above code are for testing purposes. Firstly, the 8th line creates one vector object by using the newly developed Vector class. Then, the last line calls the “display” method of the object, firing the new method we added. Finally, if everything is correct, you should be seeing the arrow in the Rhino viewport. For further study, you can test the method with several different vector objects. Note that the coordinates are stored in the object attribute, named “components”. Currently, it is only accepting the Rhino origin as the tail point. However, we are going to further develop this method in the next lesson.

display a vector in Rhino

That is it for today.

  • Search

  • Categories

    • Education
      • Basic Design
      • Design Geometry
      • Design Mathematics
      • Digital Fabrication
      • Parametric Modeling
      • Tutorials
    • Philosophy
      • Analytical Tradition
      • Phenomenology
    • Practice
      • 3D Models
      • Projects
      • Publications
      • Workshops
    • Research
      • 3D Printing
      • Building Facade
      • Calculus
      • Climate Analysis
      • Compass Constructions
      • Computational Geometry
      • Curves
      • Decorative Arts
      • Digital Fabrication
      • Evolutionary Solvers
      • Folding Structures
      • Fractals
      • Graph Theory
      • Interlocking Structures
      • Islamic Patterns
      • Linear Algebra
      • Minimal Surfaces
      • Muqarnas
      • Non-Euclidean Geometry
      • Paneling
      • Parametric Curves
      • Parametric Objects
      • Parametric Surfaces
      • Pattern Deformations
      • Patterns
      • Pavilions
      • Polyhedra
      • Rammed Earth Structures
      • Robotic Fabrication
      • Shape Grammars
      • Simulation
      • Space Syntax
      • Surface Constructions
      • Tessellations
      • Tools
      • Vector Fields
      • Virtual Reality
    • Tools and Languages
      • 3DS Max
      • 3DS Max Script
      • Grasshopper
      • Photoshop
      • Physical Prototyping
      • Revit
      • Rhino
      • Rhino Macro
      • Rhino Python
      • Rhino Script
      • Unity
  • Monthly Archive

    • October 2025 (1)
    • June 2025 (2)
    • May 2025 (2)
    • April 2025 (5)
    • December 2024 (40)
    • August 2024 (5)
    • July 2024 (6)
    • April 2024 (4)
    • March 2024 (10)
    • February 2024 (10)
    • January 2024 (8)
    • December 2023 (10)
    • August 2023 (3)
    • July 2023 (3)
    • June 2023 (7)
    • May 2023 (8)
    • April 2023 (7)
    • March 2023 (2)
    • February 2023 (2)
    • January 2023 (3)
    • December 2022 (6)
    • November 2022 (7)
    • January 2022 (1)
    • December 2021 (1)
    • October 2021 (3)
    • September 2021 (4)
    • August 2021 (4)
    • May 2019 (2)
    • April 2019 (1)
    • March 2019 (5)
    • January 2019 (2)
    • December 2018 (1)
    • November 2018 (4)
    • October 2018 (9)
    • July 2018 (1)
    • June 2018 (4)
    • May 2018 (1)
    • April 2018 (4)
    • February 2018 (2)
    • January 2018 (7)
    • August 2017 (9)
    • July 2017 (6)
    • October 2016 (1)
    • May 2015 (5)
    • April 2015 (8)
    • March 2015 (12)
    • February 2015 (4)
    • January 2015 (11)
    • November 2014 (1)
    • August 2014 (1)
    • June 2014 (2)
    • May 2014 (12)
    • April 2014 (5)
    • March 2014 (3)
    • February 2014 (6)
    • January 2014 (4)
    • December 2013 (5)
    • November 2013 (11)
    • October 2013 (2)
    • September 2013 (9)
    • August 2013 (4)
    • July 2013 (2)
    • June 2013 (14)
    • May 2013 (4)
    • April 2013 (10)
    • March 2013 (11)
    • February 2013 (11)
    • January 2013 (10)
    • December 2012 (10)
    • November 2012 (6)
    • October 2012 (13)
    • September 2012 (2)
    • August 2012 (5)
    • July 2012 (14)
    • June 2012 (6)
    • May 2012 (17)
    • April 2012 (15)
    • March 2012 (9)
    • February 2012 (16)
    • January 2012 (18)
    • December 2011 (20)
    • November 2011 (2)
  • Support designcoding!

    Enjoying designcoding? Support its future with a small donation on Patreon. Thank you!

    Patreon


    copyright 2026 designcoding.net | about | table of contents | keywords | privacy policy | end user license agreement