JustSelectedEntities Is A Part Occurrance

JustSelectedEntities Is A Part Occurrance

Anonymous
Not applicable
292 Views
2 Replies
Message 1 of 3

JustSelectedEntities Is A Part Occurrance

Anonymous
Not applicable
I'm having a difficult time getting from the selection process to the SaveAs function. I'm using a selection filter "kAssemblyOccurrenceFilter" which allow me to select a part, but I keep getting an invalid cast exception when I try to use my selected part as the original document for my SaveAs.


Private m_Part As Inventor.ComponentOccurrence

m_Part = JustSelectedEntities.Item(0)


Here's where I'm stuck. How do I get my selected object to a SaveAs statement?

Thanks,

Jon
0 Likes
293 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
>>invalid cast exception

You need to make sure that the guy in JustSelectedEntities is actually a component occurrence. And make sure you're starting your indicies at 1 for Inventor's types.

JustSelectedEntities is an ObjectEnumerator, right?

Try something like this:

{code}
For Each objEntity as Object in JustSelectedEntities
If typeof objEntity Is ComponentOccurrence Then
'Do whatever you need
End if
Next
{code}

If you then want to save that file for the occurrence, you should be able get to it through the ComponentOccurrence.Definition.Document property.
0 Likes
Message 3 of 3

Anonymous
Not applicable
This is what I needed. Thank you.

Jon
0 Likes