We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

DWG modify custom properties and save as DWG

Hello,

I load/read i DWG file and then read the custom properties, alter one of the properties and set the custom properties map back on the CadImage object.
When I then convert it to PDF, the custom properties fields that should be displayed in the converted pdf are not updated, instead, it still displays the old values. The reason I save it as a
PDF is that I can not find a way to just update the DWG file (save it again as a DWG).

Could not upload DWG so I took a print screen of it.
DWGPrintScreen.png (46.0 KB)
ResultingPDF.png (15.6 KB)

My test code:

public void testDWG() throws FileNotFoundException {

    //Native lang not supported expetion thrown if not set to English.
    java.util.Locale.setDefault(java.util.Locale.ENGLISH);
    CadImage objImage = (CadImage) CadImage.load(TEST_RESOURCE_PATH.concat("testDwg.dwg"));
    HashMap<String, String> customProperties = objImage.getHeader().getCustomProperties();
    //old value is set to TOLI
    customProperties.put("ORIGINAL_PREPARED_BY_INITIALS", "JT");

    // Prints JT
    System.out.println("updatedPropVal = " + objImage.getHeader().getCustomProperties().get("ORIGINAL_PREPARED_BY_INITIALS"));

    // Export the DWG to PDF
    //Result a pdf, but the custom property value is printed as TOLI.
    objImage.save(TEST_RESOURCE_PATH.concat("testDWGtoPDF.pdf"), new PdfOptions());

    objImage.save(); // Failes with NPE
    objImage.save(new FileOutputStream(TEST_RESOURCE_PATH.concat("testDWGtoDWG.dwg")));    // Failes with NPE.
}

@jthulin,
Hello. Please, attach your test DWG (e.g. inside zip achive), we need it to reproduce the issue on our side.

testDwg.zip (86.5 KB)

Here it is :slight_smile:

By the way we are using aspose cad version 20.4

@jthulin,
Unfortunately, we don’t have support for this feature now.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CADJAVA-10995

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Which future do you mean?

  • Convert to PDF with updated custom properties
  • Update properties and save it as DWG?

@jthulin,
we will look at both problems with applying changes of custom properties correctly (for now we don’t have such relation between them and corresponding entities in the drawing), and saving it to PDF. And we will investigate the issue about saving back to DWG, we have limited support for saving to DWG and working on it constantly.

Thanks for the swipt replies Oleksii. Do you see that we have any other option with the code as is? Thinking for example pre-converting it to anther format with better support currently? I´ve read in some threads that DXF support for editing capabilities. Could that be a way forward? Converting DWG to DXF. Editing the DXF. Converting to PDF.

Thanks in advance!

@nilspersson,
I was thinking about this yesterday, give us some time to check whether it is possible to achieve something like this and I will come back with results.

Thanks Oleksii!

@nilspersson, @jthulin,

We made brief investigation about this problem.

The relation between custom field value (“ORIGINAL_PREPARED_BY_INITIALS”) and corresponding entity in the drawing (MTEXT with related text) is complex and requires analysis of Objects collection for the drawing, there are 4 entities (2 dictionaries and 2 fields) “between” field and MTEXT, some of types are not available in public API (thus, making example of such processing is not available now), and probably, we need to parse additional information about fields for DWG format. After corresponding entity in the drawing is found we need to make changes in it, for some types (e.g. MTEXT) changing of text value may require changing of other properties like size, attachment points, etc. (but at the first look/testing this may be not required, will see later).

We will work with the step-by-step improvements for this case.

@oleksii.gorokhovatskyi

Thanks for this! Is there an implementation plan for the improvements?

@nilspersson,
we work now with reading and writing proper data for DWG format, and will try to make changes to allow public API processing for these properties. After that we will look how to implement export to PDF. Some of these features will probably appear in 23.4 though I can not guarantee this.

@oleksii.gorokhovatskyi When is 23.4 planned to be released? And is there a planned date already for 23.5? Thanks in advance!

@nilspersson,
.NET version is released usually at the second part of the month, so 23.4 version will be released close to the end of April, and 23.5 - in the second part of May. Java releases are a bit delayed compared to .NET, sometimes up to the month.

1 Like

Thanks for this!

1 Like