1 Reply Latest reply on Oct 16, 2015 3:47 PM by John Alexander

    How I get the values of the measurement sensors in an assembly per VBA?

    David Trinkle



      How can I address a measurement sensor by VBA.

      I want to get the measured values from the sensor and export the values to Excel.

      Or can to get all sensor values by for-Loop and then Export.

      I have knowledge in VBA with Excel commands and not Solidworks commands.

        • Re: How I get the values of the measurement sensors in an assembly per VBA?
          John Alexander

          I haven't used sensors but I can point you in the right direction.


          The Solidworks API documentation isn't perfect but it does happen to be the exclusive resource for finding this sort of information out. I would recommend taking a look at it.


          Every object in the API has an Interface page and a Members page in the documentation. If you want to find how to get a reference to a particular object, every method that creates it will be listed on the Interface page under Accessors. If you recursively trace the accessors backwards (in the documentation), you should eventually lead to the Solidworks application object that gives access to the API in vba. Meanwhile, the Members page will list every member and method available from that object. Usually a link to the members page is at the bottom of the interface page under See Also (and vice versa).


          It looks like ISensors give get and set access to the sensor trigger value and the state so this is probably a good place to start looking.