Grasshopper

algorithmic modeling for Rhino

generating terrain model from Text and 2D-Textposition-Points

Hi everyone,
I'm faced with a problem that seems to occur fairly regularly in my architecture studies.
I am trying to create a 3d terrain model from given points in a dxf-file.
Previously, when files had terrain contour lines , I made a grasshopper-file that divided these, took the division points, and in Rhino, with point set reconstruction tool, made a model via delauney triangulation.
Now, all I have is Rhino Text Objects and their position points in 2D. The Text Objects contain the z-value of the points. Is there a way to get the origin point of the text objects and the value of the text object into grasshopper in some sort of order, so that 3d points can be constructed?
Any suggestions, also as to how I can get the text objects as string into grasshopper, would be appreciated.
Thanks,
See Man

Views: 24035

Replies to This Discussion

How did you get this file with the Text object in the first place. You must have used a file with x,y and z values?
It's an oficial city plan in dxf-format and has the terrain information (terrain height) only in text.
Copy the following code to a vb.net component:

Dim ptlist As New List(Of On3dPoint)
Dim go As New MRhinoGetObject()
go.SetCommandPrompt("Select text objects")
Dim res As IRhinoGet.result = go.GetObjects(1, 0)
For i As Integer = 0 To go.ObjectCount() - 1
Dim annotation_obj As IRhinoAnnotationText = MRhinoAnnotationText.ConstCast(go.Object(i).Object())
Dim pt As New On3dPoint
pt = annotation_obj.Corner3dPoint(0)
pt.z = Convert.ToDouble(annotation_obj.String)
ptlist.Add(pt)
Next
a = ptlist

This component will ask to select the text objects that correspond to the point coordinates. Remember that every time this component is executed, it will ask again to input the text objects.
Connect the 'a' output of the vb.net component to a delaunay component.
Thanks so much for the quick response,
I will check this out immediately.
Awesome!!!!!
Thank You ever so much! This is exactly it.
And I thought I'd have to add all 1200 3d points manually :)
Hi Vicente,

I'm facing the same problem as above and at the moment I'm trying to use your VB script but I don't know how to bring the text into grasshopper. Would you be able to explain how to do that please?
Hi

I'd be interested to see a screen shot of the problem and solution if possible....could you upload the grasshopper file?
Hi Peter,
here are some shots of the problem and the solution. It's pretty straightforward. The text giving the terrain height is 2d (0 in z-axis). The script from Vicente (thanks again!!!! still works like a charm) is copied into a vb-component and connected to a delaunay component (in the latest grasshopper release).
Attachments:
WOW!

This is excellent! The answer to all those flat dxf OS plans...

Thank you also for contributing.
Hi See,

the text from the my survey file is just a normal text in rhino. how do i convert the text from the survey into text object in rhino?
thank you in advance!
Bruna :)
Hi See Man,

You can always use a rhinoscript to read all the text (you get the x,y values from the position of the textobject) and create a point from the values (the z value of the point you can get from something like:

Sub Main()

Dim arrText, textObj, arrBBox, cpt, txt, a

Rhino.Print "This script will convert text based spot heights to points"
Rhino.Print "Works with comma delimiters, re-configure if there are any spaces or Points!!!"

arrText = rhino.GetObjects("Pick textbased spot heights", 512)

Rhino.EnableRedraw False

For Each textObj In arrText
On Error Resume next

arrBBox = rhino.BoundingBox(textObj)
cpt = Array((((arrBBox(2)(0)) + (arrBBox(0)(0))) / 2), (((arrBBox(2)(1)) + (arrBBox(0)
(1))) / 2), (((arrBBox(2)(2)) + (arrBBox(0)(2))) / 2))
txt = Rhino.TextObjectText(textObj)
'a = Split(txt, ".pSrf.PointAt(1, 1)pSrf.PointAt(1, 1)")

Rhino.AddPoint array(cpt(0),cpt(1),CDbl(txt))
'Rhino.AddPoint array(cpt(0),cpt(1),CDbl(a(0) & "." & a(1)))

Next

Rhino.Print "Finished converting input data to points"
Rhino.EnableRedraw True

End Sub

I get this all the time and this works super quick.

Hope this helps
I just found out that you can use the new GUID parameter to reference any kind of object, even text objects. This is very nice. Connect a GUID parameter to the 'x' input of a vb.net component, reference the text objects into the GUID parameter and just use this other code:

Dim objref As New MRhinoObjRef(New Guid(x))
Dim annotation_obj As IRhinoAnnotationText = MRhinoAnnotationText.ConstCast(objref.Object)
Dim pt As New On3dPoint(annotation_obj.Corner3dPoint(0))
pt.z = Convert.ToDouble(annotation_obj.String)
a = pt

Much shorter than the rhinoscript code :P
The site plans i deal with usually have the origin of the text object where it's corresponding point was placed. So you just need to retrieve the lower-left corner, and not the center of the bounding box.

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