algorithmic modeling for Rhino
Hi all,
For an experiment I'm trying to write a console application that writes a .3dm file that contains a single surface. I've installed the NuGet Package with the C# libraries for OpenNURBS into VS2015 Community but I haven't been able to find the documentation for it anywhere (my google-fu is not strong). I can get the file to compile and it writes an empty 3dm document, but I want to add geometry to the document before it is written. Here is my code as it stands, I'm quite new to programming and very stuck! Any help would be appreciated. if I could get some hints as to how to include "onepoint" in the file I'd be very grateful, and I'd figure out how to write the rest from there.
Thanks in Advance,
Henry
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Rhino.Geometry;
using Rhino.FileIO;
using Rhino.Collections;
using Rhino;
namespace NurbsSurface
{
class Program
{
static void Main(string[] args)
{
string output = "C:/Tryitout.3dm";
File3dm nurbssurface = new File3dm();
Point3d onepoint = new Point3d(0, 0, 0);
nurbssurface.Write(output, 0);
}
}
}
Tags:
I've never used this particular API, but your approach does seem strange. Why is the file variable called nurbssurface? Surely the surface is going to go inside the file, along with potentially many other shapes?
I'll look around in the SDK to see if it makes sense to me.
Using the Rhino.FileIO namespace from within Grasshopper seems to work fine. I do not know however to what extend the functionality is available if you do not have RhinoCommon loaded. I imagine a lot of the geometry types actually aren't available, because they require the Rhino core.
Hi David,
Thank you so much for the reply! I was missing the step that involved adding the objects to the object table. From what I understand all the objects in the table (or the table itself?) are then passed to the file3dm.Write() Method when it's used? Turns out it will work in the Visual Studio IDE perfectly well like this, Now I'm just sorting out the best way to create a surface.
If I can ask one more question, what does file.Polish() do?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Rhino.Geometry;
using Rhino.FileIO;
using Rhino.Collections;
using Rhino;
namespace NurbsExample
{
class Program
{
static void Main(string[] args)
{
string output = "C:/WorkingFileExample.3dm";
RunScript(output);
}
private static void RunScript(string path)
{
File3dm file = new File3dm();
file.Polish();
for (int j = 0; j<=10; j++)
{
file.Objects.AddLine(new Line(j, 0, 5 - j, 5 + j, 0, j));
}
File3dmWriteOptions options = new File3dmWriteOptions();
options.SaveAnalysisMeshes = false;
options.SaveRenderMeshes = false;
options.SaveUserData = true;
file.Write(path, options);
}
}
}
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by