testDwg.zip (86.5 KB)
Here it is
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?
@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!
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.
@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.
Thanks for this!
Hi Oleksii!
Just reaching out to hear if any of these requests made it into the 23.4 and/or the 23.5 releases? And if not if they are planned for any future releases?
Thanks in advance!
Regards,
Nils
@nilspersson,
Hello.
We are preparing Aspose.CAD for Java 23.3 to be released at the beginning of the next week, I’m going to test the progress and new possibilities for this feature using it and come back to you with more information.
@nilspersson,
Hi.
So, here is a workaround that is available with the latest Aspose.CAD for Java 23.3 release to export DXF to PDF with changing of custom properties:
final CadImage cadImage = (CadImage)Image.load(in);
HashMap<String, String> custom = cadImage.getHeader().getCustomProperties();
String customName = "ORIGINAL_PREPARED_BY_INITIALS";
String oldValue = custom.get(customName);
String newValue = "JT";
for (CadBaseObject bo: cadImage.getObjects())
{
if (bo.getTypeName() != CadObjectTypeName.FIELD)
{
continue;
}
CadField field = (CadField)bo;
if (field.getFieldCodeString().contains(customName))
{
CadField parentField = (CadField)FindObject(cadImage, field.getSoftOwner());
CadDictionary parentDict = (CadDictionary)FindObject(cadImage, parentField.getSoftOwner());
CadDictionary parentDict2 = (CadDictionary)FindObject(cadImage, parentDict.getSoftOwner());
CadBaseEntity relatedEntity = FindEntity(cadImage.getBlockEntities(), cadImage.getEntities(), parentDict2.getSoftOwner());
if (relatedEntity.getTypeName() == CadEntityTypeName.MTEXT)
{
CadMText mtext = (CadMText)relatedEntity;
mtext.setText(mtext.getText().replace(oldValue, newValue));
}
}
}
custom.put(customName, oldValue);
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setPageWidth(1550);
rasterizationOptions.setPageHeight(1550);
// Create an instance of PdfOptions
final PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
cadImage.save(out, pdfOptions);
private static CadBaseObject FindObject(CadImage cadImage, String handle)
{
for (CadBaseObject bo : cadImage.getObjects())
{
if (bo.getObjectHandle().equals(handle))
{
return bo;
}
}
return null;
}
private static CadBaseEntity FindEntity(CadBlockDictionary blockDictionary, CadBaseEntity[] entities, String handle)
{
for (CadBaseEntity be : entities)
{
if (be.getObjectHandle().equals(handle))
{
return be;
}
// search for entities inside inserts
if (be.getTypeName() == CadEntityTypeName.INSERT)
{
CadInsertObject insert = (CadInsertObject)be;
CadBlockEntity block = blockDictionary.get_Item(insert.getName());
CadBaseEntity found = FindEntity(blockDictionary, block.getEntities(), handle);
if (found != null)
{
return found;
}
}
}
return null;
}
This example does not work for DWG now (only for DXF -> PDF), we expect to deliever it in next 23.6 version this month (for Aspose.CAD for .NET) and a month-two later for Aspose.CAD for Java (and will do our best to deliever it faster). Saving DWG to DWG is also planned for 23.6. Please, note that I can not guarantee these terms though.
Other planned work includes more convenient internal processing of these items (but there is some uncertainty how e.g. AutoCAD stores and updates them), as well as we have issues with export of DWG to DXF for this case, this task is also planned for investigation.
Thanks Oleksii! Fantastic news! We will evaluate the java version then after summer. Thanks for a great job!
Regards,
Nils
Hi Oleksii! Hope all is fine!
Just reaching out to hear if the JAVA based version is now supporting the DWG to PDF functionality discussed above?
Thanks in advance!
Regards.
Nils
@nilspersson,
Hello.
As I can see export of DWG to PDF with changed property is fine (according to example above) and hope to see the same in Java product 23.6 release. We expect to publish it close to the end of the next week.