Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

View Representation updates

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
rhasell
764 Views, 6 Replies

View Representation updates

Hi all

 

Info:

I used to use "Level of detail" to hide components etc for detailing purposes, thanks to the forum, I now use "Representations"

 

Amongs a few customised views, I have a set search for fastners.

 

Question:

Is there a way to automate the search (Saved search) and then switch off the visibilty of the items?

Preferably some iLogic code?

 

I have to run the search quite a few times during the design/detailing process, and sometimes things slip through the cracks, esp when I change fastners. (Note, All the fastners are extracted from the CC and saved with a new name and details.) It would be great to just run a rule.

 

Thanks.

 

Reg
2024.2
Please Accept as a solution / Kudos
6 REPLIES 6
Message 2 of 7
Curtis_Waguespack
in reply to: rhasell

Hi rhasell,

 

Here is a rule that will create a view rep and  turn off the visibility of components based upon a Custom iProperty value.

 

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

 

'define View Rep name
Dim oNewVRep as Object
oNewVRep = "Fasteners Off"
'define custom iProp value to look for
Dim oComparator as Object
oComparator = "Bolt"

' set a reference to the assembly component definintion.
' This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oViewRep As DesignViewRepresentation

'Look for an existing View Rep of the same name and delete it if found
For Each oViewRep in oAsmCompDef.RepresentationsManager.DesignViewRepresentations
	If oViewRep.Name = "Master"  Then
	'set the Master View Rep to be active
	oViewRep.Activate
	'if Master is already active, skip error
	On error Resume Next
	'look for same name view rep
	Else if oViewRep.Name = oNewVRep  Then
	'delete same name view rep if found
	oViewRep.Delete
	Else 
	End if
Next

'create new View Rep
oViewRep = oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Add(oNewVRep)      

'define current document
Dim openDoc As Document
openDoc = ThisDoc.Document

'look at all of the components in the assembly
Dim oCompDef As Inventor.ComponentDefinition = openDoc.ComponentDefinition
'define the first level components collection
Dim oCompOcc As Inventor.ComponentOccurrence 
'define the next level components collection
Dim oSubCompOcc As Inventor.ComponentOccurrence
'Turn off the visibility of parts in the top level assembly that include a
'custom iProp designating them as fasteners
For each oCompOcc in oCompDef.Occurrences
	'set visible if custom iProp does not match comparator value
	If iProperties.Value(oCompOcc.name, "Custom", "TYPE") <> oComparator  Then
	'Turn the visibility on
	oCompOcc.Visible = True
	Else
	'Turn the visibility off
	oCompOcc.Visible = False
	End If
	'Turn off the visibility of parts in the second level assembly that include a
	'custom iProp designating them as fasteners
    	For Each oSubCompOcc In oCompOcc.SubOccurrences
		'set visible if custom iProp does not match comparator value
		If iProperties.Value(oSubCompOcc.name, "Custom", "TYPE") <> oComparator  Then
		'Turn the visibility on
		oSubCompOcc.Visible = True
		Else
		'Turn the visibility off
		oSubCompOcc.Visible = False
	End If

    	Next
Next	
 
Message 3 of 7
rhasell
in reply to: Curtis_Waguespack

Thanks so much for the prompt response.

 

I have one more addition,

I have applied a "Custom", "TYPE" setting to all my components, (The reason for this is sorting the BOM in a sequential order.)

 

eg

Bolts = "BOLT"

Nut = "NUT"

Washer = "WASHER"

Extrsusion = "XTR"

Tubes = "CHS"

etc.

 

Can I add the additional oComparitor of "NUT" and "WASHER" to the list?

 

I played around a bit with the code, but you have a far superior knowledge of the process, I am a noob when it comes to iLogic.

 

Thank you.

 

Reg
2024.2
Please Accept as a solution / Kudos
Message 4 of 7
rhasell
in reply to: rhasell

Hi

 

I am trying to attach a test assembly, but it keeps on timing out (720k)?

 

I noticied that is does not run in the sub assemblies.

Thanks

 

Reg
2024.2
Please Accept as a solution / Kudos
Message 5 of 7
Curtis_Waguespack
in reply to: rhasell

Hi rhasell,

 

Here is an updated version.

 

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


 

'create comparator list
oStringArray = new string(){"Bolts", "Nuts", "Washers", "Extrusions", "Tubes"}

'get input from user
oList = InputListBox("Select a type", oStringArray, "Bolts", "iLogic", "Available Types")

'define custom iProp value to look for
Dim oComparator as Object
If oList = "Bolts" Then
oComparator = "BOLT"
Else if oList = "Nuts" Then
oComparator = "NUT"
Else if oList = "Washers" Then
oComparator = "WASHER"
Else if oList = "Extrusion" Then
oComparator = "XTR"
Else if oList = "Tubes" Then
oComparator = "CHS"
Else
End if

'set a reference to the assembly component definintion.
'This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
'define view rep 
Dim oViewRep As DesignViewRepresentation
'define view rep to use
Dim sVRep as String
sVRep = "Fasteners Off"

'define an arraylist to hold the list of  view rep names
Dim NameList As New ArrayList()

'Look at the view reps in the assembly
For Each oViewRep in oAsmCompDef.RepresentationsManager.DesignViewRepresentations
'set the list of names to the array list
NameList.add(oViewRep.Name)
Next

'check to see if the arraylist contains the desired view rep
If Not NameList.Contains(sVRep) Then
	'create new View Rep
	oViewRep = oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Add(sVRep)
	oViewRep.Activate
Else if NameList.Contains(sVRep) Then
	'set existing view rep active
	oViewRep = oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item(sVRep) 
	oViewRep.Activate	
End If

'define current document
Dim openDoc As Document
openDoc = ThisDoc.Document

'look at all of the components in the assembly
Dim oCompDef As Inventor.ComponentDefinition = openDoc.ComponentDefinition
'define the first level components collection
Dim oCompOcc As Inventor.ComponentOccurrence 
'define the next level components collection
Dim oSubCompOcc As Inventor.ComponentOccurrence

'Turn off the visibility of parts in the top level assembly that include a
'custom iProp designating them as fasteners
For each oCompOcc in oCompDef.Occurrences

	Try 
	'set visible if custom iProp does not match comparator value
	If iProperties.Value(oCompOcc.name, "Custom", "TYPE") <> oComparator  Then
	'do nothing
	Else
	'Turn the visibility off
	oCompOcc.Visible = False
	End If
	Catch
	'assume error means iProperty not found	
	End Try


	'Turn off the visibility of parts in the second level assembly that include a
	'custom iProp designating them as fasteners
    	For Each oSubCompOcc In oCompOcc.SubOccurrences
	
		Try
		'set visible if custom iProp does not match comparator value
		If iProperties.Value(oSubCompOcc.name, "Custom", "TYPE") <> oComparator  Then
		'do nothing
		Else		
		'Turn the visibility off
		oSubCompOcc.Visible = False
		End If
		Catch
		'assume error means iProperty not found	
		End Try
    	Next
Next	

 

Message 6 of 7
rhasell
in reply to: Curtis_Waguespack

Thanks for your help mate.

 

Reg
2024.2
Please Accept as a solution / Kudos
Message 7 of 7
LukeDavenport
in reply to: rhasell

 

Hi rhasell,

You might be interested in this new app on the exchange apps store - it automatically maintains view representations (for use in drawing views and parts lists) based on up to 2 custom or standard iproperties. You can create and manage as many of these 'saved filters' as you like, and save them in a template also.

 

App:

https://apps.exchange.autodesk.com/INVNTOR/en/Detail/Index?id=appstore.exchange.autodesk.com%3aviewr...

 

Video:

http://youtu.be/qem8o-R2mqQ

 

Best regards,

Luke

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

Post to forums  

Autodesk Design & Make Report