Reply
Solved! Go to solution

Update and retrieve ass'y mass

Hello,

 

I'm trying to update and return the mass of an assembly.

However the code I have keeps on crashing SE (st6 & 7)

        Dim objPhyProps As SolidEdgeAssembly.PhysicalProperties
       objPhyProps = objdoc.PhysicalProperties

        Dim dblMass As Double
        Dim dblVolume As Double
        Dim dblArea As Double
        Dim dblCofMass() As Double
        Dim dblCofVolume() As Double
        Dim dblGlobalMoments() As Double
        Dim dblPrincipalAxis1() As Double
        Dim dblPrincipalAxis2() As Double
        Dim dblPrincipalAxis3() As Double
        Dim dblPrincipalMoments() As Double
        Dim dblRadiiOfGyration() As Double
        Dim bIsSick As Boolean
        Dim bUpdateStatus As Boolean

        Call objPhyProps.Update() 'update mass

        Call objPhyProps.GetAssemblyPhysicalProperties( _
              Mass:=dblMass, Volume:=dblVolume, _
              Area:=dblArea, CenterOfMass:=dblCofMass, CenterOfVolume:=dblCofVolume, _
              GlobalMoments:=dblGlobalMoments, PrincipalAxis1:=dblPrincipalAxis1, _
              PrincipalAxis2:=dblPrincipalAxis2, PrincipalAxis3:=dblPrincipalAxis3, _
              PrincipalMoments:=dblPrincipalMoments, RadiiOfGyration:=dblRadiiOfGyration, _
              IsSick:=bIsSick, UpdateStatus:=bUpdateStatus)

        MsgBox(dblMass) 'show the ass'y mass!

 Please help Man Indifferent

Maarten Elings | Mechanical Engineer
3 REPLIES
Solution
Solution
Accepted by topic author MaartenEl
‎08-26-2015 04:32 AM

Re: Update and retrieve ass'y mass

Solved it!

 

        Dim objPhyProps As SolidEdgeAssembly.PhysicalProperties
       objPhyProps = objdoc.PhysicalProperties
        objDoc = objApplication.ActiveDocument

        Call objPhyProps.Update() 'update mass

        Dim dblMass As Double = 0
        Dim dblVolume As Double = 0
        Dim dblArea As Double = 0
        Dim dblCofMass As Array = Array.CreateInstance(GetType(Double), 3)
        Dim dblCofVolume As Array = Array.CreateInstance(GetType(Double), 3)
        Dim dblGlobalMoments As Array = Array.CreateInstance(GetType(Double), 3)
        Dim dblPrincipalAxis1 As Array = Array.CreateInstance(GetType(Double), 3)
        Dim dblPrincipalAxis2 As Array = Array.CreateInstance(GetType(Double), 3)
        Dim dblPrincipalAxis3 As Array = Array.CreateInstance(GetType(Double), 3)
        Dim dblPrincipalMoments As Array = Array.CreateInstance(GetType(Double), 3)
        Dim dblRadiiOfGyration As Array = Array.CreateInstance(GetType(Double), 3)
        Dim bIsSick As Boolean
        Dim bUpdateStatus As Boolean

        Try
            objPhyProps.GetAssemblyPhysicalProperties( _
                  Mass:=dblMass, Volume:=dblVolume, _
                  Area:=dblArea, CenterOfMass:=dblCofMass, CenterOfVolume:=dblCofVolume, _
                  GlobalMoments:=dblGlobalMoments, PrincipalAxis1:=dblPrincipalAxis1, _
                  PrincipalAxis2:=dblPrincipalAxis2, PrincipalAxis3:=dblPrincipalAxis3, _
                  PrincipalMoments:=dblPrincipalMoments, RadiiOfGyration:=dblRadiiOfGyration, _
                  IsSick:=bIsSick, UpdateStatus:=bUpdateStatus)
        Catch ex As Exception

        End Try
        MsgBox(dblMass)

 

Maarten Elings | Mechanical Engineer

Re: Update and retrieve ass'y mass

Amazings, that's what I was looking for!
Works Great to me, thanks

Re: Update and retrieve ass'y mass

Looks the the community samples may be getting overlooked by some!

 

They're certainly saving me a lot of time figuring stuff out when I'm pressed for time...

 

Community Samples on GitHub

 

Your specific query