Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active January 31, 2023 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/b34ade017597205fbc7634b17c7dc1e9 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/b34ade017597205fbc7634b17c7dc1e9 to your computer and use it in GitHub Desktop.
Search Text in DWG File using Java
// Load the input DWG file with CadImage class
CadImage dgnImage = (CadImage) Image.load("search.dwg");
// Search for text in the file
for (CadBaseEntity entity : dgnImage.getEntities())
{
// We iterate through CadText entities here, but some other entities
// may contain text also, e.g. CadMText and others
if (entity.getClass() == com.aspose.cad.fileformats.cad.cadobjects.CadText.class)
{
com.aspose.cad.fileformats.cad.cadobjects.CadText text =
(com.aspose.cad.fileformats.cad.cadobjects.CadText)entity;
System.out.println(text.getDefaultValue());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment