# Automatic DWG File Locking For Autodesk AutoCAD

When opening an AutoCAD® DWG drawing from a <code class="expression">space.vars.PRODUCT\_NAME</code> network drive, <code class="expression">space.vars.PRODUCT\_NAME</code> will take out a lock on the file to ensure that only one user at a time can edit the drawing. <code class="expression">space.vars.PRODUCT\_NAME</code> will also ensure that when a user opens the drawing, the latest version of the drawing is opened. Together, this helps to prevent changes from being unintentionally overwritten.

The locking support is automatic. The user does not need to perform any specific steps to lock/unlock or check out/check in the drawing. The behaviour should be familiar to users working with AutoCAD® drawings on local file servers.

On opening a DWG drawing file, <code class="expression">space.vars.PRODUCT\_NAME</code> will check if it is locked. If so, the user will see the familiar alert from AutoCAD®. The alert will show the username of the user that is editing the drawing and the SharePoint site where the drawing is located.

<figure><img src="https://4182749601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBkDVFDwNmEHlZv1KwwiY%2Fuploads%2FAoWwkMIzUfnHLLlZUczN%2Fimage.png?alt=media&#x26;token=81f73330-e14b-46ea-b330-d2c8629eded3" alt=""><figcaption></figcaption></figure>

If the drawing was not already locked, AutoCAD® will proceed to open the drawing and a lock will be taken out. <code class="expression">space.vars.PRODUCT\_NAME</code> will regularly refresh the lock whilst the drawing is opened. On closing the drawing in AutoCAD®, the lock will automatically be released.

If there is a more recent version of the drawing available then AutoCAD® will show an alert to the user when opening the drawing. The user should click OK and open the drawing again and <code class="expression">space.vars.PRODUCT\_NAME</code> will ensure they are opening the latest version.

<figure><img src="https://4182749601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBkDVFDwNmEHlZv1KwwiY%2Fuploads%2FZRlHfXpguOHtHZ6Hlya1%2Fimage.png?alt=media&#x26;token=4802e6a0-61ee-48ff-b88a-35ee144af669" alt=""><figcaption></figcaption></figure>

<code class="expression">space.vars.PRODUCT\_NAME</code> locking support has been tested to work with AutoCAD® 2024 and AutoCAD LT® 2024. Prior versions of AutoCAD® should also be compatible.
