Hey everyone ,
I am currently checking out Aspose.CAD with java (aspose-cad-25.1). I am trying to load a file from .DWG, add a couple of objects and saving back to a .DWG again.
val image =
Image.load(“path/to/file.dwg")
val cadImage = image as CadImage
val layer = CadLayerTable()
layer.name = “new_layer”
layer.colorId = 256
cadImage.r().addItem(layer)
val rectangle = CadLwPolyline()
val x = -28633.94720000
val y = 6628.87470000
val width = 4.0
val height = 3.0
rectangle.coordinates = listOf(
Cad2DPoint(x, y),
Cad2DPoint(x + width, y),
Cad2DPoint(x + width, y + height),
Cad2DPoint(x, y + height)
);
rectangle.flag = CadLwPolylineFlag.Closed
rectangle.constantWidth = 0.01
rectangle.layerName = "new_layer"
cadImage.blockEntities.get_Item("*Model_Space").addEntity(rectangle)
val cadText = CadText()
cadText.styleType = "Standard"
cadText.defaultValue = "Some custom text"
cadText.colorId = 256
cadText.layerName = "new_layer"
cadText.firstAlignment.x = -28633.94720000
cadText.firstAlignment.y = 6628.87470000
cadText.textHeight = 0.8
cadText.scaleX = 1.0
cadImage.blockEntities.get_Item("*Model_Space").addEntity(cadText)
val dwgOptions = DwgOptions()
cadImage.save(
“Path/to/output-file.dwg",
dwgOptions
)
This results in two problems:
(1) Only one layer seems to be exported at a time, i.e. either only the original layer or the first previously existing layer is exported. I have not been able to produce a file with more than one layer.
(2) All text is converted to a shape. While I guess this is somewhat intentional, it immediately disqualifies Aspose.CAD as an option for us and we would be interested if there are any plans on exporting text to DWG
That said, export to DXF works like a charm which makes me think that there is some DWG-Export specific problem.
Best Regards,
Paul