This content has been marked as final. Show 8 replies
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....)
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.
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.
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.
I modified the sample macro to output the length of the curve in Solidworks.Thats the best I can do with my limited Vb knowledge.Now we need the assistance of SolidAir to write this as a Custom Property.
Thanks for the API but we do not use any programming. We feel that for the price we pay, SolidWorks should perform the tasks we require. We spend enough time testing to make all of our connected systems work and do not want to have to upgrade and test additional programs.
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.
Try the attached code.Please note that the values would be visible in the "immediate" window in VB.
' A list of return status values for the ModelDocExtension::GetMassProperties API
Public Enum swMassPropertiesStatus_e
swMassPropertiesStatus_OK = 0
swMassPropertiesStatus_UnknownError = 1
swMassPropertiesStatus_NoBody = 2
Public Enum swUserPreferenceToggle_e
swUpdateMassPropsDuringSave = 30
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
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)