Member of GetUserPhysicalProperties for PartDocument can not be found

Valued Contributor
Valued Contributor

I've writting the following code to retrieve a user entered (custom) mass;

        Dim objapp As SolidEdgeFramework.Application
        Dim objdoc As SolidEdgeFramework.SolidEdgeDocument

        objapp = Marshal.GetActiveObject("SolidEdge.Application")
        objdoc = objapp.ActiveDocument

        Dim volume As Double = 0
        Dim area As Double = 0
        Dim mass As Double = 0
        Dim centerofgravity As Array = Array.CreateInstance(GetType(Double), 3)
        Dim centerofvolume As Array = Array.CreateInstance(GetType(Double), 3)
        Dim globalInertia As Array = Array.CreateInstance(GetType(Double), 6) ' Ixx, Iyy, Izz, Ixy, Ixz and Iyz
        Dim principalInertia As Array = Array.CreateInstance(GetType(Double), 3) ' Ixx, Iyy and Izz
        Dim axes As Array = Array.CreateInstance(GetType(Double), 9) ' 3 axes x 3 coords
        Dim radio As Array = Array.CreateInstance(GetType(Double), 9) ' 3 axes x 3 coords

        objdoc.GetUserPhysicalProperties(Volume:=volume, Area:=area, Mass:=mass, CenterOfGravity:=centerofgravity, CenterOfVolume:=centerofvolume, GlobalMomentsOfInteria:=globalInertia, PrincipalMomentsOfInteria:=principalInertia, PrincipalAxes:=axes, RadiiOfGyration:=radio)
        MsgBox(mass)

 I keep on getting this error: "The public member of GetUserPhysicalProperties for type PartDocument can not be found." (hopefully I translated it right)

I am testing it on a part and according to the help file it is a member of PartDocument

 - Solid Edge Part Type Library > PartDocument Object : GetUserPhysicalProperties Method 

Maarten Elings | Mechanical Engineer
5 REPLIES

Re: Member of GetUserPhysicalProperties for PartDocument can not be found

Legend
Legend

Hi MaartenEl,

 

You have to define objdoc as SolidEdgePart.PartDocument instead of SolidEdgeFramework.SolidEdgeDocument.

 

Or maybe you can Trycast objdoc as SolidEdgePart.PartDocument and if not is nothing call the GetUserPhysicalProperties Method:

 

 

If Not IsNothing(TryCast(objdoc, SolidEdgePart.PartDocument)) then

objdoc.GetUserPhysicalProperties(Volume:=volume, Area:=area, Mass:=mass, CenterOfGravity:=centerofgravity, CenterOfVolume:=centerofvolume, GlobalMomentsOfInteria:=globalInertia, PrincipalMomentsOfInteria:=principalInertia, PrincipalAxes:=axes, RadiiOfGyration:=radio) MsgBox(mass)
End if

Hope it helps.

Héctor Pelayo Izquierdo
Engineering Department, JAE Ingeniería y Desarrollos, S.L.
Solid Edge ST9 MP5 | NX 9
Development: VB.NET

Re: Member of GetUserPhysicalProperties for PartDocument can not be found

Valued Contributor
Valued Contributor

Thank you for your reply.

However both (see below) cause an unhandled exception:

 

unhandled exception has occurred in your application.
the parameter is incorrect exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

        Dim objapp As SolidEdgeFramework.Application
        Dim objDoc As SolidEdgePart.PartDocument

        objapp = Marshal.GetActiveObject("SolidEdge.Application")
        objdoc = objapp.ActiveDocument

        Dim volume As Double = 0
        Dim area As Double = 0
        Dim mass As Double = 0
        Dim centerofgravity As Array = Array.CreateInstance(GetType(Double), 3)
        Dim centerofvolume As Array = Array.CreateInstance(GetType(Double), 3)
        Dim globalInertia As Array = Array.CreateInstance(GetType(Double), 6) ' Ixx, Iyy, Izz, Ixy, Ixz and Iyz
        Dim principalInertia As Array = Array.CreateInstance(GetType(Double), 3) ' Ixx, Iyy and Izz
        Dim axes As Array = Array.CreateInstance(GetType(Double), 9) ' 3 axes x 3 coords
        Dim radio As Array = Array.CreateInstance(GetType(Double), 9) ' 3 axes x 3 coords

        objdoc.GetUserPhysicalProperties(Volume:=volume, Area:=area, Mass:=mass, CenterOfGravity:=centerofgravity, CenterOfVolume:=centerofvolume, GlobalMomentsOfInteria:=globalInertia, PrincipalMomentsOfInteria:=principalInertia, PrincipalAxes:=axes, RadiiOfGyration:=radio)
        MsgBox(mass)

 and

        Dim objapp As SolidEdgeFramework.Application

        objapp = Marshal.GetActiveObject("SolidEdge.Application")

        Dim volume As Double = 0
        Dim area As Double = 0
        Dim mass As Double = 0
        Dim centerofgravity As Array = Array.CreateInstance(GetType(Double), 3)
        Dim centerofvolume As Array = Array.CreateInstance(GetType(Double), 3)
        Dim globalInertia As Array = Array.CreateInstance(GetType(Double), 6) ' Ixx, Iyy, Izz, Ixy, Ixz and Iyz
        Dim principalInertia As Array = Array.CreateInstance(GetType(Double), 3) ' Ixx, Iyy and Izz
        Dim axes As Array = Array.CreateInstance(GetType(Double), 9) ' 3 axes x 3 coords
        Dim radio As Array = Array.CreateInstance(GetType(Double), 9) ' 3 axes x 3 coords

        If Not IsNothing(TryCast(objDoc, SolidEdgePart.PartDocument)) Then
            objDoc.GetUserPhysicalProperties(Volume:=volume, Area:=area, Mass:=mass, CenterOfGravity:=centerofgravity, CenterOfVolume:=centerofvolume, GlobalMomentsOfInteria:=globalInertia, PrincipalMomentsOfInteria:=principalInertia, PrincipalAxes:=axes, RadiiOfGyration:=radio)
            MsgBox(mass)
        End If

 

Maarten Elings | Mechanical Engineer

Re: Member of GetUserPhysicalProperties for PartDocument can not be found

Legend
Legend

It works for me.

 

Please revise your spell.

 

GlobalMomentsOfInteria:=

should be GlobalMomentsOfInertia:=

 

PrincipalMomentsOfInteria:=

should be PrincipalMomentsOfInertia:=

Héctor Pelayo Izquierdo
Engineering Department, JAE Ingeniería y Desarrollos, S.L.
Solid Edge ST9 MP5 | NX 9
Development: VB.NET

Re: Member of GetUserPhysicalProperties for PartDocument can not be found

Legend
Legend

If user defined Area and user defined Volume are equals to 0 it throws an exception, so you have to define them.

Héctor Pelayo Izquierdo
Engineering Department, JAE Ingeniería y Desarrollos, S.L.
Solid Edge ST9 MP5 | NX 9
Development: VB.NET

Re: Member of GetUserPhysicalProperties for PartDocument can not be found

Valued Contributor
Valued Contributor

Thanks that solved it!

 

Apperently an event that was triggert before this GetUserPhysicalProperties event cleared the area and volume data

Maarten Elings | Mechanical Engineer