Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error in code

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
286 Views, 2 Replies

Error in code

Hi, everyone,

 

Can someone tell me where is the mistake in following code:

 

Public Sub TestSelection()
   Dim InvDoc As Document
   Set InvDoc = ThisApplication.ActiveDocument

   Dim oPartDoc As PartDocument
   Set oPartDoc = InvDoc.ReferencedDocuments(1)

   Call oPartDoc.Activate
End Sub

 

I have an assembly with two parts inside. I want to activate first of them (like Edit command in browser), but I got message "Method 'Activate' of object 'PartDocument' failed".

2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

Hi,

 

I hope this will be help you out.

 

Public Sub TestSelection()
Dim InvDoc As Document
Set InvDoc = ThisApplication.ActiveDocument
If InvDoc.DocumentType = kAssemblyDocumentObject Then
Dim oAssyDoc As AssemblyDocument
Set oAssyDoc = ThisApplication.ActiveDocument

Dim oRefDocs As DocumentsEnumerator
Set oRefDocs = oAssyDoc.AllReferencedDocuments
For tt = 1 To oRefDocs.Count
Dim oDoc As Document
Set oDoc = oRefDocs.Item(tt)
If oDoc.DocumentType = kPartDocumentObject Then
Dim oOccEnum As ComponentOccurrencesEnumerator
Set oOccEnum = oAssyDoc.ComponentDefinition.Occurrences.AllReferencedOccurrences(oDoc)
Dim oOcc As ComponentOccurrence
Set oOcc = oOccEnum.Item(1)
Call oOcc.Edit
End If
Next tt
End If
End Sub

 

Message 3 of 3
Anonymous
in reply to: Anonymous

Thank you very much. I understand now where was mistake. I have to work with occurrences not with documents.

Thanks again.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report