Highlighted

How to get solid bodies from Assembly file in solid edge through API

Creator
Creator
I have an Assembly file that have three part file and each includes two solid bodies(Extrude).

I need this solid body count from assembly file through API.

Currently i am trying to get this count through vb but unable to get that.

 

Please help me to get this solid/surface bodies count from assembly file.

 

Any help would be appreciated.

 

Thanks in advance.

2 REPLIES

Re: How to get solid bodies from Assembly file in solid edge through API

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

I had once posted the following code to count the total number of solid bodies in the active part.

You should be able to easily change it to count also the number of surface bodies:

'----------------------------------------------------------------------
' PAR: Count the total number of solid bodies in the active part document.
'----------------------------------------------------------------------
Dim nSolidBodies As Integer = 0
Dim objDoc As SolidEdgePart.PartDocument = objApp.ActiveDocument
Dim objBody As Body = Nothing

' Check for solid design bodies
For Each objModel As SolidEdgePart.Model In objDoc.Models
  objBody = objModel.Body
  If objBody.IsSolid Then
    For Each objShell As Shell In objBody.Shells
      If objShell.IsClosed AndAlso Not objShell.IsVoid Then
        nSolidBodies += 1
      End If
    Next
  End If
Next

' Check for solid construction bodies
For Each objConsModel As ConstructionModel In objDoc.Constructions
  objBody = objConsModel.Body
  If objBody.IsSolid Then
    nSolidBodies += 1
  End If
Next

Re: How to get solid bodies from Assembly file in solid edge through API

Creator
Creator

Thank you so much Martin.