Free Support Forum - aspose.com

Aspose.CAD Java Saving DWG


#1

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);


#2

@bao2408,

I have observed your comments. Can you please share source file and sample requirements so that we may further investigate to help you out.