Private Sub Form_Load()
Dim objApp As SolidEdgeFrameWork.Application
Dim objDoc As SolidEdgePart.PartDocument
Dim objBody As SolidEdgeGeometry.Body
Dim dblDensity As Double, dblAccuracy As Double, dblVolume As Double
Dim dblArea As Double, dblMass As Double, dblCGravity(1 To 3) As Double
Dim dblCVolume(1 To 3) As Double, dblGMomInertia(1 To 6) As Double, dblPMomInertia(1 To 3) As Double
Dim dblPrinAxes(1 To 9) As Double, dblRadGyration(1 To 3) As Double, dblRAccAchieved As Double
Dim lngStat As Long
Const TESTFILE = "T:\vbtests\testcases\cube.par"
' Report errors
Const PI = 3.14159265358979
' Create/get the application with specific settings
On Error Resume Next
Set objApp = GetObject(, "SolidEdge.Application")
If Err Then
Err.Clear
Set objApp = CreateObject("SolidEdge.Application")
Set objDoc = objApp.Documents.Add("SolidEdge.PartDocument")
objApp.Visible = True
Else
Set objDoc = objApp.ActiveDocument
End If
Call objDoc.Close
' opening the test case file
Set objDoc = objApp.Documents.Open(TESTFILE)
' getting the body object of the model
Set objBody = objDoc.Models(1).Body
' getting the PhysicalProperties collection for the Body object
dblDensity = 1
dblAccuracy = 0.001
Call objBody.ComputePhysicalProperties(Density:=dblDensity, Accuracy:=dblAccuracy, _
Volume:=dblVolume, Area:=dblArea, Mass:=dblMass, CenterOfGravity:=dblCGravity, _
CenterOfVolume:=dblCVolume, GlobalMomentsOfInteria:=dblGMomInertia, _
PrincipalMomentsOfInteria:=dblPMomInertia, PrincipalAxes:=dblPrinAxes, _
RadiiOfGyration:=dblRadGyration, RelativeAccuracyAchieved:=dblRAccAchieved, Status:=lngStat)
' USER DISPLAY
' Release objects
Set objApp = Nothing
Set objDoc = Nothing
Set objBody = Nothing
End Sub