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:

OptionDescription
FormatThe source document type is auto-detected, but you could set the source document format explicitly with this property. Available options are: Dxf, Dwg, Dgn, Dwf, Stl, Ifc, Plt, Igs, Dwt
BackgroundColorSpecifies the background color for a CAD document.
DrawTypeSpecifies the type of drawing of a CAD document.
WidthSets the desired page width
HeightSets the desired page height
LayoutNamesSpecifies 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:

Func<LoadContext, LoadOptions> getLoadOptions = loadContext => new CadLoadOptions
{
    LayoutNames = new []{ "Layout1", "Layout3" }
};
using (Converter converter = new Converter("with_layers_and_layouts.dwg", getLoadOptions))
{
    PdfConvertOptions options = new PdfConvertOptions();
    converter.Convert("converted.pdf", options);
}

Specify background color

The following code snippet shows how to convert a CAD document and specify its desired background color:

Func<LoadContext, LoadOptions> getLoadOptions = loadContext => new CadLoadOptions
{
    BackgroundColor = System.Drawing.Color.White
};
using (Converter converter = new Converter("sample.dwg", getLoadOptions))
{
    PdfConvertOptions options = new PdfConvertOptions();
    converter.Convert("converted.pdf", options);
}