Dynamo 标准几何体库中最简单的几何对象是一个点。所有几何体均使用称为构造函数的特殊函数创建,每个函数都返回该特定几何体类型的新实例。在 Dynamo 中,构造函数以对象类型的名称(在本例中为“Point”)开始,然后是构造方法。要创建由 x、y 和 z 笛卡尔坐标指定的三维点,请使用 ByCoordinates 构造函数:
// create a point with the following x, y, and z
// coordinates:
x = 10;
y = 2.5;
z = -6;
p = Point.ByCoordinates(x, y, z);
Dynamo 中的构造函数通常使用前缀为“By”指定,调用这些函数将返回该类型的新创建对象。此新创建的对象存储在等号左侧命名的变量中。
// create a point on a sphere with the following radius,
// theta, and phi rotation angles (specified in degrees)
radius = 5;
theta = 75.5;
phi = 120.3;
cs = CoordinateSystem.Identity();
p = Point.BySphericalCoordinates(cs, radius, theta,
phi);
// create two points:
p1 = Point.ByCoordinates(3, 10, 2);
p2 = Point.ByCoordinates(-15, 7, 0.5);
// construct a line between p1 and p2
l = Line.ByStartPointEndPoint(p1, p2);