- 11 Sep 2024
- 4 Minutes to read
- Print
- DarkLight
Generating AutoCAD Drawing
- Updated on 11 Sep 2024
- 4 Minutes to read
- Print
- DarkLight
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:
- Enable the AutoCAD functionality.
- Add your credentials to the properties file.
- Upload base AutoCAD drawings.
- 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 name | Description |
---|---|
autodesk.client_id | Client ID of the Forge app. |
autodesk.client_secret | Client secret of the Forge app. |
autodesk.engine_version | AutoCAD 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:
- From the application left navigation area, select Model.
- From the top navigation bar, select AutoCAD Management.
- 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.
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 name | Class | Description |
---|---|---|
salesItemsTree | SalesItemsTree | Represents the quote. Contains functions you can use to query and modify the quote and its line items. |
drawingTitle | String | AutoCAD drawing name as defined while creating it. |
drawingNumber | Integer | Unique 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:
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.
Select Create.
(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 theList<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:
From the application left navigation area, select Administration.
From the top navigation bar, select Master Data Management.
Scroll or search to locate Setting String and select it from the list.
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
In the Setting Value String field, use the following parameters to define the name format:
- {QUOTE_ID}
- {QUOTE_TITLE}
- {VERSION}
- {OBJECT_NAMES}