Macro value recovery of a sensor from the different configs

Hello

I'm trying to make a macro that retrieves the value of a sensor and a specific property (called Formatting) of each configuration and that opens a userform containing a 2-column array.

Formatting |   Sensor

 

Can you help me please?

Thank you

Hello

For sensors, look at this example that allows you to retrieve the value of a sensor.

https://help.solidworks.com/2020/English/api/sldworksapi/Get_and_Set_Sensor_Example_VB.htm?verRedirect=1

To list the configurations, 2 examples:

http://help.solidworks.com/2020/English/api/sldworksapi/Get_List_Of_Configurations_Example_VB.htm?verRedirect=1

http://help.solidworks.com/2017/English/api/sldworksapi/Change_Configuration_Properties_Example_VB.htm

Then I have a doubt that tonight can be more feasible in a userform or at worst export to Excel.

Hello

Thank you, I'm looking at this and yes indeed I'm looking to open it in a useform and not a msg box

Thanks again for the examples

Edit: the code for the sensors unfortunately doesn't work

I just tested it for me it works, you need an open room. And a sensor already created and selected before launching it.

Ah! 

Anyone have the solution to avoid having to select the sensor?

I looked a little on my side but unfortunately I get stuck.

Thank you

Here is a 1st link with code to list all the sensors, it works partially but it can give a good lead:

https://www.eng-tips.com/viewthread.cfm?qid=468348

'https://www.eng-tips.com/viewthread.cfm?qid=468348
Option Explicit
Sub main()
    Dim swApp As SldWorks.SldWorks
    Dim swPart As SldWorks.PartDoc
    Dim swModel As SldWorks.ModelDoc2
    Dim swFeat As SldWorks.Feature
    Dim swSubFeat As SldWorks.Feature
    Dim swSensor As SldWorks.Sensor
    Dim swDimSensor As SldWorks.DimensionSensorData
    Dim sensorValue As Double
    Dim text As String

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swFeat = swModel.FirstFeature

    Do While Not swFeat Is Nothing
    Debug.Print "swFeat.Name" & swFeat.Name
        If (swFeat.Name = "Capteurs") Then
            Set swSubFeat = swFeat.GetFirstSubFeature
            Do While Not swSubFeat Is Nothing
                Set swSensor = swSubFeat.GetSpecificFeature2
                'Mis en commentaire car ne fonctionne pas
                'swDimSensor = swSubFeat.GetSensorFeatureData
                'sensorValue = swDimSensor.sensorValue

                Debug.Print swSensor.Name & ": " & sensorValue
                Set swSubFeat = swSubFeat.GetNextSubFeature
            Loop
        End If
        Set swFeat = swFeat.GetNextFeature
    Loop
    MsgBox (text)
End Sub

Here is also a link with code in C++, you will have to do the translation in vba but the principle is there:

https://r1132100503382-eu1-3dswym.3dexperience.3ds.com/#community:yUw32GbYTEqKdgY7-jbZPg/iquestion:jpK7Vvu2QlugstMincAFoQ