8 Replies Latest reply on Sep 15, 2010 3:33 PM by Josh Brady

    Mass Properties

    Zachary Lovering

      Is there any way to change the massproperty defaults in a VB macro to change things like the coordinate system, accuracy setting (default vs maximum precision), or units? The defaults seems to be the document coordinate system, default level of precision, and SI units.


      Update: Just to give you an idea of what I am doing, I am trying to write some property values of a part to a text file. Here is a portion of my code...



      Open "C:\testfile.txt" For Output As #1
      Set swApp = Application.SldWorks
      Set swModel = swApp.ActiveDoc
      Set swDocExt = swModel.Extension
      Set swMass = swDocExt.CreateMassProperty
      Set swSelMgr = swModel.SelectionManager
      Set swComp = swSelMgr.GetSelectedObjectsComponent2(1)
      vCoM = swMass.CenterOfMass
      vMoI = swMass.GetMomentOfInertia(swMassPropertyMomentAboutCenterOfMass)
      vPrinAoIx = swMass.PrincipleAxesOfInertia(0)
      vPrinAoIy = swMass.PrincipleAxesOfInertia(1)
      vPrinAoIz = swMass.PrincipleAxesOfInertia(2)
      vPrinMoI = swMass.PrincipleMomentsOfInertia

      Write #1, swMass.Density 'density in kg/m^3

      Write #1, vCoM(0) 'center of mass in x, m

      Write #1, vCoM(1) 'center of mass in y, m

      Write #1, vCoM(2) 'center of mass in z, m


      and I continue outputting the other properties. My issue is that I would prefer that the default output of these value is in US Customary units (I understand that I can just multiply by a constant, but it would be cleaner for me if I didn't have to). I would also like to change the coordinate system used for calculating the mass properties and to change the setting to be "maximum precision" rather than "default precision".