8 Replies Latest reply on Oct 21, 2008 3:34 AM by Feroz Mahomed

    Moments of inertia at centroid

    Feroz Mahomed

      Hi,

      I require assitance with setting up a custom property for the moments of inertia.I specifically require the Ixx & Iyy values.These values must be the same as the values one gets by using the Measure-Section Properties tool.

      Eg. If one draws a flat bar 100mm x 5mm one gets Ixx - 1041.667 & Iyy - 416666.7.

      Thank You

      Feroz Mahomed
      Sw2007 sp4.0
        • Moments of inertia at centroid
          Hi Feroz

          In the property manager, create a property Ixx (for example) set it to text and in the text/value field select in the combo box the right property (when you deploy the box the first value is material, and at the end of the list you've a serie of Lxx, Lxy....)
            • Moments of inertia at centroid
              Feroz Mahomed
              Boinon,

              Thanks for the help. I have done this already.The values I get are the same as what one gets when using Measure - Mass Properties.I require the values that show up if you use Measure - Section Properties. I have found a macro in the help menu that shows the correct value within Visual basic when the macro is run.It would be good if this information can be written to the part file as custom properties.

              Thank You

              Feroz Mahomed
                • Moments of inertia at centroid
                  Eddie Cyganik
                  Feroz,

                  I agree with you, a Custom or Configuration Specific File Property should be capable of capturing any measured value. As you have found, only the "mass" properties are available, not the section properties. I have a specific requirement where I want to capture the length of a curve. As it is now, I have to measure and then manually update the file property.
                    • Moments of inertia at centroid
                      Feroz Mahomed
                      Eddie,

                      My visual basic knowledge is zero. However, I found an example in the api help that does what you are looking for.By selecting a curve and running the macro you get the length of the curve.The problem is the value is output within Vb in the intermediate window.I know it is possible to get this value to come up in a pop up window in SolidWorks. I suggest you ask SolidAir for help as he has helped me previously by writing a macro to write specific values as custom properties that update my drawing sheet automatically.

                      Feroz Mahomed
                • Moments of inertia at centroid
                  Les Meares
                  Feroz,

                  Did you ever find a way to get Ixx,Iyy,Izz (All 9 of the moments of inertia)? I can see The methods for Ix...&Lxx... but am still having dificulty with the last 9 values.
                    • Moments of inertia at centroid
                      Feroz Mahomed
                      Les,

                      Try the attached code.Please note that the values would be visible in the "immediate" window in VB.

                      Option Explicit

                      ' A list of return status values for the ModelDocExtension::GetMassProperties API

                      Public Enum swMassPropertiesStatus_e

                      swMassPropertiesStatus_OK = 0

                      swMassPropertiesStatus_UnknownError = 1

                      swMassPropertiesStatus_NoBody = 2

                      End Enum

                      Public Enum swUserPreferenceToggle_e

                      swUpdateMassPropsDuringSave = 30

                      End Enum

                      Sub main()

                      Dim swApp As SldWorks.SldWorks

                      Dim swModel As SldWorks.ModelDoc2

                      Dim swModelExt As SldWorks.ModelDocExtension

                      Dim swAssy As SldWorks.AssemblyDoc

                      Dim swSelMgr As SldWorks.SelectionMgr

                      Dim swComp As SldWorks.Component2

                      Dim nStatus As Long

                      Dim vMassProp As Variant



                      Set swApp = CreateObject("SldWorks.Application")

                      Set swModel = swApp.ActiveDoc



                      Set swModelExt = swModel.Extension

                      vMassProp = swModelExt.GetMassProperties(1, nStatus)



                      Debug.Print "ModelDocExtension::GetMassProperties(" + swModel.GetPathName + ")"

                      Debug.Print " Status = " & nStatus

                      Debug.Print ""

                      If Not IsEmpty(vMassProp) Then

                      Debug.Print " CenterOfMassX = " & vMassProp(0)

                      Debug.Print " CenterOfMassY = " & vMassProp(1)

                      Debug.Print " CenterOfMassZ = " & vMassProp(2)

                      Debug.Print " Volume = " & vMassProp(3)

                      Debug.Print " Area = " & vMassProp(4)

                      Debug.Print " Mass = " & vMassProp(5)

                      Debug.Print " MomXX = " & vMassProp(6)

                      Debug.Print " MomYY = " & vMassProp(7)

                      Debug.Print " MomZZ = " & vMassProp(8)

                      Debug.Print " MomXY = " & vMassProp(9)

                      Debug.Print " MomZX = " & vMassProp(10)

                      Debug.Print " MomYZ = " & vMassProp(11)

                      End If

                      Debug.Print "-------------------------------"

                      End Sub