Guide for dwg converter

1. Ignore list

There are three types of ignore lists. Let’s look at them using this text of 2 segments as an example.

Simple text:
Lorem Ipsum is simply dummy text of the printing and typesetting industry.

Soft

That’s the simplest one. If you want to hide a portion of a phrase. E.g. "simply dummy text of the printing and" Then, you get:

Simple text:
Lorem Ipsum is simply dummy text of the printing and typesetting industry.

Medium

This type will hide the whole segment, if it contains the target phrase. E.g. "simply dummy text of the printing and". Then, you get:

Simple text:
Lorem Ipsum is simply dummy text of the printing and typesetting industry.

Hard

The most “rigorous” type. The text will only be hidden if it is a perfect match. E.g. "Simple text:" and "simply dummy text of the printing and". Hidden will be segment 1 because it is a perfect match to our condition:

Simple text:
Lorem Ipsum is simply dummy text of the printing and typesetting industry.

After adding ignore lists, you can select them when extracting text from dwg or dxf to docx, by clicking "Add Ignore" and ticking the needed lists. Multiple lists can be selected.

2. Desired layers

After adding files, you can select the desired layers to extract the text. For this, click “Select desired layers”. Once layers have been processed (this may take some time depending on the number and size of files), you can tick the desired layers.

3. Auto-replace

You can create auto-replace lists using a link. Then, add desired files in the Replace tab and select lists.

4. API

API account

In order to use api you need to register. After that, in the dashboard section, click on the "Create New Client" button, specify the name and select "Create". You will receive a secret key, as well as a client id. The key is initially not active. To change its state you need to click on "Not Active/Active".

Application setup

In your application, install the GuzzleHttp client.

Dwg to docx conversion

$client = new \GuzzleHttp\Client();

try {
/**
* Make a request for verification of authorization.
* username - your login
* password - your password
* client_id and client_secret were obtained when creating the api key
*/
$response = $client->post('https://dwg2docx.com/oauth/token', [
'form_params' => [
'client_id' => 'client_id',
'client_secret' => 'client_secret',
'grant_type' => 'password',
'username' => 'your login',
'password' => 'your password',
]
]);
$auth = json_decode( (string) $response->getBody());

/**
* Create a conversion request
* $filename - the name of your dwg or dxf file
* $pathToFile - specify the path to your file, including the name
*/
$filename = 'test.dwg';
$pathToFile = 'path to file';
$response = $client->request('POST', 'https://dwg2docx.com/api/forward', [
'headers' => [
'Authorization' => 'Bearer ' . $auth->access_token,
],
'multipart' => [
[
'name' => 'file',
'contents' => fopen($pathToFile, 'r'),
'filename' => $filename,
]
]
]);

/**
* Get the finished docx and write to the file
* $archiveName - a unique key for reverse conversion
*/
$docxForTranslation = $response->getBody()->getContents();
$archiveName = $response->getHeaders()['archive'][0];

/**
* $newFile - specify the name of the new file
* $pathToNewFile - specify the path of the new file, including the name
*/
$newFile = 'test.docx';
$pathToNewFile = 'path to file';
$newFileDocx = fopen($pathToNewFile, 'w');
fwrite($newFileDocx, $docxForTranslation);
fclose($newFileDocx);

} catch (GuzzleHttp\Exception\BadResponseException $e) {
echo "Unable to retrieve access token.";
}

Convert docx to dwg or dxf

$client = new \GuzzleHttp\Client();

try {
/**
* Make a request for verification of authorization.
* username - your login
* password - your password
* client_id and client_secret were obtained when creating the api key
*/
$response = $client->post('https://dwg2docx.com/oauth/token', [
'form_params' => [
'client_id' => 'client_id',
'client_secret' => 'client_secret',
'grant_type' => 'password',
'username' => 'your login',
'password' => 'your password',
]
]);
$auth = json_decode( (string) $response->getBody());

/**
* Create a conversion request
* $filename - the name of your docx file
* $pathToFile - specify the path to your file, including the name
* $archiveName - unique key for converting to dwg or dxf, obtained when converting dwg to docx
*/
$filename = 'test.docx';
$pathToFile = 'path to file';
$archiveName = 'archive name your file';
$response = $client->request('POST', 'https://dwg2docx.com/api/forward', [
'headers' => [
'Authorization' => 'Bearer ' . $auth->access_token,
],
'query' => [
'archiveName' => $archiveName
],
'multipart' => [
[
'name' => 'file',
'contents' => fopen($pathToFile, 'r'),
'filename' => $filename,
]
]
]);

/**
* Get the finished drawing and write to the file
* $nativeName - the original file name
* $nativeExtension - the original file extension
*/
$fileAfterTranslation = $response->getBody()->getContents();
$nativeName = $response->getHeaders()['native'][0];
$nativeExtension = $response->getHeaders()['extension'][0];

/**
* $newFile - specify the name of the new file
* $pathToNewFile - specify the path of the new file, including the name
*/
$newFile = 'test.'$nativeExtension;
$pathToNewFile = 'path to file';
$newFileDwg = fopen($pathToNewFile, 'w');
fwrite($newFileDwg, $fileAfterTranslation);
fclose($newFileDwg);

} catch (GuzzleHttp\Exception\BadResponseException $e) {
echo "Unable to retrieve access token.";
}