DraftSight 2024:Get Started with Plugin Development/Customization

DraftSight 2024:Get Started with Plugin Development/Customization

DraftSight 2024: Get Started with Plugin Development/Customization

DraftSight is a powerful,professional-grade 2D and 3D CAD software designed for designers, engineers, architects, and hobbyists. The product was developed by Dassault Systèmes and is used across various industries, such as architecture, engineering, construction, manufacturing, design, and more. DraftSight offers a familiar user interface and comprehensive drafting tools, making creating, editing, and viewing DWG and DXF files easy.

  • It allows users to create, edit, view, and markup any type of 2D and 3D DWG file, providing reliable DWG file compatibility.
  • The software includes a familiar user interface to minimize the learning curve for users transitioning from other CAD applications.
  • It provides productivity tools and automation features like a G-Code generator, Toolbox, Image Tracer, Drawing Compare, and API integration.
  • DraftSight integrates with other Dassault Systèmes products like SOLIDWORKS, 3DEXPERIENCE Marketplace, and SOLIDWORKS PDM for enhanced collaboration and data management.
  • The software is available for Windows, macOS, and can be accessed through a web-based 3DEXPERIENCE platform.

In summary, DraftSight is a comprehensive 2D and 3D CAD solution that offers a wide range of features and flexibility to meet the needs of various design and engineering professionals. Let’s learn to create and tailor plugins for DraftSight 2024. Improve your workflow processes with our comprehensive guide to plugin development and customization. 

What Are Plugins?

Plugins are software components that add specific functionalities to an existing application or website. They act as extensions, allowing customization and optimization without altering the core codebase. At ProtoTech Solutions, we have developed over 100 CAD plugins for various Autodesk software. With more than 20 years of experience in developing 3D software solutions for the AEC and manufacturing industries, we have decided to share a guide on plugins for DraftSight. This guide aims to enhance your DraftSight experience with additional functionalities. You can develop a plugin by following the simple steps outlined below:

Plugins for DraftSight

Follow these detailed steps to integrate plugins into your DraftSight environment:

  • Created a new project in Visual Studio
  • Install template from  \ProgramFiles\DassaultSystemes\DraftSight\APISDK\DraftSightAddin2022VS 
  • Add System.Windows.Forms in References: When creating your add-in project, add the System.Windows.Forms reference. This is crucial for your plugin’s user interface components to function correctly within DraftSight.
  • Understand UAC Impact on Add-in Projects: If you utilize a DraftSight add-in template for your project, be aware that User Account Control (UAC) settings might affect the creation of the addinConfigs folder and the corresponding project-specific XML file. This folder is typically located at C:\ProgramData\DassaultSystemes\DraftSight\addinConfigs
  • Manual Creation of Project-Specific XML Files: In some cases, you may need to manually create the XML configuration file for each add-in project. The XML file should be named after your project, followed by the .xml extension (e.g., ProjectName.xml), and placed within the addinConfigs folder.
  • XML File Configuration: Inside the XML file, include the following template. This configuration template ensures that DraftSight recognizes and loads your plugin correctly
  <addinmanager>
  <DraftSightversion=“”>
  <addin help=“” startup=“1” name=“add-in_project_name” premiumOnly=“1”>
    <com clsid=“your_generated_add-in_COM_CLSID”></com>
    <button bitmap=“”></button>
  </addin>
  </draftsight>
</addinmanager>
  • Replace the version with the appropriate DraftSight version number.
  • Set startup to 1 to enable the add-in to load automatically on DraftSight startup.
  • Provide your add-in’s name in the name attribute.
  • The premium-only attribute can be set to 1 if the add-in is intended for premium users.
  • Insert the clsid of our generated add-in COM component in the <com> tag.

Adding Custom Ribbon in DraftSight

A ribbon is a command bar that organizes the features into a series of tabs at the top of the application 

  • In the project inside a main class DSAddin.cs just added methods for handling the creation and removal of the user interface ribbon.
  • The method used for creating ribbon
  // Command for setting
    m_CommandSetting = new CommandSetting(dsApp, AddinGuid);
    m_CommandSetting.registerCommand();
    dsCreateCommandError_e Error;
    UserCommand tb_standards_Setting = dsApp.CreateUserCommand(AddinGuid, m_CommandSetting.localName(), “^C^CMSetting”, “Shows the Ribbon items: MSetting”,
        “c:/Program Files/Dassault Systemes/DraftSight/APISDK/samples/C#/Simple/Ribbon/ToolBar_Large.png”,
        “c:/Program Files/Dassault Systemes/DraftSight/APISDK/samples/C#/Simple/Ribbon/ToolBar_Small.png”, dsUIState_e.dsUIState_Document, out Error);
new button to the row
        RibbonCommandButton dsRibbonSettingCmdBtn = dsRibbonRow.InsertRibbonCommandButton(AddinGuid,
            dsRibbonButtonStyle_e.dsRibbonButtonStyle_LargeWithText, “Settings”, tb_Setting_id) 

Traversing DraftSightdesign to Get All Entities

To traverse a sketch in DraftSight and access its entities, follow these simple steps:     

  • Retrieve Entities from SketchManager: Utilize the GetEntities method from dsSketchManager to retrieve the entities from the sketch. This method returns two output parameters: entityTypeLongArray and entitiesArray.
object entityTypeLongArray;
object entitiesArray;
dsSketchManager.GetEntities(null, null, out entityTypeLongArray, out entitiesArray);
  • Process Entities: Iterate through the entitiesArray to access each entity individually. Check the type of each entity and perform actions accordingly.
if (entitiesArray is object[] entityArray)
{
    foreach (var entity in entityArray)
    {
        if (entity is Circle circle)
        {
            // Process Circle entities
            Console.WriteLine(circle.GetArea());
        }
        else if (entity is Spline spline)
        {
            // Process Spline entities
            Console.WriteLine(spline.GetLength());
        }
        // Output the type of each entity
        Console.WriteLine(entity.GetType().Name);
    }
}

By following the above steps, we can easily traverse a sketch in DraftSight and perform actions on its entities, such as calculating areas of circles or lengths of splines. 

Plugins for DraftSight

Custom Plugin Development for CAD/CAM Software

At ProtoTech Solutions, we specialize in custom plugin development for CAD/CAM software, enhancing functionality and streamlining workflows for engineering and manufacturing professionals. Our expertise spans a variety of platforms, including AutoCAD, 3ds Max, Navisworks, Fusion 360, SolidWorks, SketchUp, Revit, and more. By tailoring plugins to specific needs, ProtoTech Solutions empowers users to automate tasks, integrate with other tools, and improve overall efficiency, driving innovation in design and production processes.