0

I have a .NET C# program that needs to convert an image (be it BMP, JPEG, PNG) into an AutoCAD file (DWG or DXF). I've tried several ways mentioned here in other forums, but without success. I tried Aspose but there they only import DWG and don't convert to DWG.

Could anyone help me with some approach to this conversion or an API for .NET ?

I tried to convert using Aspose's API, with this link; I tried the exact same code but it doesn't seem to work because the generated DXF is empty.

The most promising approach for my .NET C# program seems to be via Aspose, but as I mentioned, I was unsuccessful.

asked Nov 27, 2023 at 19:52
4
  • 1
    You'll have to post your attempt and hope that people can help you make it work - otherwise this will just be a request for help finding a toolkit, which is off-topic. Commented Nov 27, 2023 at 23:56
  • I tried the below code available in Aspose library but it saves an empty file, there is no content in output.dxf using Aspose.Imaging; usingSystem; using System.IO; using System.Text; using System.Collections.Generic; string templatesFolder = @"c:\Users\USER\templates\"; using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"template.bmp"))) { var exportOptions = new Aspose.Imaging.ImageOptions.DxfOptions(){ TextAsLines = true,ConvertTextBeziers = true}; image.Save(Path.Combine(templatesFolder, "output.dxf"), exportOptions); } Commented Nov 28, 2023 at 17:15
  • Reading your question again, you do realize that dwg/dxf is not an image format as such but a CAD format, right? I mean, it can have elements in it that are bitmapped images, but that's not what the overall format is about. Commented Nov 28, 2023 at 17:28
  • Okay, so basically I should convert the image to a vectorized type (SVG for example) and then upload it to a CAD file? Commented Nov 28, 2023 at 18:43

1 Answer 1

0

You can try something like this with Aspose.CAD library:

using (Image cadImage = Image.Load("input.png"))
{
 cadImage.Save("output.dxf", new DxfOptions());
}

Disclosure: I work as Aspose.CAD developer at Aspose.

blackgreen
47k29 gold badges172 silver badges164 bronze badges
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.