Skip to content

Instantly share code, notes, and snippets.

@Alliages
Created April 19, 2017 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alliages/230f3bf873c014720355dfc4eb0504b6 to your computer and use it in GitHub Desktop.
Save Alliages/230f3bf873c014720355dfc4eb0504b6 to your computer and use it in GitHub Desktop.
Rhinoscript Planarization of surfaces
Option Explicit
'Script written by Guillaume Meunier
'Script copyrighted by Guillaume Meunier
'Script version Wednesday, April 12, 2017 1:14:09 PM
'try to Planarize objects
Call Main()
Sub Main()
Dim nSurf, arr, strSurf, count, arrObjects, strCurve, num_Type, res
arrObjects = Rhino.SelectedObjects
If IsArray(arrObjects) Then
arr = arrObjects
Rhino.UnselectObjects arrObjects
Else
arr = Rhino.ObjectsByType(8 + 16)
End If
count = 0
For Each strSurf In arr
num_Type = Rhino.ObjectType(strSurf)
'Rhino.Print num_Type
Do While True
If num_Type <> 8 And num_Type <> 16 Then Exit Do
strCurve = Rhino.DuplicateEdgeCurves(strSurf)
res = Rhino.AddPlanarSrf(strCurve)
If IsNull(res) Then
Print "Null"
Else
'Rhino.Print CStr(res)
count = count + 1
End If
'Rhino.DeleteObjects(strCurve)
Exit Do
Loop
Next
Call Rhino.SelectObjects(arr)
Rhino.Print "DONE " & CStr(count) & " times"
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment