Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How could I access a part of subass 1

Status
Not open for further replies.

eastar

Industrial
Oct 12, 2002
4
How could I access a part of subassembly from assembly document via VB?
 
Replies continue below

Recommended for you

You can use the Occurrences object of Solid Edge, that represents a collection of Occurrence objects, here is an example of code, I hope that helps you


Code:
   Dim objApp As Object
   Dim objParts As SolidEdgeAssembly.Occurrences
   Dim objDoc As SolidEdgeAssembly.AssemblyDocument
   Dim objPart As SolidEdgeAssembly.Occurrence
   
   ' Connect to a running instance of Solid Edge.
   Set objApp = GetObject(, "SolidEdge.Application")
   
   If GetActive = True Then
      Set objDoc = objApp.ActiveDocument
   Else
      Set objDoc = ActiveDoc
   End If
   
   Set objParts = objDoc.Occurrences
   For Each objPart In objParts
      Dim FileName As String
      FileName = objPart.OccurrenceFileName
   Next
 
Sorry, this code is for access to the part's of an assembly, to access to a part of a subassembly you can go through the objPart.OccurrenceDocument, and this is the Part of the document of the subassembly, so:

Code:
   Dim objApp As Object
   Dim objParts As SolidEdgeAssembly.Occurrences
   Dim objDoc As SolidEdgeAssembly.AssemblyDocument
   Dim objPart As SolidEdgeAssembly.Occurrence
   Dim objDocSubAss As SolidEdgeAssembly.AssemblyDocument
   Dim objPartsSubAss As SolidEdgeAssembly.Occurrences
   Dim objPartSubAss As SolidEdgeAssembly.Occurrence
   
   ' Connect to a running instance of Solid Edge.
   Set objApp = GetObject(, "SolidEdge.Application")
   
   If GetActive = True Then
      Set objDoc = objApp.ActiveDocument
   Else
      Set objDoc = ActiveDoc
   End If
   
   Set objParts = objDoc.Occurrences
   For Each objPart In objParts
      Set objDocSubAss   = objPart.OccurrenceDocument
      Set objPartsSubAss = objPartSubAss.Occurrences
      For Each objPartSubAss In objPartsSubAss

...

      Next
   Next
 
ailuJ,thanks for your help. I solved the problem with your instruction.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor