Private Sub Form_Load()
Dim objApp As SolidEdgeFramework.Application
Dim objDoc As SolidEdgePart.PartDocument
Dim objModel As SolidEdgePart.Model
Dim objExtProt As SolidEdgePart.ExtrudedProtrusion
Dim objCutOut As SolidEdgePart.ExtrudedCutout
Const TESTFILE = "T:\vbtests\testcases\freeform.par"
Const TOLERANCE = 0.0001
Dim dblDensity As Double
Dim dblAccuracyIn As Double
Dim dblAccuracyOut As Double
Dim dblVolume As Double
Dim dblArea As Double
Dim dblMass As Double
Dim dblCofGravity() As Double
Dim dblCofVolume() As Double
Dim dblGlobalMoments() As Double
Dim dblPrincipalMoments() As Double
Dim dblPrincipalAxes() As Double
Dim dblRadiiOfGyration() As Double
Dim lngStatus As Long
' 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
' Close the part document
Call objDoc.Close
' Open a Testcase
Set objDoc = objApp.Documents.Open(Filename:=TESTFILE)
' Get the model object in the test case
Set objModel = objDoc.Models(1)
' Get the feature objects
Set objExtProt = objModel.ExtrudedProtrusions(1)
Set objCutOut = objModel.ExtrudedCutouts(1)
' ***** CASE 1 : DisplayPart set to FALSE
' Set RollToFeature to ExtrudedProtrusions(1)
Call objModel.RollToFeature(Feature:=objExtProt, DisplayPart:=False)
' Compute the physical properties on the model.
dblDensity = 1
dblAccuracyIn = 0.0001
Call objModel.ComputePhysicalProperties( _
Density:=dblDensity, Accuracy:=dblAccuracyIn, Volume:=dblVolume, _
Area:=dblArea, Mass:=dblMass, CenterOfGravity:=dblCofGravity, _
CenterOfVolume:=dblCofVolume, _
GlobalMomentsOfInteria:=dblGlobalMoments, _
PrincipalMomentsOfInteria:=dblPrincipalMoments, _
PrincipalAxes:=dblPrincipalAxes, _
RadiiOfGyration:=dblRadiiOfGyration, _
RelativeAccuracyAchieved:=dblAccuracyOut, Status:=lngStatus)
' Checking the physical properties of model
If (dblVolume - TOLERANCE > 1.70449930803606E-03) Or (dblArea - TOLERANCE > 9.01381038623993E-02) Or _
(dblMass - TOLERANCE > 1.70449930803606E-03) Then
MsgBox ("ComputePhysicalProperties method of Model object fails")
End If
' Set RollToFeature to ExtrudedProtrusions(1)
Call objModel.RollToFeature(Feature:=objCutOut, DisplayPart:=False)
'Get the physical properties on the updated model. _
Since the updated model has been not computed so _
GetPhysicalProperties should return lngstatus value to ZERO . _
Call objModel.GetPhysicalProperties( _
status:=lngStatus, Density:=dblDensity, _
Accuracy:=dblAccuracyIn, Volume:=dblVolume, _
Area:=dblArea, Mass:=dblMass, CenterOfGravity:=dblCofGravity, _
CenterOfVolume:=dblCofVolume, _
GlobalMomentsOfInteria:=dblGlobalMoments, _
PrincipalMomentsOfInteria:=dblPrincipalMoments, _
PrincipalAxes:=dblPrincipalAxes, _
RadiiOfGyration:=dblRadiiOfGyration, _
RelativeAccuracyAchieved:=dblAccuracyOut)
' lngstatus value should be zero. This indicates properties of the model to be out of date,
If (lngStatus <> 0) Then
MsgBox ("GetPhysicalProperties method of Model object fails for out-of-date values")
End If
' ***** CASE 2 : DisplayPart set to TRUE
' Set RollToFeature to ExtrudedProtrusions(1)
Call objModel.RollToFeature(Feature:=objExtProt, DisplayPart:=True)
' Compute the physical properties on the model.
dblDensity = 1
dblAccuracyIn = 0.0001
Call objModel.ComputePhysicalProperties( _
Density:=dblDensity, Accuracy:=dblAccuracyIn, Volume:=dblVolume, _
Area:=dblArea, Mass:=dblMass, CenterOfGravity:=dblCofGravity, _
CenterOfVolume:=dblCofVolume, _
GlobalMomentsOfInteria:=dblGlobalMoments, _
PrincipalMomentsOfInteria:=dblPrincipalMoments, _
PrincipalAxes:=dblPrincipalAxes, _
RadiiOfGyration:=dblRadiiOfGyration, _
RelativeAccuracyAchieved:=dblAccuracyOut, Status:=lngStatus)
' Checking the physical properties of model
If (dblVolume - TOLERANCE > 1.70449930803606E-03) Or (dblArea - TOLERANCE > 9.01381038623993E-02) Or _
(dblMass - TOLERANCE > 1.70449930803606E-03) Then
MsgBox ("ComputePhysicalProperties method of Model object fails")
End If
' Set RollToFeature to ExtrudedProtrusions(1)
Call objModel.RollToFeature(Feature:=objCutOut, DisplayPart:=True)
'Get the physical properties on the updated model. _
Since the updated model has been not computed so _
GetPhysicalProperties should return lngstatus value to ZERO . _
Call objModel.GetPhysicalProperties( _
status:=lngStatus, Density:=dblDensity, _
Accuracy:=dblAccuracyIn, Volume:=dblVolume, _
Area:=dblArea, Mass:=dblMass, CenterOfGravity:=dblCofGravity, _
CenterOfVolume:=dblCofVolume, _
GlobalMomentsOfInteria:=dblGlobalMoments, _
PrincipalMomentsOfInteria:=dblPrincipalMoments, _
PrincipalAxes:=dblPrincipalAxes, _
RadiiOfGyration:=dblRadiiOfGyration, _
RelativeAccuracyAchieved:=dblAccuracyOut)
' lngstatus value should be zero. This indicates properties of the model to be out of date,
If (lngStatus <> 0) Then
MsgBox ("GetPhysicalProperties method of Model object fails")
End If
' USER DISPLAY
' Release objects
Set objApp = Nothing
Set objDoc = Nothing
Set objModel = Nothing
Set objExtProt = Nothing
Set objCutOut = Nothing
End Sub