API: SolidWorks Toolbox Manager Example (VB.NET, C#)

Version 37

    The SolidWorks Toolbox includes a library of standard components (parts) that users can insert into their assemblies. SolidWorks Enterprise PDM can be configured to manage the SolidWorks Toolbox. Third-party Product Data Management (PDM) applications can also manage the SolidWorks Toolbox. Either way, the advantages of using a PDM application include:

     

       * Document management of SolidWorks Toolbox parts. Parts can be automatically checked in or out of the PDM vault when they are

          accessed. 

       * Access control of Toolbox parts. User accounts and group permissions can be set up to provide security for the SolidWorks Toolbox. 

       * Decentralization of the SolidWorks Toolbox. SolidWorks Toolbox parts can reside in one or more vaults hosted by multiple archive

          servers.

     

     

    The attached ZIP file contains two Visual Studio 2010 solutions for managing the SolidWorks 2013 Toolbox using a third-party PDM:

     

     

       * TbcAddinSamples (C# solution)

         * ToolboxManager (C# add-in for SolidWorks Toolbox Browser)

         * TbcAddinSample (C# add-in for SolidWorks Toolbox Configurator)

       * VB.NET\TbcAddinSamples_VBNET (VB.NET solution)

         * ToolboxManager_VBNET (VB.NET add-in for SolidWorks Toolbox Browser)

         * TbcAddinSample_VBNET (VB.NET add-in for SolidWorks Toolbox Configurator)

     

    Only use these solutions when a third-party PDM manages SolidWorks Toolbox. The add-ins do not work with a SolidWorks Toolbox that is managed by Enterprise PDM.

    ToolboxManager

    Developed for SolidWorks 2013 and x86 machines using the SolidWorks API SDK add-in templates, this add-in:

     

       * Starts and connects to SolidWorks.

       * Handles SolidWorks events.

       * Disables the PropertyManager page and CommandManager of the SolidWorks SDK add-in template.

       * Connects to the SolidWorks Toolbox Browser add-in object.

       * Casts the object returned by GetAddinObject() to SolidWorks.Interop.swbrowser.IApplication,

          the entry point to the Toolbox Browser API.

       * Handles events from the SolidWorks Toolbox Browser.

     

     

     

     

    TbcAddinSample

     

    Developed for SolidWorks 2013 on x86 machines, this add-in:

     

       * Connects to the Welcome to Toolbox Setup dialog when it is opened with Toolbox > Configure.

       * Casts the application pointer to SolidWorks.Interop.sldtoolboxconfigureaddin.IToolBoxConfiguratorApplication,

          the entry point to the Toolbox Configurator API.

       * Handles events from the Welcome to Toolbox Setup dialog.

    Instructions

     

    1. Configure SolidWorks Toolbox.

        a.  Open SolidWorks 2013.

        b.  Set Tools > Options > Hole Wizard/Toolbox to the SolidWorks Toolbox that is managed by your third-party PDM.

        c.  Ensure that Tools > Add-ins enables and starts both the SolidWorks Toolbox and the SolidWorks Toolbox Browser add-ins.

        d.  Close SolidWorks.

     

    2. Configure add-in solutions in IDE.

        a.  Download and unzip the attached file in a convenient location.

        b.  Open either solution (VB.NET or C#) in Visual Studio 2010.

        c.  Modify the references of each add-in to point to the interop assemblies on your machine.

        d.  Right-click ToolboxManager in Solution Manager, select Properties > Debug, and browse to the version of sldworks.exe in

            Start external program to launch from the IDE.

     

    3. Modify SwAddin.

        a. Open ToolboxManager's SwAddin class.

        b. Set the ToolboxWorkFolder variable to an accessible folder on your machine.

        c. Some of the DPDMDocManagerEvents handlers are implemented to give you examples of document management. Modify the

            DPDMDocManagerEvents handlers to perform document management of your SolidWorks Toolbox Browser parts.

        d. Save the SwAddin class.

     

    4. Modify CTbcAddin.

        a. Open TbcAddinSample's CTbcAddin class.

        b. Set the ToolboxWorkFolder variable to an accessible folder on your machine.

        c. Some of the DPDMDocManagerEvents handlers are implemented to give you examples of document management. Modify the

            DPDMDocManagerEvents handlers to perform document management of your SolidWorks Toolbox Configurator parts.

        d. Save the CTbcAddin class.

     

    5. Modify EventHandling.

        a. Open ToolboxManager's EventHandling class.

        b. The DAssemblyDocEvents_FileDropPreNotifyEventHandler copies the dropped file to the ToolboxWorkFolder,

            sets the read-only attribute on the working file, and sets the dropped file name in the assembly document. Modify this event handler

            to suit your needs.

        c. Save the EventHandling class.

     

    6. Build and run the add-ins.

        a. Build the ToolboxManager add-in.

        b. Right-click the solution, select Properties, and modify the Debug Source Files to point to folders on your system that contain

            debugging source code.

        c. Select Debug > Start Debugging. The add-in connects to SolidWorks and the SolidWorks Toolbox Browser add-in.

        d. In SolidWorks, select Toolbox > Configure to open the Welcome to Toolbox Setup dialog.

        e. In the IDE select Tools (or Debug) > Attach to Process > SldToolboxConfigure.exe to load the Toolbox Configurator add-in

           and handle its events.

     

    Note: Each add-in project contains a post-build event that registers the DLL for x86 and .NET Framework 4. To see the post-build event:

    • VB.NET: Right-click ToolboxManager_VBNET in Solution Manager, select Properties, and click Build Events.
    • C#: Right-click ToolboxManager in Solution Manager, select Properties, and click Build Events

    - Subscription Services required for full access.

    - Looking for more API Examples?

     

    Copyright © 2011 Dassault Systèmes SolidWorks Corp. All rights reserved.
    Do not distribute or reproduce without the written consent of Dassault Systèmes SolidWorks Corp.