Grasshopper

algorithmic modeling for Rhino

Hello All:

Trying to put together some code that would place a sphere at each vertex of a brep and do a difference.  That alone is not difficult, but I don't want the spherical surfaces included in the resulting brep.

Attaching my code - will entertain any solutions you may have!

Cheers

Neil

polyholes.gh

Views: 1020

Replies to This Discussion

Hi Neil,

unfortunately it's very difficult. The [Trim Solid] component is supposed to do this, but it isn't working correctly. It seems that Rhino5 actually does provide tools for this, so I can fix the component, in the meantime I wrote a VB script that does this (attached), I hope it works (and I hope you can open it).

Just in case you can't open it, here's the code:

Private Sub RunScript(ByVal S As Brep, ByVal T As List(Of Brep), ByRef A As Object)
  For i As Int32 = 0 To T.Count -1
    Dim rc As Brep() = S.Split(T(i), doc.ModelAbsoluteTolerance)
    If (rc Is Nothing) Then Continue For
    If (rc.Length < 2) Then Continue For

    'We need to figure out which part of rc is the original.
    'I'm going to boldly assume in this case that it's the one with the
    'largest bounding box

    Dim maxI As Int32 = 0
    Dim maxD As Double = rc(0).GetBoundingBox(True).Diagonal.Length
    For k As Int32 = 1 To rc.Length - 1
      Dim localD As Double = rc(k).GetBoundingBox(True).Diagonal.Length
      If (localD > maxD) Then
        maxD = localD
        maxI = k
      End If
    Next

    S = rc(maxI)
  Next

  A = S
End Sub

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:

I just added the new logic to Trim Solid, so come the next version this will be easy, but until then you'll need the VB component.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Many thanks David!  I appreciate the reply!

Neil

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service