I am trying to parse the dxf file using aspose cad for java. My idea is to export all the layers and entities later use a third part library like Batik to convert to svg.
Following is the code to load the dxf file:
final DxfImage dxfImage = (DxfImage)Image.load(inputDxfFilePath);
fetching the layer details
CadLayerTable layer = dxfImage.getLayers().getLayer(lname);
Fetching the entities
List<CadEntityBase> entities = dxfImage.getEntities();
There are methods in CadEntityBase related to styles like getColorId, getgetPlotStyleFlag, …
Do you have a document that relates the CadEntityBase styles to html styles.
Also, how can I get the Fill color of an entity?
@brahmajipusuluri,
Hi.
I guess we need a bit more information here to assist.
Do you have a document that relates the CadEntityBase styles to html styles.
Could you please clarify what is html styles?
Also, how can I get the Fill color of an entity?
You can look at getColorId, getColorName, getColorValue, but I guess not all entities could be filled. Could you please share the initial DXF file and point out with screenshots what entity you are talking about?
I learnt that in CAD if a lwpolyline has a fill, then it is called a Hatch.
In my case I want to find the link between the Hatch and the lwpolyline.
I am able to find the dxf handle of Hatch in the lwpolyline metadata as a “ACAD_REACTORS”(Soft Handle #0 to persistent Rector). And in the Hatch the link of lwpolyline is found in "Source Entity Handle).
I need to fetch these values using Aspose cad Java methods. Can you please help here.
@brahmajipusuluri,
please, share the initial file so we can talk exactly about the same entities.
Rectangle-layers_Hatch.zip (22.8 KB)
Please find the attached dxf file for reference.
@brahmajipusuluri,
please, try if this example is useful:
final CadImage cadImage = (CadImage)Image.load(inputFile);
for (CadEntityBase cadEntityBase : cadImage.getEntities())
{
if (cadEntityBase.getTypeName() == CadEntityTypeName.HATCH)
{
CadHatch hatch = (CadHatch)cadEntityBase;
for (CadHatchBoundaryPathContainer boundaryPath: hatch.getBoundaryPaths())
{
System.out.println(String.join(", ",boundaryPath.getSourceBoundaryObjects()));
}
}
if (cadEntityBase.getTypeName() == CadEntityTypeName.LWPOLYLINE)
{
CadApplicationCodesContainer container = cadEntityBase.getApplicationCodesContainer();
if (container.getCodes().containsKey(""))
{
CadApplicationCodes codes = container.getCodes("", "ACAD_REACTORS");
for (CadCodeValue ccv: codes.getCodesList())
{
System.out.println(ccv.getCode() + " " + ccv.getValue());
}
}
}
}
1 Like