3 Replies Latest reply on Jun 25, 2017 2:42 PM by Deepak Gupta

    Mass Properties

    Eddie Capps

      I have a simple macro that overrides the Mass Properties of a part. I use it to assign a weight to a purchased part. (Example: A Bearing)

      The macro will open the Mass Properties window. It goes to the Override Mass Properties page, prompt you for the new mass of the part. Then closes

      that page. Here's my problem. The Mass Properties window stays open. Any ideas??

      Thanks in advanced for anyone's help.

        • Re: Mass Properties
          Deepak Gupta

          Why are you opening that window? You can set an input box to get the value and apply the factor for unit conversion based on the model unit.

           

          Option Explicit

          Dim swApp       As SldWorks.SldWorks

          Dim swModel     As SldWorks.ModelDoc2

          Dim MyMassProp  As SldWorks.MassProperty

           

          Sub main()

              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc

              Set MyMassProp = swModel.Extension.CreateMassProperty   

              MyMassProp.OverrideMass = True

             

              'Change Weight Value Here. Use conversion factor as needed.

              MyMassProp.SetOverrideMassValue 10, swThisConfiguration, Nothing

           

          End Sub

            • Re: Mass Properties
              Eddie Capps

              Thanks for the advice. I'm new to writing macros. So I always start by recording my steps. Then make some changes. That's how I got to opening this window. But I'm learning. Again, thanks for your help.

                • Re: Mass Properties
                  Deepak Gupta

                  Eddie Capps wrote:

                   

                  Thanks for the advice. I'm new to writing macros. So I always start by recording my steps. Then make some changes. That's how I got to opening this window. But I'm learning. Again, thanks for your help.

                  Glad to know that you're trying and learning.. Keep it up