logo

Big_Bird_PipeRebuilder

Option Explicit

'Script written by Luis Quinones
'www.luisquinonesdesign.com
'www.computationalmatter.com
'Script version Wednesday, May 18, 2011 12:51:12 PM

Call Main()

Sub Main()    

    Dim strLayer : strLayer = Rhino.AddLayer("Frame",RGB(255,255,255))
    Dim strMesh : strMesh = Rhino.GetObject("MESH",32)        
    Dim i    
    Dim arrFaces : arrFaces = Rhino.MeshFaces(strMesh)    
    Dim arrFace(3)    
    Rhino.EnableRedraw False
    Do While i < Ubound(arrFaces)                
        arrFace(0) = arrFaces(i)
        arrFace(1) = arrFaces(i+1)
        arrFace(2) = arrFaces(i+2)
        arrFace(3) = arrFaces(i+3)                
        Dim newLine : newLine = Rhino.AddLine(arrFace(0),arrFace(1))                
        Call Rhino.ObjectLayer(newLine,strLayer)                        
        i = i + 4        
    Loop        
    Dim crvs : crvs = Rhino.ObjectsByLayer("Frame",True)    

    Rhino.Command "Join"    
    Rhino.UnselectAllObjects        
    Dim crv
    Dim count    
    count = 0    
    Dim arrCrvstest : arrCrvstest = Rhino.ObjectsByLayer("Frame")    
    Dim y
    Dim testCrv
    Dim count2        
    count2 = 0
    For Each testCrv In arrCrvstest                    

        Dim meshtest : meshtest = Rhino.MeshPolyline(arrCrvstest(count2))        
        Dim areatest : areatest = Rhino.MeshArea(meshtest)            
        If areatest(1) = 0  Then            
            Call Rhino.Print("ONE FAILED")
            Call Rhino.DeleteObject(arrCrvstest(count2))            
        End If        
        count2 = count2 + 1        
    Next     
    Rhino.UnselectAllObjects        
    Dim arrCrvs : arrCrvs = Rhino.ObjectsByLayer("Frame")    
    Dim newPts()

    For Each crv In arrCrvs                
        Dim mesh : mesh = Rhino.MeshPolyline(arrCrvs(count))        
        ReDim Preserve newPts(count)
        Dim centroid : centroid = Rhino.MeshAreaCentroid(mesh)            
            newPts(count) = Rhino.AddPoint(centroid)        
        count = count + 1        
    Next    
    Dim k    
    Dim ptloc    
    ptloc = newPts    
    For k = 0 To Ubound(newPts)        
        ptloc(k) = Rhino.PointCoordinates(newPts(k))        
    Next        
    Call Rhino.AddPolyline(ptloc)
    Rhino.EnableRedraw True
End Sub
Update
  • Share