Hi,
I am just getting satrted with Rhino Compute. I am developing a test MVC web application. After some geometry calculation (where compute is used) or simply after reading Rhino file(using Rhino3dmIO) I wish to export geometry as “.sat” file. How can I possibly do that?
see attached image.
I am trying to implement the ComputePlugin example in C#. I don’t think my endpoints are set up properly. Can anybody offer some step-by-step advice? I’m also pasting the C# code I’m using to try to convert the .3dm:
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
private static readonly string computeUrl = "http://localhost:5000/";
private static readonly string file3dmPath = "./files/fromCompute.3dm";
private static readonly HttpClient client = new HttpClient();
static async Task Main(string[] args)
{
// Example 1 - Convert a 3dm file to pdf
try
{
string b64ba = Convert.ToBase64String(File.ReadAllBytes(file3dmPath));
string endpoint = $"{computeUrl}sample/convert3dmtopdf-string";
string response = await ComputeFetch(endpoint, new object[] { b64ba });
// Save the response to a PDF file
byte[] pdfBytes = Convert.FromBase64String(response);
File.WriteAllBytes("out.pdf", pdfBytes);
}
catch (Exception ex)
{
Console.Error.WriteLine(ex);
}
// Example 2 - Convert a single layer (by id) of a 3d file to dwg
try
{
string b64ba = Convert.ToBase64String(File.ReadAllBytes(file3dmPath));
string layerId = "2726aa36-732e-488e-9cf4-0b7cf82e65ce";
string endpoint = $"{computeUrl}sample/convert3dmtodwg-string_guid";
string response = await ComputeFetch(endpoint, new object[] { b64ba, layerId });
// Save the response to a DWG file
byte[] dwgBytes = Convert.FromBase64String(response);
File.WriteAllBytes("out.dwg", dwgBytes);
}
catch (Exception ex)
{
Console.Error.WriteLine(ex);
}
}
private static async Task<string> ComputeFetch(string url, object[] args)
{
var content = new StringContent(JsonSerializer.Serialize(args), Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(url, content);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
}
I have gotten this to work with C# code based on the original js example in the repository; however, text objects are not showing up in the output .dwg. Any ideas why this might be happening? Does it have to do with the code or the conversion method itself? Any help would be appreciated!