Unable to compute Physical Properties in vb.net

Why I'm Unable to compute Physical Properties in vb.net

       Dim objApp As SolidEdgeFramework.Application        Dim objDoc As SolidEdgePart.PartDocument        Dim objModel As  SolidEdgePart.Model        Dim objProfile As SolidEdgePart.Profile        Const TESTFILE = "C:\Dessin2\1285\12856\T1C00126.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(1) As Double        Dim dblCofVolume(1) As Double        Dim dblGlobalMoments(1) As Double        Dim dblPrincipalMoments(1) As Double        Dim dblPrincipalAxes(1) As Double        Dim dblRadiiOfGyration(1) As Double        Dim lngStatus As Long        ' Report errors        Const PI = 3.14159265358979        ' Create/get the application with specific settings        On Error Resume Next        objApp = GetObject(, "SolidEdge.Application")        If Err.Number() Then            Err.Clear()            objApp = CreateObject("SolidEdge.Application")            objDoc = objApp.Documents.Add("SolidEdge.PartDocument")            objApp.Visible = True        Else            objDoc = objApp.ActiveDocument        End If

        ' Close the part document        Call objDoc.Close()        ' Open a Testcase        objDoc = objApp.Documents.Open(Filename:=TESTFILE)        ' Get the model object in the test case

        objModel = objDoc.Models(1)

        ' Calcul physical properties on the model.        dblDensity = 14 * 27679.89999828        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)

........

tanks

 

 

Posted by: Plante Sylvain
Post date: 10/15/2011 4:24:06 AM

2 REPLIES

RE: Unable to compute Physical Properties in vb.net

Hi,

 

the main problem with your code above might be declaring and initializing the necessary arrays of double. See the code excerpt below which hopefully will point you to the right direction.

 

        Dim Status As Integer        Dim Density, Accuracy, Volume, Area, Mass, RelativeAccuracyAchieved As Double        Dim CenterOfGravity() As Double = New Double() {}        Dim CenterOfVolume() As Double = New Double() {}        Dim GlobalMomentsOfInertia() As Double = New Double() {}        Dim PrincipalMomentsOfInertia() As Double = New Double() {}        Dim PrincipalAxes() As Double = New Double() {}        Dim RadiiOfGyration() As Double = New Double() {}        ...        theDocument.Models.Item(1).ComputePhysicalProperties(Density, _                                                                 Accuracy, _                                                                 Volume, _                                                                 Area, _                                                                 Mass, _                                                                 CenterOfGravity, _                                                                 CenterOfVolume, _                                                                 GlobalMomentsOfInertia, _                                                                 PrincipalMomentsOfInertia, _                                                                 PrincipalAxes, _                                                                 RadiiOfGyration, _                                                                 RelativeAccuracyAchieved, _                                                                 Status)

 

Posted by: Wolfgang Kunert
Post date: 10/15/2011 10:23:12 PM

RE: Unable to compute Physical Properties in vb.net

tank's you Wolfgang Kunert, it works

 

 

Dim objApp As SolidEdgeFramework.Application

Dim objDoc As SolidEdgePart.PartDocument

Dim objModel As SolidEdgePart.Model

Dim objProfile As SolidEdgePart.Profile

Const TESTFILE = "C:\Dessin2\1285\12856\T1C00126.par"

Const TOLERANCE = 0.0001

 

Dim Status As Integer

Dim Density, Accuracy, Volume, Area, Mass, RelativeAccuracyAchieved As Double

Dim CenterOfGravity() As Double = New Double() {}

Dim CenterOfVolume() As Double = New Double() {}

Dim GlobalMomentsOfInertia() As Double = New Double() {}

Dim PrincipalMomentsOfInertia() As Double = New Double() {}

Dim PrincipalAxes() As Double = New Double() {}

Dim RadiiOfGyration() As Double = New Double() {}

 

' Report errors

Const PI = 3.14159265358979

' Create/get the application with specific settings

On Error Resume Next

objApp = GetObject(, "SolidEdge.Application")

If Err.Number() Then

Err.Clear()

objApp = CreateObject("SolidEdge.Application")

objDoc = objApp.Documents.Add("SolidEdge.PartDocument")

objApp.Visible = True

Else

objDoc = objApp.ActiveDocument

End If

 

' Close the part document

Call objDoc.Close()

' Open a Testcase

objDoc = objApp.Documents.Open(Filename:=TESTFILE)

' Get the model object in the test case

 

objModel = objDoc.Models(1)

 

' Calcul physical properties on the model.

Density = 16 * 27679.89999828

Accuracy = 0.0001

 

objDoc.Models.Item(1).ComputePhysicalProperties(Density, _

Accuracy, _

Volume, _

Area, _

Mass, _

CenterOfGravity, _

CenterOfVolume, _

GlobalMomentsOfInertia, _

PrincipalMomentsOfInertia, _

PrincipalAxes, _

RadiiOfGyration, _

RelativeAccuracyAchieved, _

Status)

 

Posted by: Plante Sylvain
Post date: 10/17/2011 12:05:40 PM