7 Replies Latest reply on Jun 23, 2015 12:00 PM by Arif Akbas

    Macro to meters³ set kg meters  in units

    Arif Akbas

      hello

       

      How to

       

       

       

       

       

       

      Dim swApp As Object

       

       

      Dim Part As Object

      Dim boolstatus As Boolean

      Dim longstatus As Long, longwarnings As Long

       

       

      Sub main()

       

       

      Set swApp = _

      Application.SldWorks

       

       

      Set Part = swApp.ActiveDoc

      Dim myModelView As Object

      Set myModelView = Part.ActiveView

      myModelView.FrameState = swWindowState_e.swWindowMaximized

      boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitSystem, 0, swUnitSystem_e.swUnitSystem_Custom)

      boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsMassPropMass, 0, swUnitsMassPropMass_e.swUnitsMassPropMass_Kilograms)

      End Sub

       

       

       

       

       

       

       

       

      Ekran Alıntısı.JPG

        • Re: Macro to meters³ set kg meters  in units
          J. C

          Hi,

          Not completey sure about what you are trying to do.

           

          If you need to change the units like they are in the pic then you can add the followin to your macro:

           

          boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsMassPropVolume,0, swUnitsMassPropVolume_e.swUnitsMassPropVolume_Meters3)

          boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsMassPropLength, 0, swLengthUnit_e.swMETER)

            • Re: Macro to meters³ set kg meters  in units
              Arif Akbas

               

              Change units as in the picture

              change units

              meters kg meters³

              change units macro

              add .swp

              add macro

                • Re: Macro to meters³ set kg meters  in units
                  J. C

                  there:

                   

                   

                  Dim swApp As Object

                   

                   

                  Dim Part As Object

                  Dim boolstatus As Boolean

                  Dim longstatus As Long, longwarnings As Long

                   

                   

                  Sub main()

                   

                   

                  Set swApp = _

                  Application.SldWorks

                   

                   

                  Set Part = swApp.ActiveDoc

                  Dim myModelView As Object

                  Set myModelView = Part.ActiveView

                  myModelView.FrameState = swWindowState_e.swWindowMaximized

                  boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitSystem, 0, swUnitSystem_e.swUnitSystem_Custom)

                  boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsMassPropMass, 0, swUnitsMassPropMass_e.swUnitsMassPropMass_Kilograms)

                  boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsMassPropVolume,0, swUnitsMassPropVolume_e.swUnitsMassPropVolume_Meters3)

                  boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsMassPropLength, 0, swLengthUnit_e.swMETER)

                  End Sub

                      • Re: Macro to meters³ set kg meters  in units
                        Arif Akbas

                        hello

                         

                        millimeters

                         

                        Change units as in the picture

                        change units

                        meters kg meters³

                        change units macro

                        add .swp

                        add macro

                         

                         

                         

                         

                        Ekran Alıntısı.JPG

                          • Re: Macro to meters³ set kg meters  in units
                            Deepak Gupta

                            You could set the units to something different. Then start recording a macro and change the units to what you need. Finally refine the codes and you should be all set.

                              • Re: Macro to meters³ set kg meters  in units
                                Arif Akbas

                                Dim swApp As Object

                                 

                                 

                                Dim Part As Object

                                Dim boolstatus As Boolean

                                Dim longstatus As Long, longwarnings As Long

                                 

                                 

                                Sub main()

                                 

                                 

                                Set swApp = _

                                Application.SldWorks

                                 

                                 

                                Set Part = swApp.ActiveDoc

                                Dim myModelView As Object

                                Set myModelView = Part.ActiveView

                                myModelView.FrameState = swWindowState_e.swWindowMaximized

                                boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitSystem, 0, swUnitSystem_e.swUnitSystem_Custom)

                                boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsMassPropMass, 0, swUnitsMassPropMass_e.swUnitsMassPropMass_Kilograms)

                                boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsMassPropVolume,0, swUnitsMassPropVolume_e.swUnitsMassPropVolume_Meters3)

                                boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsMassPropLength, 0, swLengthUnit_e.swMETER)

                                End Sub

                                 

                                 

                                 

                                It did not work

                                how will it be

                                 

                                boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsMassPropLength, 0, swLengthUnit_e.swMillimeters)