Show Hidden Components, Make Collection/Selection Visible/Invisible

Show Hidden Components, Make Collection/Selection Visible/Invisible

cnoJTCG6
Contributor Contributor
2,038 Views
12 Replies
Message 1 of 13

Show Hidden Components, Make Collection/Selection Visible/Invisible

cnoJTCG6
Contributor
Contributor

I have a sweet little iLogic rule that sets all Invisible components to Visible and the Visible to Invisible.
Prior to this, the number of Visible and Invisible components is determined which happens very quickly, Inventor knows this in no time.
Then I don't know any other way than to go through the collection one by one and do a visible/unvisible comparison and then connect the reversed action to it, this method takes quite some time.
My question: Can this be done faster?
Is there a way to make a collection or selection visible/invisible at once?
See video and attachment(Code incl. Button with VBA code/module).

0 Likes
2,039 Views
12 Replies
Replies (12)
Message 2 of 13

pcrawley
Advisor
Advisor

 

You can do all that from the selection menu:

 

>Select Part Priority

Window select all visible components, right-click > Visibility (to make them invisible)

>Previous Selection

>Invert Selection (now you have everything that was invisible selected)

Right-click > Visibility (to make them visible)

03.jpg

 

If you are looking for iLogic or other coding advice, you might have more luck over on the Inventor iLogic and VB.net Forum - Autodesk Community forum: 

Peter
Message 3 of 13

cnoJTCG6
Contributor
Contributor

@pcrawley

Thank you for your response and clear explanation.
It is a bit cumbersome to be able to see what you have 'hidden' in a Design View, I think that button could have been there for a long time given the amount of code that is apparently required.
What is your experience with this method on an assembly with about 1600 occurrences?
Things don't run smoothly here, especially with Part priority it takes a long time for the selection to 'get through'.
I think I already love the button 🙂

 

Actually I was under the impression to have posted this post in 'Inventor iLogic and VB.net' Forum.
I did accidentally have '/' in the tags and removed them.
Could this also have changed the destination?
Btw, I still have strange experiences with the forum in the sense of spontaneously logging out, this has been going on for months now.
I just have to smile now, I think Autodesk tries to keep the Inventor style alive on the forum, a form of consistency.

 

0 Likes
Message 4 of 13

pcrawley
Advisor
Advisor

In a previous life, I had a few customers using a similar workflow on assemblies with 30,000+ (mostly unique) parts and it worked OK.

 

Are you using Vault?  I think that since all the files are local in a Vault environment, it dramatically helps the selection speed.

Peter
Message 5 of 13

checkcheck_master
Advocate
Advocate

@pcrawley 

Thanks again for your response.

Yes we are using vault.

 

0 Likes
Message 6 of 13

CGBenner
Community Manager
Community Manager

@cnoJTCG6 wrote:

 

Actually I was under the impression to have posted this post in 'Inventor iLogic and VB.net' Forum.
I did accidentally have '/' in the tags and removed them.
Could this also have changed the destination?
Btw, I still have strange experiences with the forum in the sense of spontaneously logging out, this has been going on for months now.
I just have to smile now, I think Autodesk tries to keep the Inventor style alive on the forum, a form of consistency.

 


@checkcheck_master @cnoJTCG6 

Did you still wish to have this post moved to the iLogic forum?

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!


Chris Benner
Community Manager

0 Likes
Message 7 of 13

checkcheck_master
Advocate
Advocate

@CGBenner 

Yes please, that would be nice, thanks for the thoughtfulness.

0 Likes
Message 8 of 13

Lucas.dolinarVFXZU
Collaborator
Collaborator

Sry, but i don't think i understand your goal...

do you already have a rule?

 

(i think the attached video went missing?)

0 Likes
Message 9 of 13

marcin_otręba
Advisor
Advisor

try this:

 

Dim ass As AssemblyDocument = ThisApplication.ActiveDocument
For Each occ As ComponentOccurrence In ass.ComponentDefinition.Occurrences
	If occ.Visible = True Then
		occ.Visible=False
		
		Else
			occ.Visible=True
		End If

	Next

 

if this will not be enough for you we could try to do it trough selectset and execute command trough command manager.

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 10 of 13

marcin_otręba
Advisor
Advisor
0 Likes
Message 11 of 13

Lucas.dolinarVFXZU
Collaborator
Collaborator

Wouldn't a branchless version be faster?

 

occ.Visible = Not occ.Visible

 

0 Likes
Message 12 of 13

marcin_otręba
Advisor
Advisor

hi, for large assemblies it could be faster, but still i think it will be faster to change visibility with one command, this approach even simplified like you suggested will be slower, this is because switching visibility is most time consuming operation here.

 

this one could be faster:

 

Dim ass As AssemblyDocument = ThisApplication.ActiveDocument
Dim selset As SelectSet = ass.SelectSet
Dim o_vis As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim o_hid As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
o_vis.Clear
o_hid.Clear
For Each occ As ComponentOccurrence In ass.ComponentDefinition.Occurrences
	If occ.Visible = False Then o_hid.Add(occ) 
	If occ.Visible = True Then o_vis.Add(occ)
Next
selset.Clear
selset.SelectMultiple(o_vis)
	
ThisApplication.CommandManager.ControlDefinitions("AssemblyVisibilityCtxCmd").Execute
 
selset.Clear
selset.SelectMultiple(o_hid)
ThisApplication.CommandManager.ControlDefinitions("AssemblyVisibilityCtxCmd").execute
selset.Clear
o_vis.Clear
o_hid.Clear
o_vis = Nothing
o_hid=Nothing

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 13 of 13

checkcheck_master
Advocate
Advocate

Thanks everyone for the responses.

 

@marcin_otręba 
Thanks for your code.
That's what I had in mind too, but didn't do what I wanted.
I've incorporated your code into what I already had, I've excluded suppressed components to get it working for my assembly with suppressed components.
What surprises me is the speed difference.
I expected that with a collection it would run much smoother, but it seems to go slower.
Am I doing something wrong or can it be done differently?
See video for a comparison, code as attachment.
Apart from the fact that the code does work and it can be a handy tool compared to the clicks you have to make otherwise, it intrigues me why it should take so long.
Right-clicking on a design view and choosing show all or hide all is lightning fast, even if a part is already visible.
How does Inventor do that itself, I wonder.

0 Likes