Ikram ul Haq January 10, 20170 Comments

Drawing DGN format as part of DWG format with Aspose.CAD for .Net 16.12

Drawing DGN format as part of DWG format with Aspose.CAD for .Net 16.12

January 10, 2017
Share on FacebookTweet about this on TwitterShare on LinkedIn

We are pleased to announce the release of Aspose.CAD for .NET 16.12. The major development in this release is implementation of the feature drawing DGN format as a part of DWG format. Underlay flags for DWG format are implementation in this release. Reading insert coordinate and rotation angle for DGN underlay feature also been incorporated in this release.

Drawing DGN Format As Part of DWG

Aspose.CAD for .NET allows you to export a DWG file with embedded DGN underlay inside. Following is the code demonstrating how to access the DGN underlay inside a DWG file while exporting the DWG file.

// Input and Output file paths
string fileName = "BlockRefDgn.dwg";
string outPath = fileName + ".pdf";

// Create an instance of PdfOptions class as we are exporting the DWG file to PDF format
PdfOptions exportOptions = new PdfOptions();

// Load any existing DWG file as image and convert it to CadImage type
using (CadImage cadImage = (CadImage)Image.Load(fileName))
        // Go through each entity inside the DWG file
	foreach (CadBaseEntity baseEntity in cadImage.Entities)
		// Check if entity is an image definition
		if (baseEntity.TypeName == CadEntityTypeName.DGNUNDERLAY)
			CadDgnUnderlay dgnFile = (CadDgnUnderlay)baseEntity;

			// Get external reference to object

       // Define settings for CadRasterizationOptions object
	exportOptions.VectorRasterizationOptions = new CadRasterizationOptions()
		PageWidth = 1600,
		PageHeight = 1600,
		CenterDrawing = true,
		Layouts = new string[] { "Model" },
		ScaleMethod = ScaleType.None,
		BackgroundColor = Color.Black,
		DrawType = CadDrawTypeMode.UseObjectColor

        // Export the DWG to PDF by calling Save method
	cadImage.Save(outPath, exportOptions);

Accessing underlay Flags for DWG Format

Aspose.CAD for .NET has implemented the underlay flags for DWG format and allow developers to access them. Following is the simple code demonstration.

// Input file name and path
string fileName = "BlockRefDgn.dwg";

// Load an existing DWG file and convert it into CadImage 
using (CadImage image = (CadImage)Image.Load(fileName))
    // Go through each entity inside the DWG file
    foreach (CadBaseEntity entity in image.Entities)
        // Check if entity is of CadDgnUnderlay type
        if (entity is CadDgnUnderlay)
            // Access different underlay flags 
            CadUnderlay underlay = entity as CadUnderlay;
            Console.WriteLine((underlay.Flags & UnderlayFlags.UnderlayIsOn) == UnderlayFlags.UnderlayIsOn);
            Console.WriteLine((underlay.Flags & UnderlayFlags.ClippingIsOn) == UnderlayFlags.ClippingIsOn);
            Console.WriteLine((underlay.Flags & UnderlayFlags.Monochrome) != UnderlayFlags.Monochrome);


Following enhancements have been introduced in this release.

  • Process of converting DWG to PDF format has been improved.

  • Process of converting DWG to PNG format in multithreading has been improved.

To view a complete list of new features and to download the latest release, please visit Aspose.CAD for .NET 16.12 page in downloads section.

Aspose.CAD for .NET Resources

The resources, you may need to accomplish your tasks:

Leave a comment

Posted inAspose.CAD Product Family

Related Articles