We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

CAD to svg/image format

Hello,

I want to Convert CAD files into SVG or any image format. I am using Aspose.Imaging for it.
I have implemented the tutorial, but it is not converting all the dwg files,
I have tried with 4 dwg files, among which only 1 file is converted.
Is there any specific format supported for cad files?

here is my sample code,
using (Image image = Image.Load(myDir + "Image\\Gasket.dwg"))
{
Stream str = new MemoryStream();


CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();

//Set page width & height
rasterizationOptions.PageWidth = 1000;
rasterizationOptions.PageHeight = 1000;

//Create an instance of PngOptions for the resultant image
ImageOptionsBase options = new JpegOptions();

//Set rasterization options
options.VectorRasterizationOptions = rasterizationOptions;


image.Save(myDir + "Image\\output.jpeg", options);
//return File(str, "MIME","ab");
}


2) Can I convert the dwg image selected layer wise?
3) can I convert dwg to image as per particular dimention?

Hi Kalidas,


Thank you for considering Aspose APIs.

I am afraid, the current implementation of Aspose.Imaging APIs cannot write or convert to SVG file format. We already have this feature on our road map and hopefully we will be able to provide the implementation in near future. We have attached the appropriate ticket IMAGING-34871 from our request tracking system to this thread so that you could be notified automatically once the required feature is available for public use.

Regarding your other concerns, please find the answers as follow.

  1. The current implementation of Aspose.Imaging for .NET API supports loading of DWG 2004 (version 16.0 release 18), 2005 (version 16.1), 2010 (version 18.0) & 2013 (version 19.0). In case you are loading a DWG that does not correspond to above mentioned revisions then the API will throw ImageLoadException at Image.Load method. That being said, we request you to please provide us the sample DWG files that caused problems. Please also share the complete stack trace. We will further look into those samples to find out the exact problem cause.
  2. Yes, you can convert one layer at a time to any raster image format. Please check the detailed article on converting CAD layers to raster images.
  3. Yes, you can specify the desired image dimensions while using the CadRasterizationOptions.PageWidth & CadRasterizationOptions.PageHeight properties. Your current code is setting these properties to 1000.

Looking forward to your samples in order to provide further assistance in this regard.

Thanks for reply,


I am satisfied with you answer for my question 1 and 2,
but it looks like there is bit confusion in my 3rd question.

I was not asking for the image dimension, I was talking about the view like top view, right view, left view, for 3D files.
hope you understand what I am trying to say.


And attached the dwg files that I worked with.
I dont get error ever, but the converted image is used to be blank. I have attached tha Output.jpg too.
Hi Kalidas,

Thank you for your inquiry and providing sample files.

Currently, conversion of 3D view file is not supported by Aspose.Imaging. However, this is to update you that support for 3D view feature is on our road map. We will update you accordingly about features’ availability.
Further, please allow us some time to completely analyze the sample files provided by you. We will update you accordingly about our finding and results.

Hope the above information helps. In case of any issues, need further clearance please be sure to let us know, we will be glad to assist you.

Hi Kalidas,


We have worked with your provided samples and following are our investigation results.

  • colorwh.dwg: This sample does not correspond to any of the support DWG revisions therefore Aspose.Imaging APIs cannot load it for further processing.
  • civil_example-imperial.dwg: Sample seems to be damaged, however, we have logged an investigative ticket IMAGING-34911 to look further into this sample.
  • architectural_example-imperial.dwg: Sample appears to be damaged, however, a ticket with Id IMAGING-34913 has been logged for further investigation.
  • BARK CHAIR 2D_DWG (Right).dwg: If you render this sample with default settings, the resultant image is blank because among the 3 layouts in the sample, two are blank. Please try the following piece of code that renders each layout to a separate image. You will notice that Model layout has contents in it while others are empty. You may also confirm this by loading the DWG to AutoCAD application or AutoDesk’s TrueView. That being said, the default behaviour of Aspose.Imaging APIs is to render only the Model layout if resultant image cannot have multiple frames, such as Jpeg, Png & Bmp. In this scenario, it seems that the API is rendering a layout other than Model if no layouts are specified. We have logged an investigative ticket IMAGING-34912 for further investigation/

C#

//Load a CAD drawing in an instance of CadImage
using (var image = (Aspose.Imaging.FileFormats.Cad.CadImage)Aspose.Imaging.Image.Load(“D:/architectural_example-imperial.dwg”))
{
//Create an instance of CadRasterizationOptions
var rasterizationOptions = new Aspose.Imaging.ImageOptions.CadRasterizationOptions();
//Set image width & height
rasterizationOptions.PageWidth = 1500;
rasterizationOptions.PageHeight = 1500;

//Get the layers in an instance of CadLayersDictionary
var layouts = image.Layouts;
//Iterate over the layouts
foreach (var layout in layouts.ValuesTyped)
{
//Display layout name for tracking
Console.WriteLine("Start with " + layout.LayoutName);

//Add the layout name to the CadRasterizationOptions’s layout list
rasterizationOptions.Layouts = new string[] { layout.LayoutName };

//Create an instance of JpegOptions (or any ImageOptions for raster formats)
var options = new Aspose.Imaging.ImageOptions.JpegOptions();
//Set VectorRasterizationOptions property to the instance of CadRasterizationOptions
options.VectorRasterizationOptions = rasterizationOptions;
//Export each layer to Jpeg format
image.Save(“D:/” + CleanFileName(layout.LayoutName) + “.jpg”, options);
}
}

Hi Kalidas,

This is to update you regarding the tickets attached to this threads. Please find the details as follow.

  • IMAGING-34911: The problem has been fixed, where the fix will be available for your testing with the next release of Aspose.Imaging for .NET 3.1.0.
  • IMAGING-34912: Hopefully, the fix will be available with the next release, however, please note that the sample file has correct structure but AutoCAD opens it with “Non Autodesk DWG. This DWG file was saved by a software application that was not developed or licensed by Autodesk. Autodesk cannot guarantee the application compatibility or integrity of this file.” message. Moreover, the problem with layouts raised because internal order of layouts in file does not correspond to order in AutoCAD, therefore the first layout Aspose.Imaging APIs read is Layout1 instead of Model. We will provide the fix by correcting the order for such situations.
  • IMAGING-34913: The problem is correlated to the ticket IMAGING-34911 and therefore the fix will be available as soon as Aspose.Imaging for .NET 3.1.0 is available for public use.
  • IMAGING-34871: This is a new feature request for writing SVG files for possible conversion of other formats to SVG. We have scheduled the implementation with the release of Aspose.Imaging for .NET 3.2.0.

Please feel free to contact us back in case you have any questions or need our assistance with Aspose APIs.

The issues you have found earlier (filed as IMAGING-34913;IMAGING-34912;IMAGING-34911) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.