.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How convert DWG to DXF?

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Leonardo_Czuy
957 Views, 1 Reply

How convert DWG to DXF?

Hello for everyone, 

 

I am trying to convert DWG Files to DXF Files, i am using ODA File Converter, but i wanna use AUTODESK API for this convert, i have this code now but not working.

 

 

/ Função para obter o token de acesso
async function getAccessToken() {
  const response = await axios.post('https://developer.api.autodesk.com/authentication/v1/authenticate', {
    client_id: CLIENT_ID,
    client_secret: CLIENT_SECRET,
    grant_type: 'client_credentials',
    scope: 'data:read data:write data:create bucket:create bucket:read',
  }, {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  });

  return response.data.access_token;
}

// Função para converter DWG para DXF
async function convertDWGtoDXF(dwgFile) {
  const accessToken = await getAccessToken();

  const response = await axios.post('https://developer.api.autodesk.com/modelderivative/v2/designdata/job', {
    input: {
      urn: dwgFile,
    },
    output: {
      formats: [
        {
          type: 'dxf',
          views: ['2d'],
        },
      ],
    },
  }, {
    headers: {
      'Authorization': `Bearer ${accessToken}`,
      'Content-Type': 'application/json',
    },
  });

  return response.data;
}

 

 

Labels (1)
1 REPLY 1
Message 2 of 2
norman.yuan
in reply to: Leonardo_Czuy

When you say you want to use AutoCAD API, do you mean/realize that you need to run AutoCAD? The JavaScript code you post here is irrelevant, because it upload a drawing to a cloud service for the conversion, meaning the app on the user side running your code probably not run inside AutoCAD.

 

If you do want to use AutoCAD API to do the conversion, you need write code as AutoCAD plugin and execute the code INSIDE running AutoCAD session. See this post for the actual code (from @_gile )

 

https://forums.autodesk.com/t5/net/open-dwg-save-as-dxf-with-api-vb-net-or-c/m-p/11495623#M74488 

 

 

Norman Yuan

Drive CAD With Code

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report