Grasshopper

algorithmic modeling for Rhino

Is it possible to perform the "Text Tag" component funtion in VB?

Here is what I am trying to do. I have a list of lines with varying lengths in a VB component. I would like to display the lengths of each line in the rhino canvas. The obstacle is this...it is my intention to avoid the use of the GH components as much as possible, as others that will be using the GH script are not as familiar with the interface.

Ultimately, I will create a component that requires only the input/setting of a single point, and all of the geometry is created and controlled by sliders(integers and doubles).

Views: 1146

Replies to This Discussion

Hi Pierre,

you want to draw 3D text in the Rhino viewports from inside a custom component? I assume it's a GHA project written in VB.NET?

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Yes, this is correct. At the moment, I have written much of the code that creates the geometry in the grasshopper VB component as a test, just to verify that what I am trying to do can be coded in VB.
Ultimately, I will transfer this info into visual studio and create GHA project. I have already gone over the insructions and general process in the grasshopper SDK.

In case you cannot open the attached gh file, I also posted the VB code.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:
Thanks,

I got text to appear within a circle, I also added a new plane to the String.format plane argument.

I am still fairly new to VB scripting, so I do have some questions about the structure of the script. I noticed that you create two override methods. I don't see where you call the methods. Why is it that these methods do not need to be called? Also, there is no output (i.e. A=tags). I'm just curious as to how this code works.

I wasn't using A, I probably should have removed the output altogether.

I'm not calling the overrides, just as the script itself doesn't call RunScript. The script component calls both the RunScript and preview methods. You can add skeleton preview methods using the button in the top-right corner of the script editor window.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Also, what is runCount? I can find it in the Grasshopper SDK or RhinoCommon SDK.

runCount enumerates the iteration of the RunScript (i.e. how often it has been called) within this solution. It therefore provides an easy way to do something once -and only once- within a single solution. In the Grasshopper SDK this information is provided by IGH_DataAccess.Iteration

The first time the RunScript method is called the runCount equals zero. Then it is incremented every time. There's no way of knowing what the last call to RunScript is going to be.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks,
One last thing. How do I change the precision of the text output value? As of now, if I have a line that measures as 8.25 this script outputs the integer value of 8. I would like to output a floating decimal to 1/100th (i.e. 1.00)
Figured it out, thanks for all of the help! Works great

Dim radius As Double = c.Radius
Dim radString As String
radString = Format(radius, "f")


Dim tag As New Rhino.Display.Text3d(radString, y, C.Radius * .25)
tags.Add(tag)
box.Union(tag.BoundingBox)
Ok, I am still working on this one.

The text text tag works fine if I add this into the vb component. When I add this into Visual Studio to create a component, it doesn't work. Not only that, but it causes the rest of my geometry to dissappear. Any suggestions?

If I take the code for the text tag out of the VB project, everything else works perfectly.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service