Legend Parameters 2D - custom legend in HUD

Hi,

Great release with the 1.6.0 version!
As always, with new features come new feature requests / questions :wink:

I have a few custom legends that I’d love to display in the HUD as well. Say for example this one with the custom daylight factor threshold lines below the legend.

In this case, the lines and extra text are just displayed with native Custom Preview and Text Tag 3D components, but I don’t know how to go about that with the visualization set / HUD. How can I tap into the Legend Parameters 2D / HUD functionality?

Kind regards,
Marc

Hey @marctavenier ,

You can probably pull this off if you’re willing to edit the source code a little. The two main RhinoCommon methods that are being used to draw the HUD legend are DisplayPipeline.Draw2dText and DisplayPipeline.DrawSprite. You can see here inside the Preview VisualizationSet component, the arguments are being passed to those methods of the DisplayPipeline:

So, you could try adding some extra arguments into self.vis_con.draw_2d_text there for your custom text. Or you could make your own separate component that overwrites these methods.

If you do the latter, I found this post from @piac to be very helpful:

1 Like

Sorry to tack on to this thread but I feel this solution may be relevant to my question. So I’ve got various legends that I’ve generated from the [LB Direct Sun Hours] component, and from the [LB Create Legend] component. Can I not use the [Legend Parameters 2D] component to translate either of these into a 2D Legend, or does the legend have to be derived from one of the {Visualize Data} components? I’ve tried various native ways to achieve this, but if I’m understanding this thread correctly, I would need to edit the Python source code to achieve the desired result? Either that or I’m misunderstanding how the component works (which is what I hope)!

Hey @realrhino1 ,

You are correct that there’s not really a way to use the LB Create Legend component to make a custom screen-oriented legend. But what you are asking for here does not require a huge amount of code and it sounds generally useful. Let me think about the best way to implement this but we can probably add an official component for it.

1 Like

FYI, @realrhino1 ,

I added an option for 2D legend parameters on the “LB Create Legend” component.

So you can now use it to create custom screen-oriented legends like so:

The component should be available with the LB Versioner within an hour or so.

4 Likes

Thank you so much for the amazingly quick response! Looking forward to implementing this in my scripts!

Hi @chris,
Want to report a bug in the above workflow: When you set the continuous_leg input to true the colors are inverted, like so:

Thanks,
-A.

Hi @chris,
Just in case this fell into the cracks …
Thanks,
-A.

Thanks for the reminder, @AbrahamYezioro . This is a bug, indeed. I just added a fix:

I’ll try to make sure that it becomes available via the LB Versioner by the end of tomorrow at the latest. If our CI runs smoothly, it may be available in as early as an hour.

2 Likes

Working just fine.
Thanks,
-A.

2 Likes

There might be a small bug. I can get the numeric part of the legend to show as a HUD, but the colored mesh doesn’t show up…I’m on 1.8 and on a mac

thanks