Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:scriptsamples:explodemesh [2015/09/14] (current)
Line 1: Line 1:
 +====== Exploding Meshes ======
 +> **Developer:​** //​[[developer:​rhinoscript|RhinoScript]]//​
 +> **Summary:​** //How to explode a mesh into individual faces.//
 +
 +===== Overview =====
 +The following [[developer:​rhinoscript|RhinoScript]] demonstrates how to explode a mesh into individual faces. See the [[developer:​rhinoscript|RhinoScript]] help file for details on running scripts.
 +
 +<code vb>
 + ​Option Explicit
 +
 + Sub ExplodeMesh
 +   Dim mesh
 +   mesh = Rhino.GetObject("​Select mesh to explode",​ 32)
 +   If IsNull(mesh) Then Exit Sub
 +
 +   Dim faces
 +   faces = Rhino.MeshFaces(mesh,​ True)
 +   If Not IsArray(faces) Then Exit Sub
 +
 +   ​Rhino.EnableRedraw False
 +   Dim i, a, b, c, d, bQuad
 +   i = 0
 +
 +   While i <= UBound(faces)
 +     a = faces(i)
 +     b = faces(i+1)
 +     c = faces(i+2)
 +     d = faces(i+3)
 +     If c(0)=d(0) And c(1)=d(1) And c(2)=d(2) Then
 +       ​Rhino.AddMesh Array(a,​b,​c,​d),​ Array(Array(0,​1,​2,​2))
 +     Else
 +       ​Rhino.AddMesh Array(a,​b,​c,​d),​ Array(Array(0,​1,​2,​3))
 +     End If
 +     i = i + 4
 +   Wend
 +
 +   ​Rhino.DeleteObject mesh
 +   ​Rhino.EnableRedraw True
 +
 + End Sub
 +
 +
 +</​code>​
 +
 +\\
 +
 +{{tag>​Developer RhinoScript}}
  
developer/scriptsamples/explodemesh.txt ยท Last modified: 2015/09/14 (external edit)