forked from mcneel/rhino.inside
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
59 lines (52 loc) · 1.53 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.IO;
using System.Reflection;
using Rhino.Runtime.InProcess;
using Rhino.Geometry;
namespace HelloWorld
{
class Program
{
#region Program static constructor
static Program()
{
ResolveEventHandler OnRhinoCommonResolve = null;
AppDomain.CurrentDomain.AssemblyResolve += OnRhinoCommonResolve = (sender, args) =>
{
const string rhinoCommonAssemblyName = "RhinoCommon";
var assemblyName = new AssemblyName(args.Name).Name;
if (assemblyName != rhinoCommonAssemblyName)
return null;
AppDomain.CurrentDomain.AssemblyResolve -= OnRhinoCommonResolve;
string rhinoSystemDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Rhino WIP", "System");
return Assembly.LoadFrom(Path.Combine(rhinoSystemDir, rhinoCommonAssemblyName + ".dll"));
};
}
#endregion
[System.STAThread]
static void Main(string[] args)
{
try
{
using (new RhinoCore(args))
{
MeshABrep();
Console.WriteLine("press any key to exit");
Console.ReadKey();
}
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
}
}
static void MeshABrep()
{
var sphere = new Sphere(Point3d.Origin, 12);
var brep = sphere.ToBrep();
var mp = new MeshingParameters(0.5);
var mesh = Mesh.CreateFromBrep(brep, mp);
Console.WriteLine($"Mesh with {mesh[0].Vertices.Count} vertices created");
}
}
}