Wednesday, September 29, 2010

Backe an object with an assigned name

Bake an object with the assigned name from Grasshopper : Backe an object with an assigned name

file fro m Grasshopper3D: AddNameToObj.ghx, 31 KB



if (BakeNow)
{
Rhino.DocObjects.ObjectAttributes att = new Rhino.DocObjects.ObjectAttributes();

att.Name = NewName;

//If it's a brep, a polysurface or a surface
if (Obj is Brep)
{
doc.Objects.AddBrep((Brep) Obj, att);
A = "Brep baked";
}

//If it's a mesh
else if (Obj is Mesh)
{
doc.Objects.AddMesh((Mesh) Obj, att);
A = "Mesh baked";
}

//If it's a line (not a curve)
else if (Obj is Line)
{
doc.Objects.AddLine((Line) Obj, att);
A = "Line baked";
}

//If it's an arc (not a curve)
else if (Obj is Arc)
{
doc.Objects.AddArc((Arc) Obj, att);
A = "Arc baked";
}

//If it's a circle (not a curve)
else if (Obj is Circle)
{
doc.Objects.AddCircle((Circle) Obj, att);
A = "Circle baked";
}

//If it's a curve)
else if (Obj is Curve)
{
doc.Objects.AddCurve((Curve) Obj, att);
A = "Curve baked";
}

//If it's a Point3D)
else if (Obj is Point3d)
{
doc.Objects.AddPoint((Point3d) Obj, att);
A = "Point baked";
}

else
{
A = "Don't Know how to handle this geometry.";
}

}

No comments:

Post a Comment