I have received a great solution from Bobvdd allowing ilogic control of the view rep in a part file (not an assembly file). The code below works brilliantly when the part file is the active document. However when the part is placed in an assembly and the ilogic is run with the assembly active, the code produces no result. Is anyone able to advise on how to modify the top 6 lines of code? Many thanks for your help.
'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document
Dim docFile As Document
'kAssemblyDocumentObject = 12291
If openDoc.DocumentType = 12291 Then
'Iterate though the part files in the assembly
For Each docFile In openDoc.AllReferencedDocuments
'kPartDocumentObject = 12290
If docFile.DocumentType = 12290 Then
'-------- your code here --------
MessageBox.Show("This file is not an Assembly.", "iLogic")
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Thank you for the quick response Curtis, very much appreciated. I have tried the code you suggest in the assembly (with my own simple code added) and it gives me the 'Parameter is incorrect' error when running. Am I doing something obvious wrong? Thank you