Grasshopper

algorithmic modeling for Rhino

Hello,

 

I´m trying to read out some x,y,z coordinates...

The model ist quiet big (14 km at x direction).

 

My problem ist, that grasshopper gives me for the x coordinats: 1.3941e+4

but thats not detailed enough, rhino directly gives me for the some point: 13941.1594.

That numbers look much better :-)

 

Can somebody help me with that???

 

Thank you

Views: 3532

Replies to This Discussion

I think you can use String.Format in C# or VB.

 

Something like 




String.Format("{0:0.00}", 123.4567);   --> "123.46"



Try google the forum, or http://www.csharp-examples.net/string-format-double/



-j


thank you...

 

but I guess I don´t have enough experience ( rookie oder dummie ;-)) in vb or c# for that...

 

Attachments:
you can also use a Function component to do this 
Attachments:

Thank you !!!!!

 

you saved my day :-)

Or use expressions like this to add even more formatting:

 

Format("{0:0.0000} km", x/1000)

Format("{0:0} m", x)

Format("{0:0} m ({1:0.0000} km)", x, x/1000)

 

You can format as many items at the same time as you want, just keep adding comma-separated values at the end of the function and use {X}, where X is the index of the value you want to format (first value = index 0, second value = index 1 etc.)

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

I'm trying this now and find it works well for a decomposed coordinate - How about formatting in {x,y,z} in the same function?

 

I'd like to have the Tag write the numbers for baking - I tried doing it individually, but it stacks the numbers.

 

Thank you!

Format("{0:0.00}, {1:0.00}, {2:0.00}", pt.X, pt.Y, pt.Z)

 

will format all three coordinates simultaneously. The number in front of the colon in the curly bracket notation indicates which item is to be formatted. 0 refers to the first item (pt.X), 1 to the second (pt.Y) and so forth. There is no limit and you can format each item as often as you want.

 

The portion after the semi-colon is optional (in which case the semi colon should also be omitted), but it allows you to specify HOW the data is formatted. There exist a lot of predefined formatting codes for numbers, and dates, and times, and currencies, and whatnot and you can also supply a customized format, such as I have done here. This particular format means "always display two decimal places, whether they exist or not". A different format like:

 

{0:0.00##}

 

means, "always display two decimal places, and you can add two more if the number has them". So the number 3 will become "3.00" and the number Pi will become "3.1415".

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thank you David, this works great!
to get access to input x's co-ordinates individually you can use the notation x.x, x.y and x.z
Thank you Danny for the clarification. I'll try it.

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