Sunday, January 16, 2011

Update Baked Objs by C#


Link: update-bake


1.
Guid uuid = Guid.Empty;
uuid = doc.Objects.AddSurface(obj as Surface, att);

2.
Rhino.DocObjects.ObjRef RefObj = new Rhino.DocObjects.ObjRef(uuid);
doc.Objects.Replace(RefObj, srf);

Wednesday, January 12, 2011

SpaceMorph - Deformation Utility from Rhino SDK/RhinoCommon

Tutorial: link

To make a component that applies a deformation to geometry, try Rhino.Geometry.SpaceMorph with MorphVector. Yet, without using Morphvector, Rhino will just morph two nearby points and thus approximate the vector deformation.

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);

}