Generating AutoCAD Drawing
  • 11 Sep 2024
  • 4 Minutes to read
  • Dark
    Light

Generating AutoCAD Drawing

  • Dark
    Light

Article summary

Purpose

Allows you to run a script to generate an AutoCAD drawing based on the quote structure. A script must include the business logic for creating the drawing, and indicate whether to represent each line item in it.

Setup

To set up the extension point, follow these steps:

  1. Enable the AutoCAD functionality.
  2. Add your credentials to the properties file.
  3. Upload base AutoCAD drawings.
  4. Create a Groovy script.

Enable the AutoCAD functionality

Zilliant CPQ's AutoCAD functionality is powered by the Autodesk Forge platform. Contact your Zilliant representative to create an Autodesk Forge subscription and enable the AutoCAD functionality in your environment.

Add credentials to the properties file

After creating an Autodesk Forge subscription, add your credentials to the application.properties file using the variables from the table below. Then restart the server.

Variable nameDescription
autodesk.client_idClient ID of the Forge app.
autodesk.client_secretClient secret of the Forge app.
autodesk.engine_versionAutoCAD version you want to use.

Upload base AutoCAD drawings

The system doesn't generate AutoCAD drawings from scratch. It creates the final output by combining multiple existing drawings with dynamically generated elements like text. Each of these drawings can either be stored as separate files or as predefined blocks in a file.
Before the script can use these components, you must upload files containing the drawings or blocks. The supported file format is .dwg.

To upload the base drawings, follow these steps:

  1. From the application left navigation area, select Model.
  2. From the top navigation bar, select AutoCAD Management.
  3. Select + to upload a .dwg file.

Create a Groovy script

Create a Groovy script in Zilliant CPQ by making the following selections:

  • Select Generate Autocad Drawing as the script type.
  • In the Base DWG File field, select a .dwg file based on which you want to create drawings.
Note

All elements of the selected .dwg file are included in all drawings generated with this script. Additionally, you can use all blocks defined in this file for the drawing composition.

Binding variables

In addition to the common binding variables, the following binding variables are available for this extension point.

Variable nameClassDescription
salesItemsTreeSalesItemsTree Represents the quote. Contains functions you can use to query and modify the quote and its line items.
drawingTitleStringAutoCAD drawing name as defined while creating it.
drawingNumberIntegerUnique running number for the drawing that will be autogenerated by the system.

Expected output

The script should return one of the following objects:

  • AutocadScript
  • List<AutocadScript>
  • Map<String, List<AutocadScript>>

Each AutocadScript object corresponds to a .scr script file, which is executed against a base file to generate a drawing. If the script returns a list, it means that it created multiple drawings. If the script returns a map, it means that it created several groups of drawings.

The system supports only 2D drawings. They are represented by the AutocadScript2D class that allows you to perform the following actions:

  • Insert a predefined block from the base .dwg file with an ability to rotate and scale it. Additionally, you can set attribute values for the block.
  • Insert a drawing from an uploaded file with an ability to rotate and scale it.
  • Add text.
  • Insert aligned dimension measurements.
  • Draw straight lines.

Additionally, you can add arbitrary commands. You can use any command that can be executed in a .scr script and run successfully in the AutoCAD desktop application. This allows you to use features that are not directly supported by the system.

Script execution

A user must manually run the script when creating an AutoCAD drawing. To execute the script, follow these steps:

  1. Open a quote.

  2. On the AutoCAD tab, select + to create a drawing. Enter information or make selections:

    • Title—Drawing name. To automatically generate drawing names, read the corresponding section below.
    • View Type—Select a Groovy script of the Generate Autocad Drawing type to create a drawing.
    • Select Item to Draw—Select at least one sales item to generate a drawing.
  3. Select Create.

  4. (Optional.) You can download or view a generated drawing on the AutoCAD tab:

    • To download a .dwg file, select Download in the DWG File column.
    • To download a .pdf file, select Download in the PDF File column.
    • To view a drawing, select View in the Open in Viewer column.

The drawings appear on the AutoCAD tab in a quote.

  • If the script returns the AutocadScript object or the List<AutocadScript> object, drawings are added to a group with the name matching the defined drawing title.
  • If the script returns the Map<String, List<AutocadScript>> object, each entry in the map becomes a group.

Automatically generate names for drawings

You can configure the AutoCAD names for drawings to be automatically generated every time you create a new drawing in a quote. To do this, follow these steps:

  1. From the application left navigation area, select Administration.

  2. From the top navigation bar, select Master Data Management.

  3. Scroll or search to locate Setting String and select it from the list.

  4. Select a scenario for which to define the name format:

    • The format for AutoCAD drawing title when all sales items are selected
    • The format for AutoCAD drawing title when only one or a few sales items are selected
  5. In the Setting Value String field, use the following parameters to define the name format:

    • {QUOTE_ID}
    • {QUOTE_TITLE}
    • {VERSION}
    • {OBJECT_NAMES}

Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.