Created
April 27, 2021 14:41
-
-
Save GroupDocsGists/f6f22f03f2b4f9c984932a11e77a1b23 to your computer and use it in GitHub Desktop.
Render CAD Drawings | View DWG or DWF as HTML in C# using .NET API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Render DWG CAD drawing to view as HTML with embedded resources using C# | |
using (Viewer viewer = new Viewer("drawing.dwg")) | |
{ | |
HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html"); | |
viewer.View(viewOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Render C# CAD drawing to view as HTML with external resources using C# | |
using (Viewer viewer = new Viewer("drawing.dwg")) | |
{ | |
HtmlViewOptions viewOptions = HtmlViewOptions.ForExternalResources( | |
"page_{0}.html","page_{0}/resource_{1}","page_{0}/resources"); | |
viewer.View(viewOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get Layouts and Layers of DWG CAD drawing in C# | |
using (Viewer viewer = new Viewer("drawing.dwg")) | |
{ | |
ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForHtmlView(); | |
CadViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions) as CadViewInfo; | |
Console.WriteLine("File type: " + viewInfo.FileType); | |
Console.WriteLine("Pages count: " + viewInfo.Pages.Count); | |
foreach (Layout layout in viewInfo.Layouts) | |
Console.WriteLine(layout); | |
foreach (Layer layer in viewInfo.Layers) | |
Console.WriteLine(layer); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Render Layers of .dwg CAD drawing in C# | |
using (Viewer viewer = new Viewer("drawing.dwg")) | |
{ | |
HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); | |
viewOptions.CadOptions.Layers = new List<Layer> | |
{ | |
new Layer("Walls"), | |
new Layer("Windows") | |
}; | |
viewer.View(viewOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Render Layouts of .dwg CAD drawing in C# | |
using (Viewer viewer = new Viewer("drawing.dwg")) | |
{ | |
HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); | |
viewOptions.CadOptions.RenderLayouts = true; | |
viewer.View(viewOptions); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment