Tuesday, December 28, 2010

String Format for Double

Tutorial Link: Local Project: http://www.csharp-examples.net/string-format-double/


Digits after decimal point
This example formats double to string with fixed number of decimal places. For two decimal places use pattern „0.00“. If a float number has less decimal places, the rest digits on the right will be zeroes. If it has more decimal places, the number will be rounded.

Next example formats double to string with floating number of decimal places. E.g. for maximal two decimal places use pattern „0.##“.

Digits before decimal point
If you want a float number to have any minimal number of digits before decimal point use N-times zero before decimal point. E.g. pattern „00.0“ formats a float number to string with at least two digits before decimal point and one digit after that.

Align numbers with spaces
To align float number to the right use comma „,“ option before the colon. Type comma followed by a number of spaces, e.g. „0,10:0.0“ (this can be used only in String.Format method, not in double.ToString method). To align numbers to the left use negative number of spaces.

Sunday, December 19, 2010

Create an automated screenshot


Original Link: http://www.grasshopper3d.com/forum/topics/having-grasshopper-create-an

Rectangle bounds = Screen.GetBounds(System.Drawing.Point.Empty);
using(Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))

{

    using(Graphics g = Graphics.FromImage((Image) bitmap))

    {

        g.CopyFromScreen(System.Drawing.Point.Empty, System.Drawing.Point.Empty, bounds.Size);

    }

    bitmap.Save(@"C:\SomePath\SomeFilename.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

}

Concave Hall


paid application: http://www.concavehull.com/home.php?main_menu=1

Local Project: http://ubicomp.algoritmi.uminho.pt/local/


algorithm: http://www.concavehull.com/home.php?main_menu=1

Online application: http://local.dsi.uminho.pt:8080/webMathematica/ConcaveHull/index.html

Saturday, December 18, 2010

DataTree in C#


How to create a DataTree in C# using Grasshopper:

DataTree Tree = new DataTree();

for (int i = 0; i <= y; i++){

    // Adding data to a DataTree requires a path.

    // In this case the path will have a single branch index.

    // There will be only one Point associated with each path

    Point3d pt = new Point3d(i, 0, 0);

    EH_Path Path = new EH_Path(i);

    Tree.Add(pt, Path);

}

Friday, December 10, 2010

how to port Excel data to GH


original source link

Dim xlApp As Object
''Grab a running instance of Excel
xlApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application")

''send volume and area to Excel
xlApp.range("B12").Value = volume
xlApp.range("B13").Value = area

Thursday, December 9, 2010

PQ Mesh


Reference from EAT-A-BUG:
http://eat-a-bug.blogspot.com/2010/09/planar-quad-mesh-design.html
http://eat-a-bug.blogspot.com/2010/09/planar-quad-mesh-design-pt-2.html


This is a exercise to create a Tool to generate a quad-dorminate mesh with only planar faces only--PQ Mesh, which was first presented in this paper.