Grasshopper

algorithmic modeling for Rhino

Hello all,

 

I'm trying to override the GH_ComponentAttributes Render method for a custom component, but struggling to render the wires. I know the SDK gives a custom parameter example using GH_Attributes<T> , but it doesn't require any incoming wires to be rendered. 

 

I've tried getting all the sources from each Owner.Params.Input (see below), but no joy. Does anyone know how to render the wires correctly for a component? Struggling to figure it out.

 

protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)

{
  if (channel == GH_CanvasChannel.Wires)
   {
   for (int i = 0; i < Owner.Params.Input.Count; i++)
     {
     RenderIncomingWires(canvas.Painter, Owner.Params.Input[i].Sources, Owner.Params.Input[i].WireDisplay);
     }
   return;
   }

   //some custom stuff here...

}

 

Many thanks,

 

John.

Views: 894

Replies to This Discussion

Hi John,

if your attributes derive from GH_ComponentAttributes, all you have to do is call the base class Render method and all wires will be drawn. Is this not an option?

--

David Rutten

david@mcneel.com

Poprad, Slovakia

But of course. I think I was overly keen to use RenderIncomingWires somehow as per your GH_Param example! Thank you David.

protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
{
  if (channel == GH_CanvasChannel.Wires){
    base.Render(canvas, graphics, channel);
  }

  if (channel == GH_CanvasChannel.Objects)
  {

    ... custom object stuff here

  }

}

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service