Dwg转SVG
1.DWG to SVG API: The API for converting AutoCAD drawings to SVG vector images - ConvertAPI
1.ConvertApi
async static Task Main(string[] args) { string From = @"C:\Users\Prozkb\Desktop\WJ\1-8.dwg"; string To = @"C:\Users\Prozkb\Desktop\WJ\"; ConvertApi convertApi = new ConvertApi("7xxxxx3"); var convert = await convertApi.ConvertAsync("dwg", "svg",new ConvertApiFileParam("File", From)); await convert.SaveFilesAsync(To); }
不成功的
using Aspose.CAD.ImageOptions.SvgOptionsParameters; using Aspose.CAD; using Aspose.CAD.ImageOptions; using Autodesk.AutoCAD.Interop; using Autodesk.AutoCAD.Interop.Common; using Aspose.Cells; using GroupDocs.Conversion; using GroupDocs.Conversion.Options.Convert; namespace DwgToSvg { internal class Program { static void Main(string[] args) { string From = @"C:\Users\Prozkb\Desktop\WJ\1-7.dwg"; string To = @"C:\Users\Prozkb\Desktop\WJ\"; { //try //{ // // 加载输入 DWG 文件 // Image image = Image.Load(From); // //ImageOptions.SvgOptions options = new ImageOptions.SvgOptions(); // //// 设置 SVG 颜色模式 // //options.ColorType = SvgColorMode.Grayscale; // //options.TextAsShapes = true; // imageOption imageOption = new imageOption(); // // 保存输出 SVG 文件 // //image.Save(To, imageOption); // image.Save(To); //} //catch (Exception ex) //{ // throw; //} } { try { // Load DWG file var converter = new GroupDocs.Conversion.Converter(From); // Set conversion parameters for SVG format var sd = converter.GetPossibleConversions(); var convertOptions = converter.GetPossibleConversions()["svg"].ConvertOptions; // Convert to SVG format converter.Convert(To, convertOptions); } catch (Exception ex) { throw ex; } } { //ConvertDwgToSvg(From, To); } Console.WriteLine("Hello, World!"); } public static bool ConvertDwgToSvg(string dwgFilePath, string svgFilePath) { try { // 加载DWG文件 using (var image = Aspose.Imaging.Image.Load(dwgFilePath)) { // 创建SVG选项 var svgOptions = new Aspose.Imaging.ImageOptions.SvgOptions(); // 设置SVG选项 svgOptions.VectorRasterizationOptions.PageWidth = image.Width; svgOptions.VectorRasterizationOptions.PageHeight = image.Height; // 保存为SVG格式 image.Save(svgFilePath, svgOptions); } return true; } catch (Exception ex) { // 处理异常 Console.WriteLine($"转换过程中发生错误: {ex.Message}"); return false; } } } }
人各有命,上天注定,有人天生为王,有人落草为寇。脚下的路,如果不是你自己的选择,那么旅程的终点在哪,也没人知道。你会走到哪,会遇到谁,都不一定。