Component Occurrence Inserted With API Missing Representations

Component Occurrence Inserted With API Missing Representations

TylerWarner33
Advocate Advocate
421 Views
2 Replies
Message 1 of 3

Component Occurrence Inserted With API Missing Representations

TylerWarner33
Advocate
Advocate

Is there a way to get the 'Representations' to load on an occurrence that is loaded using the API?


I insert the occurrence like this:

componentOccurrence = assemblyDocument.ComponentDefinition.Occurrences.AddWithOptions(
    inventorFilePath,
    matrix,
    options);

if (string.IsNullOrWhiteSpace(viewRepresentationName) is false)
    componentOccurrence.SetDesignViewRepresentation(viewRepresentationName);


In the image below, the top assembly was inserted with the API & the second assembly was inserted manually via the Inventor user interface. As you can see, the 'Representations' are not loaded for the first assembly even though they are the same file. 

TylerWarner33_0-1760785905084.png

 

If this answered your question, click 'Accept Solution'.
If this was helpful, click 'Like'.

Tyler Warner

0 Likes
Accepted solutions (1)
422 Views
2 Replies
Replies (2)
Message 2 of 3

Curtis_W
Consultant
Consultant
Accepted solution

@TylerWarner33 , hope you're doing well!

I think the trick here is to set the veiw rep to be associative with the options.

 

inventorFilePath = "C:\Temp\Test01.iam"
Dim oAssemblyDocument As AssemblyDocument = ThisDoc.Document
Dim oPositionMatrix As Inventor.Matrix = ThisApplication.TransientGeometry.CreateMatrix()
Dim oOptions As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()
oOptions.Add("DesignViewRepresentation", "Test")
oOptions.Add("DesignViewAssociative", True)

Dim oComponentOccurrences As ComponentOccurrences = oAssemblyDocument.ComponentDefinition.Occurrences
Dim oOcc As ComponentOccurrence = oComponentOccurrences.AddWithOptions(inventorFilePath, oPositionMatrix, oOptions)

 

Or set that after it is placed:

inventorFilePath = "C:\Temp\Test01.iam"
Dim oAssemblyDocument As AssemblyDocument = ThisDoc.Document
Dim oPositionMatrix As Inventor.Matrix = ThisApplication.TransientGeometry.CreateMatrix()
Dim oOptions As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()
oOptions.Add("DesignViewRepresentation", "Test")

Dim oComponentOccurrences As ComponentOccurrences = oAssemblyDocument.ComponentDefinition.Occurrences
Dim oOcc As ComponentOccurrence = oComponentOccurrences.AddWithOptions(inventorFilePath, oPositionMatrix, oOptions)
oOcc.SetDesignViewRepresentation("Test",,"True")

 

Hope that helps,
Curtis

 EESignature

0 Likes
Message 3 of 3

TylerWarner33
Advocate
Advocate

Thanks @Curtis_W , hope you're doing well too!

 

That seemed to do it. I was testing with that previously but kept getting errors. Turns out, the 'associative' will throw an error if trying to associate to the "[Primary]" view representation.

If this answered your question, click 'Accept Solution'.
If this was helpful, click 'Like'.

Tyler Warner