Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Assembly area

Phenom
Phenom

I have an addin for our company that uses the [c#] API AssemblyDocument.PhysicalProperties.GetAssemblyPhysicalProperties() to get the Mass of an assembly and saves it to the file properties to allow SEEC to upload it to Teamcenter.

 

I'm now trying to do some calculations with the Area that the same API outputs - however I can only seem to get a result of -1.  Does the assembly GetAssemblyPhysicalProperties not report a real Area, despite it 'claiming' to? I can't see anything in the documentation to this effect, but also can't seem to get an area out.


Thanks.

4 REPLIES 4

Re: Assembly area

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

A hint I can give is to update the physical properties. You can see an example on this page:

https://docs.plm.automation.siemens.com/docs/se/109/api/SolidEdgeAssembly~PhysicalProperties~Update....

 

Regards,

Tushar

www.SurfAndCode.IN

www.CADVertex.com

Re: Assembly area

Phenom
Phenom

@Tushar thanks for the suggestion, but unfortunately it hasn't made a difference.

 

The mass and volume output are correct, but can't get the area to be anything other than -1. Can you (or anyone else?) confirm that physicalProperties.GetAssemblyPhysicalProperties() *should* return a real area for an assembly?

 

Note: I have both a part and sheet metal part as children in the assy to make sure there is something to report on!

Re: Assembly area

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

@Alex_H

 

I tried this with success:

Manually select all components in the assembly, then use the GetSelectSetPhysicalProperties method.

 

Here's my code, based on the sample by Jason for computing part physical properties:

 

Imports System.Runtime.InteropServices

Module Module1

    Sub Main(ByVal args() As String)
        Dim application As SolidEdgeFramework.Application = Nothing
        Dim asmDocument As SolidEdgeAssembly.AssemblyDocument = Nothing
        Dim models As SolidEdgePart.Models = Nothing
        Dim model As SolidEdgePart.Model = Nothing
        Dim density As Double = 0
        Dim accuracy As Double = 0
        Dim volume As Double = 0
        Dim area As Double = 0
        Dim mass As Double = 0
        Dim cetnerOfGravity As Array = Array.CreateInstance(GetType(Double), 3)
        Dim cetnerOfMass As Array = Array.CreateInstance(GetType(Double), 3)
        Dim centerOfVolumne As Array = Array.CreateInstance(GetType(Double), 3)
        Dim globalMomentsOfInteria As Array = Array.CreateInstance(GetType(Double), 6) 
        Dim principalMomentsOfInteria As Array = Array.CreateInstance(GetType(Double), 3)
        Dim principalAxes As Array = Array.CreateInstance(GetType(Double), 9) 

        Dim principalAxes1 As Array = Array.CreateInstance(GetType(Double), 9) 
        Dim principalAxes2 As Array = Array.CreateInstance(GetType(Double), 9) 
        Dim principalAxes3 As Array = Array.CreateInstance(GetType(Double), 9) 

        Dim principalMoments As Array = Array.CreateInstance(GetType(Double), 9)

        Dim radiiOfGyration As Array = Array.CreateInstance(GetType(Double), 9) 
        Dim relativeAccuracyAchieved As Double = 0
       
        Try
            application = Marshal.GetActiveObject("SolidEdge.Application")
            asmDocument = application.ActiveDocument

            If asmDocument IsNot Nothing Then
                density = 1
                accuracy = 0.05
                Dim phy As SolidEdgeAssembly.PhysicalProperties = asmDocument.PhysicalProperties()
                phy.Update()
                
                phy.GetSelectSetPhysicalProperties(Mass:=mass, Volume:=volume, Area:=area,
                                                  CenterOfMass:=cetnerOfMass, CenterOfVolume:=centerOfVolumne, GlobalMoments:=globalMomentsOfInteria,
                                                  PrincipalAxis1:=principalAxes1, PrincipalAxis2:=principalAxes2, PrincipalAxis3:=principalAxes3,
                                                  PrincipalMoments:=principalMoments, RadiiOfGyration:=radiiOfGyration)

                Console.WriteLine("ComputePhysicalProperties() results:")

                Console.WriteLine("Density: {0}", density)
                Console.WriteLine("Accuracy: {0}", accuracy)
                Console.WriteLine("Volume: {0}", volume)
                Console.WriteLine("Area: {0}", area)
                Console.WriteLine("Mass: {0}", mass)
                Console.ReadKey()
            Else
                Throw New System.Exception("No active document.")
            End If
        Catch ex As System.Exception
            Console.WriteLine(ex.Message)

        End Try
    End Sub

End Module

  

You may create a SelectSet and add all occurrences in it before running the program, then use the RemoveAll method on the SelectSet

  

Hope this helps.

~Tushar

Re: Assembly area

Phenom
Phenom

Thanks @Tushar, that approch works. Still not sure why the normal method doesn't work but I'll give this a go.