-
Notifications
You must be signed in to change notification settings - Fork 336
/
Copy pathRhinoMethods.cs
40 lines (38 loc) · 1018 Bytes
/
RhinoMethods.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
using System;
using System.Threading.Tasks;
using Rhino.Runtime.InProcess;
namespace SampleRhinoInsideJavascriptMethodsLib
{
public class RhinoMethods
{
static RhinoCore rhinoCore;
public RhinoMethods()
{
RhinoInside.Resolver.Initialize();
}
public async Task<object> StartRhino(dynamic input)
{
return await Task.Run(() =>
{
try
{
rhinoCore = new RhinoCore(new string[] { "/NOSPLASH" }, WindowStyle.NoWindow);
return "Rhino has started.";
}
catch (Exception ex)
{
return ex.Message;
}
});
}
public async Task<object> MakeSphere(dynamic input)
{
return await Task.Run(() =>
{
var sphere = new Rhino.Geometry.Sphere(Rhino.Geometry.Point3d.Origin, input.radius);
var sphereMesh = Rhino.Geometry.Mesh.CreateFromSphere(sphere, input.countU, input.countV);
return Newtonsoft.Json.JsonConvert.SerializeObject(sphereMesh);
});
}
}
}