Option Explicit 'Script written by Luis Gil ' www.legil.org ''reads a .txt file from qhull (qconvex o format) and creates the convex hull ''based on the voronoi import script by Stylianos Dritsas, www.dritsas.net Call ConvexHull Sub ConvexHull Call TheGuts End Sub Function TheGuts Dim filename filename = Rhino.openfilename( "Open", "QHull Files (*.*)|*.*||" ) 'If( IsNull( filename ) ) Then Exit Function Dim filesystem Set filesystem = CreateObject( "Scripting.FileSystemObject" ) 'If( Not filesystem.fileexists( filename ) ) Then Exit Function Dim textstream Set textstream = filesystem.opentextfile( filename ) Call textstream.skipline() 'get header info Dim header header = parse(textstream.readline()) 'set number of vertices and facets from document Dim intVertCount, intFacetCount intVertCount = header(0) intFacetCount = header(1) 'store vertex positions for facet creation ReDim arrVerts(intVertCount - 1) Dim i For i = LBound(arrVerts) To UBound(arrVerts) arrVerts(i) = parse(textstream.readline()) Next 'attempt to create surfaces from facet parameters ReDim arrFacets(intFacetCount - 1) Call Rhino.EnableRedraw(False) Dim j For j = LBound(arrFacets) To UBound(arrFacets) Dim arrLine arrLine = parse(textstream.readline()) intVertCount = arrLine(0) ReDim arrOneFacet(intVertCount - 1) Dim q For q = LBound(arrOneFacet) To UBound(arrOneFacet) arrOneFacet(q) = arrVerts(arrLine(q + 1)) Next Call Rhino.AddSrfPt(arrOneFacet) Next Call Rhino.EnableRedraw(True) End Function Function parse( text ) Dim result result = Rhino.strtok( text ) Dim index For index = LBound( result ) To UBound( result ) result( index ) = Eval( result( index ) ) Next parse = result End Function