Created
April 8, 2021 09:32
-
-
Save GroupDocsGists/5e8817fee989916e595d86081578147c to your computer and use it in GitHub Desktop.
Render CAD Drawings (DWG, DWF) to HTML using Java
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 Java | |
try (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 .dwg CAD drawing to view as HTML with external resources using Java | |
try (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 Java | |
try (Viewer viewer = new Viewer("drawing.dwg")) { | |
ViewInfoOptions viewInfoOptions = ViewInfoOptions.forHtmlView(); | |
CadViewInfo viewInfo = (CadViewInfo) viewer.getViewInfo(viewInfoOptions); | |
System.out.println("File type: " + viewInfo.getFileType()); | |
System.out.println("Pages count: " + viewInfo.getPages().size()); | |
for (Layout layout : viewInfo.getLayouts()) { | |
System.out.println(layout); | |
} | |
for (Layer layer : viewInfo.getLayers()) { | |
System.out.println(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 Java | |
try (Viewer viewer = new Viewer("drawing.dwg")) { | |
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources(); | |
viewOptions.getCadOptions().setLayers(Arrays.asList(new Layer("Stairs"), new Layer("Walls"))); | |
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 Java | |
try (Viewer viewer = new Viewer("drawing.dwg")) { | |
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources(); | |
viewOptions.getCadOptions().setRenderLayouts(true); | |
viewer.view(viewOptions); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment