-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FishPrint of svg #395
Comments
Hi @ChenChihYuan |
Thanks @hrntsm , I am looking into it. I do have some problems to create my own svg scripting component. private void RunScript(ref object bitmap_0, ref object bitmap_1)
{
bitmap_0 = CaptureViewport()[0];
bitmap_1 = CaptureViewport()[1];
}
List<Bitmap> CaptureViewport()
{
// RhinoView view = RhinoDoc.ActiveDoc.Views.ActiveView;
List<Guid> viewNames = new List<Guid>();
List<Bitmap> bitmaps = new List<Bitmap>();
foreach (Rhino.Display.RhinoView view in RhinoDoc.ActiveDoc.Views)
{
// viewNames.Add(view.ActiveViewport.Id);
Bitmap bitmap = view.CaptureToBitmap();
bitmaps.Add(bitmap);
}
return bitmaps;
} However, private void RunScript(string folderPath, ref object a, ref object b)
{
// string fileName = "ViewportCapture.svg"; // Change filename as needed
string fileName = $"ViewportCapture_{DateTime.Now:yyyyMMdd_HHmmss}.svg";
a = CaptureViewportAsSvg(folderPath, fileName);
b = Path.Combine(folderPath, fileName);
}
public static void CaptureViewportAsSvg(string folderPath, string fileName)
{
RhinoView view = RhinoDoc.ActiveDoc.Views.ActiveView;
if (view == null)
{
RhinoApp.WriteLine("No active viewport found.");
return null;
}
int width = 1920; // Set width
int height = 1080; // Set height
double dpi = 300; // High resolution
ViewCaptureSettings vcs = new ViewCaptureSettings(view, new System.Drawing.Size(width, height), dpi);
vcs.DrawBackground = true; // Change to false for a transparent background
vcs.ApplyDisplayModeThicknessScales =true; //Apply viewport display thickness settings
vcs.WireThicknessScale = 0.3; // Adjust line thickness
// Capture SVG as XmlDocument
XmlDocument svg = Rhino.Display.ViewCapture.CaptureToSvg(vcs);
if (svg == null)
{
RhinoApp.WriteLine("Failed to capture viewport as SVG.");
return null;
}
// Ensure the folder exists
if (!Directory.Exists(folderPath))
Directory.CreateDirectory(folderPath);
string filePath = Path.Combine(folderPath, fileName);
// Save SVG file
svg.Save(filePath);
RhinoApp.WriteLine($"SVG saved: {filePath}");
} I attach as such, so that artifact accepting the filePath, but it won't trigger svg script component I made above to fire each solution runs. |
@ChenChihYuan After the svg is properly generated, check that the correct file path is specified. |
Motivation
Vectorized format has better detail preservation capability than rasterized Bitmap.
When viewing the pictures either in Dashboard or TT-Design Explorer, I find it's better if Tunny can also support svg format.
Description
I dived into code, and found out the FishPrint is casted from Bitmap.
However, I think there's need for FishPrint accepting Svg as well, since there's this https://developer.rhino3d.com/api/rhinocommon/rhino.display.viewcapture/capturetosvg function.
Vectorized format has better detail preservation capability than rasterized Bitmap.
I hope this can be a feature supported in the future.
Alternatives (optional)
No response
Additional context (optional)
No response
The text was updated successfully, but these errors were encountered: