How to read the DgnTag in DGN Cad (Java)

Hi,

I noticed that the Aspose.CAD brings the com.aspose.cad.fileformats.dgn.DgnTag.

But I already explored all methods to try to read the tags but without success.

I can’t find a way to read this.

Can someone help?

Thank you.

@eduveks,

Can you please share source file so that we may further investigate to help you out.

I’m reading a DGN file and the CellHeaders and the PolyLines have some tags (extra information) in the MicroStation.

How can I read these tag values? I can’t find any way to get the DgnTag objects…

Here is my source code:

import com.aspose.cad.StreamContainer;
import com.aspose.cad.fileformats.dgn.DgnElementType;
import com.aspose.cad.fileformats.dgn.DgnTag;
import com.aspose.cad.fileformats.dgn.dgnelements.*;

public class Main {
    public static void main(String[] args) {
        String fileName = "sample.dgn";

        com.aspose.cad.fileformats.dgn.DgnImage dgnImage = (com.aspose.cad.fileformats.dgn.DgnImage) com.aspose.cad.Image.load(fileName);
        
        for (com.aspose.cad.fileformats.dgn.dgnelements.DgnDrawingElementBase baseEntity : dgnImage.getElements())
        {
            System.out.println(baseEntity.getMetadata().getType());
            if (baseEntity.getMetadata().getType() == DgnElementType.CellHeader) {
                DgnCellHeaderElement cellHeader = (DgnCellHeaderElement)baseEntity;
                System.out.println(new String(cellHeader.getMetadata().d()));
                System.out.println(cellHeader.getName());
                System.out.println(new String(cellHeader.getMetadata().getProperties().getAttribute()));
            }
            if (baseEntity.getMetadata().getType() == DgnElementType.PolyLine) {
                DgnPolyLineElement line = (DgnPolyLineElement)baseEntity;
                //System.out.println(new String(line.getMetadata().getProperties().getAttribute()));
                //System.out.println(baseEntity.getMetadata());

            }
            /*System.out.println(baseEntity.getMetadata().getType());
            System.out.println(
                    new String(baseEntity.getMetadata().d())
                            .replace("�", "")
                            .replace("\u0000", "")
            );
            if (baseEntity.getMetadata() != null
                    && baseEntity.getMetadata().getProperties() != null
                    && baseEntity.getMetadata().getProperties().getAttribute() != null
            ) {
                System.out.println(
                        new String(baseEntity.getMetadata().getProperties().getAttribute())
                                .replace("�", "")
                                .replace("\u0000", "")
                );
            }*/
        }

        System.out.println(dgnImage.g.getClass().toGenericString());

        for (String attribute : dgnImage.getAttributes()) {
            System.out.println(attribute);
        }

        StreamContainer streamContainer = dgnImage.getDataStreamContainer();
        byte[] bytes = new byte[(int)streamContainer.getLength()];
        for (int i = 0; i < streamContainer.getLength(); i++) {
            int b = streamContainer.readByte();
            bytes[i] = (byte)b;
        }
        System.out.println(
            new String(bytes)
                    .replace("�", "")
                    .replace("\u0000", "")
        );
    }
}

@eduveks,

I have observed the sample code shared and request you to please share the source DGN file along with information about what information regarding tag you want to read using Aspose.CAD is in not get read using API. If possible please share the snapshot of desired tag information.

I think it’s not needed the source DGN file, because of the Aspose.CAD brings the DgnTag object and I just need a way to get instances of these objects.

May have some way to get instances of DgnTag from a DGN file, but I can not find any online samples, or even in online documentation, or even exploring the Aspose.CAD methods.

In my source code above I tried to read the metadata, and the properties and the attributes, but with the bytes array that the Aspose.CAD gives are not useful.

Then have no way to get the DgnTag from a DGN file!?

I wonder why the Aspose.Cad brings the DgnTag object…

@eduveks,

We have created an issue with ID CADJAVA-505 in our issue tracking system as investigation on our end. We request for your patience and will share the feedback with you as soon as any possible solution is possible to serve the purpose on your end.

@eduveks,

As requested earlier, can you please provide a sample file and a screenshot with tag object data of this sample. We need this to further investigate this on our end.