How to Convert DWG AutoCAD to PNG in Python using Aspose.CAD REST API?

Hi everyone!
I first use Aspose to convert .dwg file to .png file by python SDK. But it can’t work and throw ApiException as following, and I doubt that error file path cause it.

raise ApiException(
asposecadcloud.rest.ApiException: ('404 Error connecting to the API https://api.aspose.cloud/v3.0/cad/HPB11.dwg/saveAs/png; Message: Not Found', 404, {'code': 'errorItemNotFound',
'description': 'Operation Failed. Item Not Found.',
'inner_error': None,
'message': 'The storage myStorage was not found or is not associated with the '
'application.'})

My code as follows.

import os
from asposecadcloud import CadApi
import asposecadcloud.models.requests as requests

app_sid = 'xxx'
app_key = 'xxx'
base_url = 'https://api.aspose.cloud/'
api_version = 'v3.0'
cad_api = CadApi(app_key=app_key, app_sid=app_sid, base_url=base_url, api_version=api_version)

request = requests.GetDrawingSaveAsRequest(name='HPB11.dwg', output_format='png', folder='./input/HPB11.dwg', out_path='./output/HPB11.png', storage='myStorage')
cad_api.get_drawing_save_as(request=request)

My storage layout as follows.

Could I trouble you to solve the above problem? Thanks!
storage2.png (19.3 KB)
storage1.png (16.9 KB)

@shiki

We are sorry for the inconvenience. I tried to convert DWG AutoCAD to PNG in Python using Aspose.CAD Cloud SDK for Python and notice the reported issue. So logged a ticket CADCLOUD-471 for further investigation and rectification. We will notify you as soon as it is resolved.

Convert DWG to PNG in Python without AutoCAD

# import modules
import os
from asposecadcloud import CadApi
import asposecadcloud.models.requests as requests

# Get your Client ID and Client Secret at https://dashboard.aspose.cloud (free registration is required).
app_sid = 'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx'
app_key = 'xxxxxxxxxxxxxxxxxxxxxx'
base_url = 'https://api.aspose.cloud'
api_version = 'v3.0'
# instantiate Aspose.CAD Cloud API
cad_api = CadApi(app_key=app_key, app_sid=app_sid, base_url=base_url, api_version=api_version)

# Convert DWG to PNG
convertDWGtoPNGRequest = requests.GetDrawingSaveAsRequest(name='sample.dwg', output_format='png', out_path='sample_cad.png', storage='MyDB_Storage')
cad_api.get_drawing_save_as(request=convertDWGtoPNGRequest)

I get it. Thank you for your prompt reply.

1 Like