Quick way to Hide / Unhide parts in an assembly?

Quick way to Hide / Unhide parts in an assembly?

gustav123456
Explorer Explorer
2,990 Views
31 Replies
Message 1 of 32

Quick way to Hide / Unhide parts in an assembly?

gustav123456
Explorer
Explorer

Hi!


I'm a long-time SolidWorks user currently transitioning to Inventor in my new workplace. 

When in an assembly - in SW, you could hover the mouse over a component and hit TAB to hide the component. To un-hide it, you could hover with the mouse where the component should have been if it was visible, and then hit SHIFT+TAB to make it visible again. I used this all the time but so far I haven't found something similar in Inventor. Sure, hiding a part with Alt+V or right click -> "Visible" isn't a big deal, but do you really have to locate the part in the assembly tree to be able to un-hide it? I hope there is an Inventor equivalent to SHIFT+TAB in SolidWorks.
I'm running Inventor Professional 2019.

 

Best regards

2,991 Views
31 Replies
Replies (31)
Message 21 of 32

rhenstenburg
Advocate
Advocate

I use that technique also but in this scenario I am trying to be far more general.  For the visibility settings in a View Rep, how can I make all visible components Hidden and all Hidden components Visible.  Essentially inverting the visibility settings for everything.

Inventor Pro / Vault Basic
0 Likes
Message 22 of 32

rhenstenburg
Advocate
Advocate

I think I have it now ...

The problem was that to make a selection set "stick" you need to perform an action on it.

 

How to "Invert" Visibilities in a View Rep (make visible components hidden and hidden components visible)

 

1) Make a View Rep active

2) In the window, Shft-Right click > Select all Invisible Components

3) Right Click > Visibility (or Alt-V) ... result will be ALL components are visible but you have a working selection set of the previously hidden components available to use

4) Shft-Right click > Previous selection

5) Shft-Right click > Invert Selection

6) Alt-V

 

I tried this several times and got it to work consistently.

 

Q.E.D. (Problem solved).

 

Next step ... automate this with code.

Inventor Pro / Vault Basic
0 Likes
Message 23 of 32

rhenstenburg
Advocate
Advocate

Sorry @gustav123456 for usurping your post and turning it into something different.  I believe that @JMGunnar  solved your problem with the Edit View command.

Inventor Pro / Vault Basic
0 Likes
Message 24 of 32

Ray_Feiler
Advisor
Advisor

Have you tried using Transparent (Alt+T) instead? It may not be available in IV2019.

Screenshot 2023-10-05 095623.png


Product Design & Manufacturing Collection 2024
Sometimes you just need a good old reboot.
0 Likes
Message 25 of 32

rhenstenburg
Advocate
Advocate

I don't recall when transparency was introduced ... thinking it was 2021 but not sure.

 

I am definitely wanting to work with Visibility.  Transparent parts are still able to be selected. Visible (& Enable) will remove a part from being selected; more desirable for my purpose.

Inventor Pro / Vault Basic
0 Likes
Message 26 of 32

rhenstenburg
Advocate
Advocate

Oops! @Ray_Feiler was replying to @gustav123456.  Sorry.

Inventor Pro / Vault Basic
0 Likes
Message 27 of 32

JMGunnar
Collaborator
Collaborator

Best Regards Johan 

 

This would works 

 

@rhenstenburg 

 

 Sub Main()
	ThisApplication.CommandManager.ControlDefinitions("AssemblyEnhSelAllInvisCompsCmd").execute
	
	ThisApplication.CommandManager.ControlDefinitions("AssemblyVisibilityCtxCmd").execute
	
	
	ThisApplication.CommandManager.ControlDefinitions("AssemblyEnhSelUndoCmd").execute
	
	ThisApplication.CommandManager.ControlDefinitions("AssemblyEnhSelInvertCmd").execute
	
	ThisApplication.CommandManager.ControlDefinitions("AssemblyVisibilityCtxCmd").execute


End Sub 



 

Message 28 of 32

rhenstenburg
Advocate
Advocate

Nice @JMGunnar ... I didn't have to figure it out myself.  Thanks!

 

I found an oddity with my method.  I tried it on an assembly that I'm currently working on.  In that assembly I have three folders with related components. The components in the folders are unaffected (doing it manually or with your code ... same process).  I deleted the folders and everything worked as expected.

 

An unexpected SNAFU.

Inventor Pro / Vault Basic
0 Likes
Message 29 of 32

Mgła3
Participant
Participant

I see lots of work arounds, but they're all a pain and slow. I have a solution, Inventor should just give us Tab and Shift-Tab to do the same thing. Why use painful workarounds when there should be a good solution provided by AutoCAD. Alternatively, we stop using it, that always speaks louder.

0 Likes
Message 30 of 32

emanuel.c
Collaborator
Collaborator

Here is my method. It isn't perfect, but fast enough I think. I use Alt+V to Hide Parts or Components (Sub Assemblies) and "V" to to bring them all back in view. This is by way of an External iLogic rule. This works on Inventor 2024, when external rules can be accessed in Tools -> Customize -> Keyboard for shortcuts, an amazing feature!

 

In Tools -> Customize -> Keyboard I use:

- Press 1: Part Priority (this is so I can quickly select between parts or subassemblies, for viewing editing etc.)

- Press 2: Component Priority (if you want to hide a subassemby)

- press V: Set component visibility (this is the external iLogic rule)

 

emanuelc_0-1707615004079.pngemanuelc_1-1707615018990.png

 

Here is the external rule. It refreshes the view representation and relies on "Default" View to exist. It may have to be adjusted if you have View Representations labeled differently. If you're working in an Assembly it sets all components to Visible, but hides "Referenced" components. If you're working on a Part, it calls a second rule "Set Surface Visibility", which is the second code I attached here. Please make sure the path of "Set Surface Visibility" is defined correctly.

 

I hope it helps. If you don't have any experience with iLogic it may be daunting, but you can do sooo much with iLogic, I think it's worth learning the basics at least!

 

 

'https://forums.autodesk.com/t5/inventor-forum/ilogic-rule-to-find-all-reference-parts-and-turn-off-visibilty/td-p/4305340

Sub Main()

	If ThisApplication.ActiveDocumentType = DocumentTypeEnum.kPartDocumentObject Then
		PartSurfaces
		Exit Sub
	ElseIf ThisApplication.ActiveDocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
		MsgBox("Eh, the rule '" & iLogicVb.RuleName & "doesn't work in Drawings", vbOKOnly, "WRONG DOCUMENT TYPE")
		Exit Sub
	End If
	
	Dim oDoc As Document
	oDoc = ThisDoc.Document
	Dim oAsmCompDef As AssemblyComponentDefinition
	oAsmCompDef = oDoc.ComponentDefinition
	oAssemblyComponents = oAsmCompDef.Occurrences
	
	oViewRepsCollection = oAsmCompDef.RepresentationsManager.DesignViewRepresentations
	oActiveViewRep = oAsmCompDef.RepresentationsManager.ActiveDesignViewRepresentation
	
	Dim oAVR As String = oActiveViewRep.Name
	'msgbox(oAVR)
	
	Dim oOccurrence As ComponentOccurrence
	Dim oViewRep As DesignViewRepresentation
	
	For Each oViewRep In oViewRepsCollection
		oViewRep.Activate
		'MsgBox(oViewRep.Name)
		Try	
			'Activate a writeable View Rep (master view rep is not writeable)	
			oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("Default").Activate	
		Catch	
			'Assume error means this View Rep does not exist, so create it	
			oViewRep = oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Add("Default")	
		End Try		
	    
		If oViewRep.Name.Contains("Default") Then
		'If oViewRep.Name = "Default" Then
			oViewRep.Activate
			For Each oOccurrence In oAssemblyComponents
				If (oOccurrence.BOMStructure = BOMStructureEnum.kReferenceBOMStructure) Then
					oOccurrence.Visible = False
				Else
					Try
						oOccurrence.Visible = True
					Catch
					End Try
				End If
			Next
		Else
			'Do nothing			    
		End If
	Next
	
	'oOccurrence.SetDesignViewRepresentation("Default",, True)	
	'oViewRep.DesignViewRepresentation("Default",, True)
	'oActiveViewRep.Activate 'Sets the view rep back to the one that was active before the rule was executed
	
	Representations 'call Representations Sub

End Sub

Sub Representations()

	Dim doc As AssemblyDocument = ThisDoc.Document  
	Dim oAsmCompDef As ComponentDefinition  
	oAsmCompDef = doc.ComponentDefinition 
	Dim oCompOcc As Inventor.ComponentOccurrence
	
	For Each oCompOcc In oAsmCompDef.Occurrences
	
	If oCompOcc.Visible = True Then
		Try
			oCompOcc.SetDesignViewRepresentation("Default", True)
		Catch
		End Try
	End If
	
	'On Error Resume Next
	Next
		
End Sub

Sub PartSurfaces()

	Dim oDoc As Document = ThisDoc.Document
	auto = iLogicVb.Automation
	'Define location of iLogic rule "Set Surface Visibility"
	auto.RunExternalRule(oDoc, "C:\Autodesk Inventor\Ilogic\Appearance - View Representations\Set Surface Visibility")
	
End Sub

 

 

Rule: "Set Surface Visibility" 

 

Sub Main()

	'catch and skip errors
	On Error Resume Next
		
	Dim Vis As Boolean
	Dim result = MessageBox.Show("Yes" & vbCrLf & "No - Turn Visibility OFF" & vbCrLf & _
		"Cancel - Exit", "Make all surfaces visible?", MessageBoxButtons.YesNoCancel)
	Select Case result
	    Case vbYes
	        Vis = True
	    Case vbNo
	        Vis = False
	    Case vbCancel
	        Exit Sub
	End Select
	
	'define the active assembly
	Dim oAssyDoc As AssemblyDocument
	oAssyDoc = ThisApplication.ActiveDocument	
	Dim oDoc As Inventor.Document = ThisApplication.ActiveDocument
	DocType = oDoc.DocumentType
	Dim oSurfacebody As WorkSurface
	
	If DocType = DocumentTypeEnum.kAssemblyDocumentObject Then		
		For Each oDoc In oAssyDoc.AllReferencedDocuments		    
		    For Each oSurfacebody In oDoc.ComponentDefinition.WorkSurfaces
		        oSurfacebody.Visible = Vis
		    Next
		Next
	Else		
		For Each oSurfacebody In oDoc.ComponentDefinition.WorkSurfaces
		        oSurfacebody.Visible = Vis
		    Next
	End If

	ThisApplication.ActiveDocument.Update

End Sub

 

 

 

0 Likes
Message 31 of 32

NigelHay
Advisor
Advisor

We often have assemblies which need additional parts for transportation when delivered & Jigs & fixtures for production operations. In the top level assembly I create folders for 'Transport' & 'Jigs' and put the relevant components in those folders. Thereafter, you can turn the visibility of the folders & all the contained parts, on or off in a single action.

0 Likes
Message 32 of 32

rhenstenburg
Advocate
Advocate

@emanuel.chas a good idea.  I also heavily use my own keyboard shortcuts.  In addition, we have written many routines using the Inventor API (these are stored in a DLL). These can also be accessed via keyboard shortcuts (or the ribbon).

 

Among other things, we have one routine specifically for visibility.  The downside of our visibility routine AND with iLogic is that they run much slower than native Inventor commands.  For small assemblies, this is not an issue. For large assemblies, this can become a huge hassle (holding your machine hostage for a while).  This is especially bad if we traverse the full depth of our assemblies to set visibility (we can set how deep to go, 0 = full depth, 1=top level only, etc).  I was hoping to find a method for inverting the visibility of every component in an assembly using Inventor native commands.  Unfortunately, things in folders and in arrays are all treated similarly (all will become visible or invisible together) when using the sequence of native commands I suggested earlier.

Inventor Pro / Vault Basic
0 Likes