Skip to content

C# library to convert AutoCAD drawings from DWG to SVG. AutoCAD files are read using ACadSharp.

License

Notifications You must be signed in to change notification settings

nanoLogika/ACadSvg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ACad/SVG

ACad/SVG is a library to convert AutoCAD DWG documents to SVG. DWG documents are read with ACadSharp.

The converter supports many AutoCAD entities such as Arc, Circle, Dimensions, Ellipse, Hatch, Insert, Leader, Line, LwPolyline, MText, Multileader, Spline, TextEntity. The converter focuses on converting the block structure, especially dynamic blocks, rather than just converting a drawing.

SVG text is created using SvgElements.

Getting Started

Use the ACad SVG Studio to load and convert DWG documents and view the converted SVG.

Code Example

using ACadSvg;
using SvgElements;

//  Create conversion context assuming standard conversion options.
//  The conversion context also receives the conversion log.
//  See/use ACadSvgStudio to learn more about conversion options.
ConversionContext ctx = new ConversionContext();

string path = "sample.dwg";
DocumentSvg docSvg = ACadLoader.LoadDwg(path, ctx);

//  Get an object representing a SVG group containing the converted
//  entities that are not member of a BlockRecord.
SvgElementBase mainGroup = docSvg.MainGroupToSvgElement();

//  Get an object representing a SVG defs element containing the converted
//  BlockRecord objects found in DWG.
SvgElementBase defs = docSvg.DefsToSvgElement();

//  Create an empty SVG element
SvgElement svg = DocumentSvg.CreateSVG(ctx);

//  Convert the SVG objects to Text
string mainGroupSvg = mainGroup.ToString();
string defsSvg = defs.ToString();

Console.WriteLine(ctx.ConversionInfo.GetLog());
Console.WriteLine(ctx.ConversionInfo.GetOccurringEntitiesLog());

Dependencies

NOTE: Currently not all ACadSharp features required by ACadSvg are pushed to ACadSharp. Please use the "merged" branch from this repository.

WIP

The converter does not support all AutoCAD entities. Entitiy types that could not be converted, either because the conversion is not implemented in ACad/SVG or the DWG reader is not implemented in ACadSharp are listed in the conversion log.

Notice that this project is in an alpha version, not all the features are implemented and there can be bugs due to this.

Contributions

Please feel free to fork this repo and send a pull request if you want to contribute to this project.

About

C# library to convert AutoCAD drawings from DWG to SVG. AutoCAD files are read using ACadSharp.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages