Error to get body from assembly occurrence.

Valued Contributor
Valued Contributor

Hello All,

 

working on some code and here is my problem:

 

 

Dim objApp As SolidEdgeFramework.Application = Nothing
Dim objDoc As SolidEdgeAssembly.AssemblyDocument = Nothing
Dim objOccurrences As SolidEdgeAssembly.Occurrences = Nothing

Dim objFirstPart As SolidEdgeAssembly.Occurrence = Nothing

Dim objFace1 As Object = Nothing

 

objApp = GetObject(, "SolidEdge.Application")
objDoc = objApp.ActiveDocument
objOccurrences = objDoc.Occurrences


' get a reference of the desired  item number
objFirstPart = objOccurrences.Item(1) ' First item on the assembly

 

objFace1 = objFirstPart.Body.Faces(1)' get a Face

 

it errors out on this last line because is not getting the body from the first occurrance.

 

Body = {"Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))"}

 

Any help?

1 REPLY

Re: Error to get body from assembly occurrence.

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi,

the occurrence object has no Body object (Nothing) unless there is a Assembly Feature defined, that modifies this occurrence.

Use the OccurenceDocument first to get the part Document from the Occurrence.

Then follow the the Models collection to find the Part Body.

 

Use the Spy for Solid Edge program from Jason, which is a great help to explore the object structure.

 

BR Jürgen

regards

JB
VS2015, SE ST10