Dynamo
Primer for v2.0
繁體中文
繁體中文
  • 關於
  • 簡介
    • 什麼是 Dynamo?它如何運作?
    • 手冊使用者指南、Dynamo 社群與平台
  • 安裝 Dynamo
  • 使用者介面
    • 工作區
    • 資源庫
  • 節點和線路
  • 基本節點和概念
    • 節點的索引
    • 用於計算設計的幾何圖形
      • 幾何圖形概述
      • 向量、平面和座標系統
      • 點
      • 曲線
      • 曲面
      • 實體
      • 網格
    • 程式的建置區塊
      • 資料
      • 數學
      • 邏輯
      • 字串
      • 顏色
    • 使用清單設計
      • 什麼是清單
      • 使用清單
      • 清單的清單
      • n 維清單
    • Dynamo 中的字典
      • 什麼是字典
      • 字典節點
      • 程式碼區塊中的字典
      • Revit 使用情況
  • 自訂節點和套件
    • 自訂節點
      • 自訂節點簡介
      • 建立自訂節點
      • 發佈至資源庫
    • 套件
      • 套件簡介
      • 套件案例研究 - Mesh Toolkit
      • 開發套件
      • 發佈套件
      • Zero-Touch 匯入
  • 適用於 Revit 的 Dynamo
    • Revit 連接
    • 選取
    • 編輯
    • 建立
    • 自訂
    • 記錄
  • Dynamo for Civil 3D
    • Civil 3D 連接
    • 入門
    • 節點資源庫
    • 範例工作流程
      • 道路
        • 燈柱放置
      • 面
        • 服務放置
      • 公用程式
        • 更名結構
      • 鐵路
        • 間隙包絡線
      • 測量
        • 點群組管理
    • 進階主題
      • 物件併入
      • Python 和 Civil 3D
    • Dynamo 播放器
    • 有用的套件
    • 資源
  • Dynamo in Forma Beta 版
    • 設定 Forma 中的 Dynamo Player
    • 在 Dynamo Player 中加入和分享圖表
    • 在 Dynamo Player 中執行圖表
    • Dynamo 計算服務與桌面版 Dynamo 的差異
  • 在 Dynamo 中撰寫程式碼
    • 程式碼區塊和 DesignScript
      • 什麼是程式碼區塊
      • DesignScript 語法
      • 速寫
      • 函數
    • 使用 DesignScript 的幾何圖形
      • DesignScript 幾何圖形基礎知識
      • 幾何基本型
      • 向量數學
      • 曲線:內插和控制點
      • 平移、旋轉和其他轉換
      • 曲面:內插、控制點、斷面混成、迴轉
      • 幾何參數化
      • 交集和修剪
      • 幾何布林運算
      • Python 點產生器
    • Python
      • Python 節點
      • Python 和 Revit
      • 設定您自己的 Python 樣板
    • 語言變更
  • 最佳實踐
    • 圖表策略
    • 指令碼撰寫策略
    • 指令碼撰寫參考
    • 管理您的程式
    • 在 Dynamo 中有效率地處理大型資料集
  • 範例工作流程
    • 入門工作流程
      • 參數式花瓶
      • 牽引點
    • 概念索引
  • 開發人員手冊
    • 從原始碼建置 Dynamo
      • 從原始碼建置 DynamoRevit
      • 管理和更新 Dynamo 中的相依性
    • 為 Dynamo 開發
      • 入門
      • Zero-Touch 案例研究 - 網格節點
      • 在 Zero-Touch 節點中執行 Python 指令碼 (C#)
      • 深入瞭解 Zero-Touch
      • 進階 Dynamo 節點自訂
      • 在 Dynamo 套件中使用 COM (互通性) 類型
      • NodeModel 案例研究 - 自訂使用者介面
      • 針對 Dynamo 2.x 更新您的套件和 Dynamo 資源庫
      • 針對 Dynamo 3.x 更新套件與 Dynamo 資料庫
      • 延伸
      • 定義 Dynamo 2.0+ 的自訂套件組織
      • Dynamo 指令行介面
      • Dynamo 整合
      • 為 Dynamo for Revit 開發
      • 發佈套件
      • 從 Visual Studio 建置套件
      • 將延伸當作套件
    • 提取請求
    • 測試預期結果
    • 範例
  • 附錄
    • 常見問題
    • 視覺程式設計和 Dynamo
    • 資源
    • 發行說明
    • 有用的套件
    • 範例檔案
    • 主體程式整合對應表
    • 下載 PDF
    • Dynamo 鍵盤快速鍵
Powered by GitBook
On this page
  • 座標系統 (CoordinateSystem)
  • 點 (Point)
  • 直線 (Line)
  • 3D 基本型 - 立方體、圓錐、圓柱、圓球等
Edit on GitHub
Export as PDF
  1. 在 Dynamo 中撰寫程式碼
  2. 使用 DesignScript 的幾何圖形

幾何基本型

PreviousDesignScript 幾何圖形基礎知識Next向量數學

Last updated 2 years ago

座標系統 (CoordinateSystem)

雖然 Dynamo 能夠建立各種複雜幾何形狀,但是簡單的幾何基本型是構成任何計算設計的骨架:無論是以最終設計的形式直接表示,或是用來做為產生更複雜幾何圖形的鷹架。

雖然 CoordinateSystem 嚴格來說不算是一個幾何圖形,但卻是建構幾何圖形的一個重要工具。一個 CoordinateSystem 物件可以同時追蹤位置和幾何的轉換,例如旋轉、切變和調整比例。

建立一個中心點位於 x=0,y=0,z=0 的 CoordinateSystem (沒有旋轉、調整比例或切變轉換),只需要呼叫 Identity 建構函式:

// create a CoordinateSystem at x = 0, y = 0, z = 0,
// no rotations, scaling, or sheering transformations

cs = CoordinateSystem.Identity();

具有幾何轉換的 CoordinateSystem 超出本章節的範圍,不過有另一個建構函式 CoordinateSystem.ByOriginVectors 可以讓您在特定的點建立座標系統:

// create a CoordinateSystem at a specific location,
// no rotations, scaling, or sheering transformations
x_pos = 3.6;
y_pos = 9.4;
z_pos = 13.0;

origin = Point.ByCoordinates(x_pos, y_pos, z_pos);
identity = CoordinateSystem.Identity();

cs = CoordinateSystem.ByOriginVectors(origin,
    identity.XAxis, identity.YAxis, identity.ZAxis);

點 (Point)

最簡單的幾何基本型是一個點 (Point),代表三維空間中的一個零維位置。如先前所述,在特定座標系統中建立一個點有幾種不同的方式:Point.ByCoordinates 以指定的 x、y、z 座標建立一個點;Point.ByCartesianCoordinates 在特定座標系統中以指定的 x、y、z 座標建立一個點;Point.ByCylindricalCoordinates 在有半徑、旋轉角度和高度的圓柱上建立一個點;Point.BySphericalCoordinates 在有半徑和兩個旋轉角度的圓球上建立一個點。

本範例會顯示在各種座標系統建立的點:

// create a point with x, y, and z coordinates
x_pos = 1;
y_pos = 2;
z_pos = 3;

pCoord = Point.ByCoordinates(x_pos, y_pos, z_pos);

// create a point in a specific coordinate system
cs = CoordinateSystem.Identity();
pCoordSystem = Point.ByCartesianCoordinates(cs, x_pos,
    y_pos, z_pos);

// create a point on a cylinder with the following
// radius and height
radius = 5;
height = 15;
theta = 75.5;

pCyl = Point.ByCylindricalCoordinates(cs, radius, theta,
    height);

// create a point on a sphere with radius and two angles

phi = 120.3;

pSphere = Point.BySphericalCoordinates(cs, radius,
    theta, phi);

直線 (Line)

下一個較高維度的 Dynamo 基本型是線段,代表兩個端點之間有無限個點。使用 Line.ByStartPointEndPoint 建構函式明確指出兩個邊界點,或使用 Line.ByStartPointDirectionLength 建構函式指定起點、方向和沿著該方向的長度,可以建立直線。

p1 = Point.ByCoordinates(-2, -5, -10);
p2 = Point.ByCoordinates(6, 8, 10);

// a line segment between two points
l2pts = Line.ByStartPointEndPoint(p1, p2);

// a line segment at p1 in direction 1, 1, 1 with
// length 10
lDir = Line.ByStartPointDirectionLength(p1,
    Vector.ByCoordinates(1, 1, 1), 10);

3D 基本型 - 立方體、圓錐、圓柱、圓球等

Dynamo 有幾個物件,代表三維的幾何基本型的最基本類型:使用 Cuboid.ByLengths 建立的立方體 (Cuboid);使用 Cone.ByPointsRadius 和 Cone.ByPointsRadii 建立的圓錐 (Cone);使用 Cylinder.ByRadiusHeight 建立的圓柱 (Cylinder);以及使用 Sphere.ByCenterPointRadius 建立的圓球 (Sphere)。

// create a cuboid with specified lengths
cs = CoordinateSystem.Identity();

cub = Cuboid.ByLengths(cs, 5, 15, 2);

// create several cones
p1 = Point.ByCoordinates(0, 0, 10);
p2 = Point.ByCoordinates(0, 0, 20);
p3 = Point.ByCoordinates(0, 0, 30);

cone1 = Cone.ByPointsRadii(p1, p2, 10, 6);
cone2 = Cone.ByPointsRadii(p2, p3, 6, 0);

// make a cylinder
cylCS = cs.Translate(10, 0, 0);

cyl = Cylinder.ByRadiusHeight(cylCS, 3, 10);

// make a sphere
centerP = Point.ByCoordinates(-10, -10, 0);

sph = Sphere.ByCenterPointRadius(centerP, 5);