RhinoScript 建立按鍵 Create Button

RhinoScript 建立巨集 Macros 可以使用指令巨集執行很多任務 RhinoScript 是 Rhino 3D 內建 Macro 巨集語言,包括自己定義命令或由指令行輸入、自訂工具列按鈕、快速鍵、處理複雜且重複的工作,將 RhinoScript 設置於工具列中的按鈕,提升 3D Modeling Productivity 建模效率。

! _-Runscript (
  RhinoScript...
)

! _LoadScript "C:\User\Documents\RhinoScript\Example.rvb"

RhinoScript 用於 Rhinoceros 3D 的語言,可以自動化許多不同的任務,根據需求進行定義流程和功能提高工作效率,從創建幾何圖形到執行複雜的建模運算。在 RhinoScript 編輯器中創建 Script 文件,使用 VBScript 語言來編寫腳本,發現他還可以把 Microsoft 經典版程式 Class ASP Beautifier 自動格式化。協助自動化許多相同重複輸入任務。只要熟悉 VBScript 語言和 Rhino 3D 軟件的 API 可以使用 RhinoScript 創建各種自定義工具和插件,以滿足實際工作上具體需求。


RhinoScript 匹配到指定物件的顏色

Match Object Color to Select 當使用顏色來區分模型時,因為又新增一個模型且需要與原本的顏色相同,用顏色區分主要是方便可以使用 ('_SelColor) Select by Color 配合鎖定或隱藏。當然也可以使用圖層區分。

Dim multipleObjects, strObject, objColor, selObjects

SelectedObjects 如果當前已經選擇目標物件,則直接指定匹配的物件。如果沒有再進行 GetObjects 來選取希望的物件。

multipleObjects = Rhino.SelectedObjects
If Not IsArray(multipleObjects) Then
  multipleObjects = Rhino.GetObjects("Select objects to change color")
End If
If IsArray(multipleObjects) Then
  selObjects = Rhino.GetObject("Select objects color")
  objColor = Rhino.ObjectColor(selObjects)
  Rhino.Print "Color : " & objColor
  If IsNumeric(objColor) Then
    For Each strObject In multipleObjects
      Rhino.ObjectColor strObject, objColor
    Next
  End If
End If



Rhinoceros - Tools「工具」> RhinoScript「巨集指令碼」> Run「執行巨集指令碼」。

處理多數產品且有共同的格式分別

例如一個產品分別有原始 DWG 圖形、尺寸標示、建立 3D Model 模型等相同名稱的圖層,且設置圖層的顏色。

Rhino.Print "New Produc Layer:" & Rhino.AddLayer("BR250G::BR250G-DIM", RGB(255, 0, 255))
Rhino.Print "New Produc Layer:" & Rhino.AddLayer("BR250G::BR250G-DWG", RGB(255, 0, 255))
Rhino.Print "Colored Layer:" & Rhino.LayerColor("BR250G-DIM", RGB(0, 128, 255))
Rhino.Print "Colored Layer:" & Rhino.LayerColor("BR250G-DWG", RGB(255, 255, 0))


設置圖層的顏色(經由已經選擇的圖層)

已經選擇的 SelectedLayers 圖層、可以按下 Shift 複選圖層。返回陣列 Array 當前在 Rhino 界面中選擇的圖層的標識符。

Dim arrLayers, strId, strLayer
arrLayers = Rhino.SelectedLayers
If IsArray(arrLayers) Then
  For Each strId In arrLayers
    strLayer = Rhino.LayerName(strId)
    Rhino.Print "Colored Layer:" & Rhino.LayerColor(strLayer, RGB(170, 110, 220))
    Call Rhino.Print(strLayer)
  Next
End If


設置圖層的顏色(名稱符合 InStr 指定的圖層)「區分大小寫」

InStr() 比較字串、例如 "DIM" 字串 String,將一個字串由左而右與另一個比較,傳回第一個相同的位置。InStr() 沒有符合搜尋結果回傳 0

Dim arrLayers,strLayer, i
Call Rhino.SelectLayers(null)
arrLayers = Rhino.LayerIds
For i = 0 to UBound(arrLayers)
  strLayer = Rhino.LayerName(arrLayers(i))
  If InStr(strLayer, "DIM") > 0 Then
    Rhino.Print "Colored Layer:" & Rhino.LayerColor(strLayer, RGB(170, 110, 220))
  End If
Next

RGB JavaScript, HSV 或 HSL 色碼轉換 RGB




Select Curves Length 選擇指定長度

Rhino.IsCurve(), Rhino.CurveLength()

選擇指定長度,或說是選擇相同長度的 Curves 例如孔洞的曲線、散熱孔、同尺寸的螺絲孔等。

Dim arrAllObjects, selectObject, curvelLength, intCount
intCount = 0
selectObject = Rhino.GetObject("Select Object")
curvelLength = Rhino.CurveLength(selectObject)
Rhino.Print "Select Curves Length: " & CStr(curvelLength)
arrAllObjects = Rhino.AllObjects
If IsArray(arrAllObjects) Then
  For Each strObject In arrAllObjects
    If Rhino.IsCurve(strObject) And Rhino.CurveLength(strObject) = curvelLength Then
      Rhino.SelectObject(strObject)
      intCount = intCount + 1
    End If
  Next
  Rhino.Print "Curves Selected: " & CStr(intCount)
End If


Rhinoceros 3D 工業設計應用

使用 Rhinoceros 3D 在工業設計領域的快速應用時,可以運用基於 NURBS 快速三維建模 Surface Creation 表面創建 Curves Editable 曲線和 Geometric Continuity 幾何連續性或是 XNurbs Rhino 設計工具解決 Rhino 曲面設計的問題,產品設計上能夠創造出複雜且精確建模符合實際尺寸和標準的模型、高度精細的完美配合。節省時間和成本、並且能夠透過 .STEP 與其他 CAD 軟件進行檔案轉換實現更有效的合作。例如轉換匯入 Autodesk 3ds Max 的著色,創建工業產品的模型,例如發動機、減速機、螺桿升降模組、線性馬達、齒輪和軸承、機械產品應用、汽車檢測工具配件應用模型製作、建築設計外觀圖、室內設計方案、造型藝術等設計方案。




傳動產品、電腦繪圖、3D 動畫