Points


Geometric definition


A point represents a specific location in space but has no size, width, or depth. It’s often represented by a dot and labeled with a letter in diagrams. Thanks to its simplicity, a point often serves as a building block for more complex geometric structures such as lines, planes, and shapes.

How to add


As often, it is possible in Rhino to use either RhinoCommons or RhinoScriptSynthax to add a point to the Rhino workspace. Here are the two methods:

RhinoCommons


import Rhino.Geometry as rg
import scriptcontext as sc

# Parameters to create the point
x = 5
y = 5
z = 5

# Will create a point at the coordinates (x, y, z)
my_point = rg.Point3d(x, y, z)

sc.doc.Objects.AddPoint(my_point)


RhinoScriptSynthax


import rhinoscriptsyntax as rs

# Parameters to create the point
x = 5
y = 5
z = 5

# Will create and add to the workspace a point at the coordinates (x, y, z)
my_point = rs.AddPoint(x, y, z)

Main methods, properties and operators


Methods


Among the main methods we have:

# Will create a point by adding the coordinates of the two points p1 and p2
point_C = rg.Point3d.Add(point_A, point_B) 

# Will calculate the distance between p1 and p3
dist = point_C.DistanceTo(point_A)

Properties


Among the main properties, we have:

# Will retrieve the X coordinate of the point
x = my_point.X 

# Will retrieve the Y coordinate of the point
y = my_point.Y 

# Will retrieve the Z coordinate of the point
z = my_point.Z 

Operators


Point objects also have some very useful operators:

# points to which we will apply the operators
point_A = Rhino.Geometry.Point3d(0, 0, 0)
point_B = Rhino.Geometry.Point3d(1, 1, 1)

# Will add the coordinates of p1 and p2 respectively, to create p3
point_C = point_A + point_B

# Will substract the coordinates of p1 and p2 respectively, to create p3
point_C = point_A - point_B

# Will create p3 by taking the opposite of the coordinates of p2
point_A =  -point_B

# Will multiply the coordinates of p1 by 2, to create p3
point_A = 2*point_B

# Will divide the coordinates of p1 by 2, to create p3
point_A = point_B/2


🛠 Exercise


01: 🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍

Solution:

01: 🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍