Load CAD document with options

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Conversion MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-conversion -- dnx GroupDocs.Conversion.Mcp --yes
Folders, licensing and more →

GroupDocs.Conversion provides CadLoadOptions to give you control over how the source CAD document will be processed. The following options could be set:

  • setFormat allows you to set the source document format explicitly with this property. Available options are: Dxf, Dwg, Dgn, Dwf, Stl, Ifc, Plt, Igs, Dwt.
  • setWidth sets the desired page width.
  • setHeight sets the desired page height.
  • setLayoutNames specifies which CAD layout to be converted.

Specify layouts to be converted

The following code snippet shows how to convert a CAD document and convert only certain layouts:

const outputPath = "ConvertCadAndSpecifyLayouts.pdf"
  
const loadOptions = new groupdocs.conversion.CadLoadOptions()
loadOptions.setLayoutNames(["Layout1", "Layout3"]);
const converter = new groupdocs.conversion.Converter("with_layers_and_layouts.dwg", () => loadOptions);

const convertOptions = new groupdocs.conversion.PdfConvertOptions()
console.log(`Cad document converted successfully to ${outputPath} (cad & specify layouts)`)
converter.convert(outputPath, convertOptions)

Specify width and height

The following code snippet shows how to convert a CAD document and specify the width and height:

const outputPath = "convertCadAndSpecifyWidthAndHeight.tiff"

const loadOptions = new groupdocs.conversion.CadLoadOptions()
loadOptions.setWidth(1920);
loadOptions.setHeight(1080);

const converter = new groupdocs.conversion.Converter("with_layers_and_layouts.dwg", () => loadOptions);

const convertOptions = new groupdocs.conversion.ImageConvertOptions();
convertOptions.setFormat_ConvertOptions_New(groupdocs.conversion.ImageFileType.Tiff);

console.log(`Cad document converted successfully to ${outputPath} (cad & specify width and height)`)
converter.convert(outputPath, convertOptions)