algorithmic modeling for Rhino
Tags:
Private Sub RunScript(ByVal regions As List(Of Box), ByVal files As List(Of String), ByRef A As Object)
If (regions.Count <> files.Count) Then
Print("You must supply equal numbers of regions and filenames")
Return
End If
Dim boxes As New List(Of BoundingBox)
For Each b As Box In regions
boxes.Add(b.BoundingBox)
Next
'Iterate over all regions and filenames
For i As Int32 = 0 To files.Count - 1
doc.Objects.UnselectAll()
Dim obj_count As Int32 = 0
For Each obj As Rhino.DocObjects.RhinoObject In doc.Objects
Dim objbox As BoundingBox = obj.Geometry.GetBoundingBox(True)
If (IsInRegion(boxes(i), objbox)) Then
obj.Select(True)
obj_count += 1
End If
Next
Print("{0} objects exported to {1}", obj_count, files(i))
If (obj_count > 0) Then
Dim export_dir As String = IO.Path.GetDirectoryName(files(i))
If (Not IO.Directory.Exists(export_dir)) Then
IO.Directory.CreateDirectory(export_dir)
End If
Rhino.RhinoApp.RunScript(String.Format("-_Export ""{0}"" _Enter", files(i)), False)
End If
Next
End Sub
'
Private Function IsInRegion(ByVal reg As BoundingBox, ByVal box As BoundingBox) As Boolean
If (box.Max.X < reg.Min.X ) Then Return False
If (box.Max.Y < reg.Min.Y ) Then Return False
If (box.Min.X > reg.Max.X ) Then Return False
If (box.Min.Y > reg.Max.Y ) Then Return False
Return True
End Function
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by