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

Free Support Forum - aspose.com

Cast Image to CadImage not working for STL files

In latest aspose-cad version, casting to CadImage from Image object is not possible. (Source image is STL)

But before it is ok.

Why is this so?

@Schwraz,
could you please attach exact code snippet and your file, so we can reproduce this exactly?

public class ExportSTLToPNG {
    public static void main(String[] args)
    {
        //ExStart:ExportSTLToPNG
        String dataDir = Utils.getDataDir(ExportSTLToPNG.class) + "ExportingSTL/";
        String fileName = dataDir + "foot.stl";

        CadImage cadImage = (CadImage)Image.load(fileName);
        CadRasterizationOptions vectorOptions = new CadRasterizationOptions();
        vectorOptions.setPageWidth(1500);
        vectorOptions.setPageHeight(1500);
 
        PngOptions pngOptions = new PngOptions();
        //pngOptions.setVectorRasterizationOptions(rasterizationOptions);
        String outPath = dataDir + "foot.stl.png";
        cadImage.save(outPath, pngOptions);

        //ExEnd:ExportSTLToPNG
    }
}

From my understanding CadImage is use to get/set layouts of DWG and DXF files.
From before STL files can also have layouts.

So CadImage was used to cast STL image.

But now it cannot.
We can only cast it to STLImage.

@Schwraz,
Do you need to cast to CadImage to get access to layouts? Do you need layout names or something more specific?

I need to cast to CadImage to get layout names.

@Schwraz,
I have logged CADJAVA-10503 to research this problem and will come back with more information.

1 Like

But STL files have no layouts right? Not really sure though…maybe this is the reason for the change.

But DWG and DXF sure have layouts

@Schwraz,
yes, now I can confirm such changes. You are right, STL has no layouts.