API: Using ISldWorks.PostMessageToApplication from C#

Version 4

    A Visual Studio 2008 example is provided to demonstrate the use of the SolidWorks API method:

     

       ISldWorks.PostMessageToApplication

     

     

    from a C# add-in.

     

    For illustration purposes the ModifyNotify event handler for Part and Assembly document is used.
    In general little work can be done in the ModifyNotify event handler, as SolidWorks is typically still in the process of making a modification, and the model may not be in a consistent state yet. Hence a message is posted, which is processed later.

    Here "later" is determined by which other messages are in the Windows message queue.

     

    The example illustrates the use of a callback data helper class "AddinCallbackData", which makes it easier to get data across from the post site to the processing site.

     

    Other methods involved:

     

    ISldWorks.AddCallback
    ISldWorks.RemoveCallback

     

     

    Minimum SolidWorks version:

     

    - for 32-bit  SolidWorks 2010

    - for 64-bit  SolidWorks 2011  to be able to use ISldWorks.PostMessageToApplicationx64

     

     

    Add references to the following Interop Assemblies:

     

    SolidWorks.Interop.sldworks.dll
    SolidWorks.Interop.swcommands.dll
    SolidWorks.Interop.swconst.dll
    SolidWorks.Interop.swpublished.dll
    SolidWorksTools.dll

     

    for your version of SolidWorks.


    A helper class "Win32" is added to be able to determine on what kind of OS SolidWorks is running:

     

      32-bit
      32-bit WOW64 on 64-bit
      64-bit


    This class uses P/Invoke.


    ==============================================================

    This item is also published as Solution S-054481 in the SolidWorks Knowledge Base.

     

     

    Note:
    - 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.