Grasshopper

algorithmic modeling for Rhino

Hello,

how can I display "helper" geometry when using a custom component? for example I have a component that creates planes from a set of data. It outputs some plane surface. I want to display the area centroid as point or whatever geometry, but I don't need it as an input.

Can I do that ? 

Views: 356

Replies to This Discussion

Hi raf,

 

"but I don't need it as an input." Did you mean output? I'm a wee bit confused.

 

I take it you're writing a GHA library (or are you writing a VB/C# Script component?) and you want to draw extra stuff in the Rhino viewports, a bit similar to the BiArc component which draws the little arrows at the arc-seams?

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Hi David,

sorry I meant output. Yes I am writting GHA library in C# and I would like to draw extra stuff in the rhino viewports ...similar to the BiArc component...

You need to override the DrawViewportWires() method on your Component. Make sure you place a call to the base class method, otherwise you'll disable all the existing previews.

 

You should also check the Hidden flag to make sure you don't draw when the preview for your component has been disabled.

 

Public Overrides Sub DrawViewportWires(byval args As IGH_PreviewArgs)

  MyBase.DrawViewportWires(args)

  If (Hidden) Then Return

 

  'Draw your extra geometry here. You can use args.Display to get access to the current display pipeline

End Sub

 

You can collect all your preview data from within the SolveInstance() method. For example:

 

private m_extraPoints As New List(Of Point3d)

Protected Overrides Sub SolveInstance(ByVal DA As IGH_DataAccess)

  If (DA.Iteration = 0) Then

    'This is the first time the SolveInstance method is called for this solution

    m_extraPoints.Clear()

  End If

  ....

  m_extraPoints.Add(SurfaceAreaCentroidPoint)

End Sub

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

 

thanks !

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service