An introduction to DraftSight customization

First of all, in this article I’m writing for the widest possible audience, so there won’t be code snippets or specific instructions in the article. Instead, this is an introduction to the capabilities and possibilities in the DraftSight Application Programming Interface (API).

When Vivek Allu introduced his SOLIDWORKS World 2019 session on the DraftSight API , two facts quickly became clear. One, this is programming, so prior experience in writing code is necessary. Two, it is possible for someone with only basic programming knowledge to quickly build functional add-on apps in DraftSight 2019.

By definition an API is a set of programming features for creating applications that access both the features of a program (or operating system, etc.) and the data created or held by it. In DraftSight, you write instructions that execute DraftSight commands to retrieve and use design data. Several add-on products are available for DraftSight; they were written primarily using the DraftSight API (known internally as “DSAPI”.) The API was also used to create a connection between the online utility HomeByMe, a Dassault Systemès free tool for personal interior design.  

Dassault Systemès HomeByMe is a free online utility for interior design. DraftSight 2019 users can interact with HomeByMe to import and export design data.

 

Once you pass the hurdle of needing to know how to write code, DraftSight becomes a very flexible work environment. Several programming languages can be used to create new apps for DraftSight, including C++ (native or .com); C#/VB .NET; VBA; and JavaScript. There are a series of Visual Basic templates available by request from DraftSight. All API apps created for DraftSight 2019 will be forward compatible. All entity types in DraftSight are accessible by the API. And the best thing of all, for the potential users of an app, is that the DraftSight User Interface carries over into the app.

Allu started his presentation by using Visual Basic to build a simple app. He said it is best to work in DraftSight’s Admin mode. There is a snippet of code that is needed no matter the app, which he copied into the work space. Using existing code and cut/paste of various DraftSight commands, in less than five minutes Allu wrote a simple routine that places selected geometry in response to user input.

Next Allu — DraftSight’s Associate Portfolio Technical Manager — used the API to design a Bill of Materials (BOM) table. He created a new task pane, inserted a Windows form inside the pane, dragged three buttons to add commands, and created a Delete option. He showed how easy it is to flip between DraftSight specifics and the programming of the new app’s workflow.  “This does require programming knowledge,” Allu reminded the full room of DraftSight users, “but not at an expert level.”

Allu was not the only presenter on the DraftSight API. Robert Graebert (CTO of software Graebert GmbH) and Ram Chilukuri (DraftSight R&D Senior Manager) led a session on using DraftSight with other applications. While the purpose was to introduce some excellent new tools, there was also discussion about DSAPI in the Q&A. One tip from their session was how quickly new apps can be written by starting with recording a macro. Usually a macro is created to simplify repetitive tasks. When recorded, DraftSight saves the sequences in the macro as DSAPI code, with calls to the program that correspond to the action on the screen. A DSAPI programmer can take this code and adapt it to a new app.

In Allu’s session and a conference-ending Q&A, there were lively discussions about troubleshooting APIs. I was reminded of the old saying from the early days of open source programming,  “With enough eyes all bugs are shallow.” The DraftSight team works hard to make the API a great utility, but they can’t test every possible application. In such situations the API developer and the DraftSight support team need to work together. Dassault Systemès realizes they are blazing a new trail by making DraftSight a commercial application with no permanent free version; they are eager to support app developers to ensure the best possible outcomes for their customers.

The following video provides an overview of using DraftSight with HomeByMe.

IMPORTANT:

DraftSight 2019 for Windows® is offered in paid versions only.
Once you download and install DraftSight 2019 (free 30-day trial or purchased version), you will no longer be able to re-download or access any previous free version of DraftSight (2018 or earlier). All free versions of DraftSight (2018 or earlier) will cease to run after 12/31/2019.

Learn more about DraftSight 2019 here.

Randall Newton
Randall S. Newton is Managing Director of Consilia Vektor, a boutique consulting firm serving the engineering software industry. He is a Contributing Editor at Digital Engineering and AEC Magazine UK. You can follow him on Twitter.
Randall Newton
Randall Newton