Is it possible to save your edits to a DWG file? I edited the xref attribute of a dwg file but cannot save the edits.
String dataDir = “C:\Users\user\Desktop\”;
String sourceFileName = “Test.dwg”;
String destFileName = “XRef_Test.dwg”;
//ExStart:ReadXREEFMetaData
CadImage image = (CadImage) Image.load(dataDir + sourceFileName);
for (CadBlockEntity blockEntity : image.getBlockEntities().getValues()) {
String currentXRefPath = blockEntity.getXRefPathName();
if (currentXRefPath.contains(File.separator)) {
System.out.println(currentXRefPath);
String currentXRefFileName = currentXRefPath.substring(currentXRefPath.lastIndexOf(File.separator) + 1);
String revisedXRefFileName = “Test_” + currentXRefFileName;
String revisedXRefPath = currentXRefPath.replace(currentXRefFileName, revisedXRefFileName);
blockEntity.setXRefPathName(revisedXRefPath);
System.out.println(blockEntity.getXRefPathName());
}
}
image.save(dataDir + destFileName, true);