algorithmic modeling for Rhino
Hi All,
I'm in the process of developing a few components in VS and had a few questions.
1) On a custom component is it possible to dynamically add input parameters such as the scripting components? If so, how? (See Image 1)
2) On a custom component is is possible to make edits to the right click menu to add custom feature? (See Image 2)
3) I want to create a component that displays a series of text on the screen similar to the TEXT TAG (3D) component. I've tried using the TextEntity class and the TextDot class but no success. (See Image 3)
Thanks in advance for any advice.
Cheers,
Tags:
Hi Charles,
1 & 2) http://www.grasshopper3d.com/forum/topics/creating-a-component-with-a
3) You have to write your own Display ovverride and feed it with the 3dText like so:
public override void DrawViewportMeshes(IGH_PreviewArgs args)
{
args.Display.Draw3dText("text", Color.Black, plane, height, "Arial");
}
The rest you should get on your own.
TextEntity and TextDot will not display in Grasshopper, because they're not handled by Grasshopper. Would be nice though if you can output them anyway, because on my next update of the FabTools there will be the option of displaying them on all those bake components.
Cheers
FF
Thanks Florian!! I'll give it a shot.
Cheers,
[C]
Hi Florian,
I've tried the above override but I keep getting an error saying "object reference not set to an instance of an object" I tried a couple of different options, with the same results.
Dim args As igh_previewargs = Nothing
args.Display.Draw3dText("hello", color.Black, plane.WorldXY, 100, "Arial")
Dim t1 As New Rhino.Display.Text3d(Text, Plane.WorldXY, 100)
args.Display.Draw3dText(t1,Drawing.Color.Black)
I'm sure its a simple fix but can't figure it out.
Thanks,
[C]
Hi Charles,
the object reference error is due to the missing IGH_PreviewArgs instance. You instantiate a Nothing (or Null) which doesn't work. You should use an override of the DrawViewportWires or DrawViewportMeshes method of a GH_Component. These Methods pass an IGH_PreviewArgs instance as parameter. There is no other way. Well you can write your own display pipeline with eventhandlers, but this is much more complicated and not necessary in your case.
This is the translation to VB of the above script:
Public Overrides Sub DrawViewportMeshes(args As IGH_PreviewArgs)
args.Display.Draw3dText("text", Color.Black, plane, height, "Arial")
End Sub
This is right if you're working in VS and you want to compile your custom component. But you can also test you're approach at first in a vb script component, before you go over to VS. That example looks a bit different.
I've made you a quick example (attached). Hope this helps.
Cheers,
FF
Thanks for your feedback. I finally got back to this project. I got the text to show but now when i update the text the previous text remains. Is there some sort of update method i should be calling?
For example I have a list of numbers on a slider, and I increase the numbers, the new text appears. When I decrease the slider the old numbers remain on the screen.
Cheers,
[C]
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