Show hidden parts to unhide them

Show hidden parts to unhide them

DarthBane55
Advisor Advisor
3,807 Views
16 Replies
Message 1 of 17

Show hidden parts to unhide them

DarthBane55
Advisor
Advisor

This topic has been visited multiple times, with various levels of understanding.  Basically, long term Inventor users don't see a problem, but pretty much everybody coming to Inventor see a problem.

 

Problem: In assembly mode in particular, if you have many parts hidden, and want to show 1 particular part, it is a hassle to find it in the tree to unhide it.  You could create view reps, but you could end up with a multitude of them.  Sometimes you have a grid of the same part, say 200 instances of 1 part, and need to show 1 of them temporarily.  5 minutes later, you want to show a different one, to see possible alternatives for this assembly.  Creating view reps is not ideal.

 

Solution: click a button to show the hidden parts temporarily (show all hidden parts), select the ones you want to unhide, click ok, and done.

 

I believe it is possible to program this with API...  I'd have to think about it for a while myself, but has anyone seen anything that does this as a macro or addin or whatever else?  I just visited the addin store and didn't see one, and I searched on this forum and did not see the solution implemented.  If someone has come across the script for this solution, could you put down a link to it please, it would be incredibly appreciated.

 

Thanks!

0 Likes
Accepted solutions (1)
3,808 Views
16 Replies
Replies (16)
Message 2 of 17

A.Acheson
Mentor
Mentor

I can see your thought process  but I'm not sure if it would be entirely efficient to implement. It all depends on how large the parts are in terms of memory. Having all variations loaded into memory and just turning off and on the visibility could make for a big assembly file,not to mention the mass of the assembly will be out to lunch.  If it works for you in practice then all good. 

 

Your workflow is likely possible with the API. If you can do it manually you can program it to increase the speed. Can you show a sample of what you need to implement? 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 17

DarthBane55
Advisor
Advisor

You got some valid points there...  that's why I was thinking that I'd have to think about it for a while, not entirely sure it's doable/practical.  I was kind of thinking to make a loop going thru all the parts in the assembly and check for the "visibility" property, if there is such a thing (I programmed some API before but not much in Inventor).  Anything that would have that property=0 (or hidden state), I would temporarily revert, and vice-versa...  the tricky part would have to allow the user to click on them to change the visibility property to "visible", then reverse the process when user clicks ok.  That should then reshow what was originally visible, plus the parts that were selected by the user.

 

I will show a link below, I hope this is allowed, otherwise I will delete it, but it shows 100% exactly what I am after.  You can skip directly to 1m30s to get right to the bottom of it.

https://www.youtube.com/watch?v=hc64NINo6WM&ab_channel=ProgressionSupport

0 Likes
Message 4 of 17

A.Acheson
Mentor
Mentor

Here is the link to API help for the syntax of the occurrence below.  

https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-E81F1362-07E1-41C0-9152-29377F86C717

Syntax: ComponentOccurrence.Visible() As Boolean

 

Traverse the assembly sample written in VBA. 

https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-71992135-2633-4DE3-ACA7-60738CD204E7https...

 

You would then need to check if it is not visible and add to a collection which can be used to switch visibility. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 5 of 17

JMGunnar
Collaborator
Collaborator
Accepted solution

I right click in deisgn view and use "edit view" 

then you can use include och exlude mode 

 

Exludce_Include.JPG 

0 Likes
Message 6 of 17

DarthBane55
Advisor
Advisor

Thank you very much!  I think I'll make this a holiday project.

0 Likes
Message 7 of 17

DarthBane55
Advisor
Advisor

Are you kidding me!!!  How long does this thing exists for?  It's a few more clicks but I mean, that is exactly it!!!  It works perfectly, geeeeeezzzzz  all these years I've been wanting this feature!  And I'm not alone, many posts about this over the years.

Well anyways, thank you so much, very much appreciated!

0 Likes
Message 8 of 17

DarthBane55
Advisor
Advisor

I just added the icon on the ribbon, now there are no extra clicks, it works just the same as SW and NX.

Again, thank you so much, have a great day!!

0 Likes
Message 9 of 17

DarthBane55
Advisor
Advisor

@JMGunnar 

I just noticed that it restores all the sketches though.  So in assembly mode, if you use this function, it works great, but it shows all the assembly sketches.  Do you know a way around that?  Maybe a setting somewhere, or this is how it is and that's it maybe...  If that is intended behavior, I might still try and get this done in API just for fun.

0 Likes
Message 10 of 17

JMGunnar
Collaborator
Collaborator

Can create one picture or small assembly too explain 

 

i can not get "assembly sketch" too show in assembly.

 

Johan 

0 Likes
Message 11 of 17

DarthBane55
Advisor
Advisor

@JMGunnar 

Here you go, 1st picture is before using the function, you can see all assembly sketches are hidden:

1.png

 Then here, after using the function to show 2 additional green blocks, all assembly sketches turn on:

2.png

 

0 Likes
Message 12 of 17

J-Camper
Advisor
Advisor

If they are 2D sketches you can use F10 to toggle visibility, if they are 3D sketches, there is no short cut key, but Object Visibility under View tab has a spot to toggle.  It will take you out of the EditView command, so you would want to toggle before going into edit view:

temp_pic.JPG

you can also add either one to the Custom User Commands ribbon pane, just like editview:

temp_pic2.JPG

Message 13 of 17

DarthBane55
Advisor
Advisor

@J-Camper 

Thanks for that trick, F10 is not bad.  I never use the show all or hide all sketches, but it works, I might just have to change my ways a little (I usually show and hide individual sketches).  It beats anything else I tried so far (for the whole process of showing hidden parts).  

Thanks, I appreciate the trick!

Message 14 of 17

JMGunnar
Collaborator
Collaborator

We can create one external rule and add too button. 

then we report this as improvent too inventor-ideas

https://forums.autodesk.com/t5/inventor-ideas/idb-p/v1232 

 

Johan 

 

 

'catch and skip errors
On Error Resume Next
'define the active assembly
Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisApplication.ActiveDocument 

wfBoolean = False

For Each oSketch In oAssyDoc.ComponentDefinition​.Sketches
	 oSketch.Visible = wfBoolean
Next
InventorVb.DocumentUpdate()

 

 

0 Likes
Message 15 of 17

DarthBane55
Advisor
Advisor

@JMGunnar 

I will try to do what you said.  I will create an external rule and test it out.  I'll try to find out how to create a button from external rule.  But I also want the "edit view" thing to run with the same button.  Maybe there is a way to add the "edit view" function to this script?  Then it will do everything with 1 button?

 

EDIT:  I ran this rule, and it hides all the assembly sketches, which is great... however, I will throw a wrench in it a bit here...  do you think it is possible to only hide the sketches that were already hidden?  Meaning that, just before running the rule, if I had a few sketches that were visible, I'd like those to remain visible, not become hidden...  possible?  It will have to check the visibility status, record it, and restore it...

This is all with the ideal of using the edit view to show hidden parts.  So to sum it up:

-I run an iLogic rule that will record the visibility status of assembly sketches, then run the function "edit view" (at this point Inventor makes all assembly sketches visible), then restore the visibility status of the assembly sketches to what they were before running this rule.

I am not sure how difficult the iLogic rule just became... 😮

0 Likes
Message 16 of 17

JMGunnar
Collaborator
Collaborator

Check Hjalte  Button Creation 

its free add-ins from Autodesk Store 

 

https://apps.autodesk.com/INVNTOR/en/Detail/Index?id=2268703737300536294&appLang=en&os=Win64

 

 http://hjalte.nl/inventor-addins/31-button-constructor

 

@JelteDeJong 

 

Best regards Johan Gunnar 

Message 17 of 17

DarthBane55
Advisor
Advisor

I just got back to this, getting real close now.  I can store the visibility status of all assembly sketches in an array, and restore them all at the end.  So that part works.  But...

After storing the visibility status, I need to run the command "edit view" from under the view representation (it's under right click on a view representation). I got a long list of inventor commands, but this is not in the list I have.  Is there a command we can call to run this "edit view" from code?

I would run this, except I would replace the "AssemblyVisibilityCtxCmd" with actual command for "edit view".  This would have to be run from the "active" view representation:

 

Dim oControlDef As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyVisibilityCtxCmd")
oControlDef.Execute()

 

 

 If this command is not available to run from code, I created a keyboard shortcut in Inventor to run it.  I assigned "ctrl+E" to run the "edit view" command.  It works when I do the keystroke manually, but it does not from code.

Here's the code I have for this (I tried many variance on the brackets and whatnot but I can't make it work):

 

 

AppActivate(ThisApplication.Caption)
System.Windows.Forms.SendKeys.SendWait("{^E}")

 

 

Would anyone be able to help me, with either one of these solutions?

 

Thanks a lot!

0 Likes