forked from mcneel/MOVED-rhinoscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExplodeMesh.rvb
40 lines (32 loc) · 961 Bytes
/
ExplodeMesh.rvb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ExplodeMesh.rvb -- September 2005
' If this code works, it was written by Dale Fugier.
' If not, I don't know who wrote it.
' Works with Rhino 4.0.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Sub ExplodeMesh
Dim mesh
mesh = Rhino.GetObject("Select mesh", 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