Inventor General Discussion

Reply
Active Contributor
CadlineSupport
Posts: 48
Registered: ‎02-23-2012
Message 1 of 3 (720 Views)

iLogic for View Representation of Part File (in Assy)

720 Views, 2 Replies
04-17-2012 05:07 AM

 

Hi

 

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. 

 

Dim oApp As Inventor.Application

oApp = ThisApplication

 

Dim oDoc As Document

oDoc = ThisDoc.Document

 

Dim ocompdef As ComponentDefinition

ocompdef = odoc.ComponentDefinition

 

'Then apply specified View Representation

 

If Colour = "Red" Then

ocompdef.RepresentationsManager.DesignViewRepresentations.Item("Red").Activate

 

End If

*Expert Elite*
Curtis_Waguespack
Posts: 2,804
Registered: ‎03-08-2006
Message 2 of 3 (706 Views)

Re: iLogic for View Representation of Part File (in Assy)

04-17-2012 06:42 AM in reply to: CadlineSupport

Hi CadlineSupport,

 

Here is a basic "template" I've used for working with parts in assemblies. You can give it a go, I didn't have a chance to try it though.

 

Here is another approach that might work:

http://forums.autodesk.com/t5/Autodesk-Inventor/iLogic-set-Design-View-Representation-by-material/m-...

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com


 

 

 

'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 --------
		
		End If 
	Next
	
	Else	
	MessageBox.Show("This file is not an Assembly.", "iLogic")	
End If 

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Active Contributor
CadlineSupport
Posts: 48
Registered: ‎02-23-2012
Message 3 of 3 (691 Views)

Re: iLogic for View Representation of Part File (in Assy)

04-17-2012 02:31 PM in reply to: CadlineSupport

 

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 

 

Dim oAsmCompDef As AssemblyComponentDefinition

oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

 

'Define the open documentDim 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

       

           If Colour = "Red" Then

           oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("Red").Activate

 End If

       End If

   Next

   

    Else   

    MessageBox.Show("This file is not an Assembly.", "iLogic")   

End If

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube