How to "Show All" in a part document with iLogic?

How to "Show All" in a part document with iLogic?

acheungR3ZK5
Contributor Contributor
96 Views
4 Replies
Message 1 of 5

How to "Show All" in a part document with iLogic?

acheungR3ZK5
Contributor
Contributor

How do I call the "Show All" command (shown in screenshot) in a part document with iLogic? I know how to loop through all the parts and make them visible if not visible, but it takes longer if there are many parts and you can't undo the whole command in one undo. 

acheungR3ZK5_0-1759319151202.png

 

0 Likes
Accepted solutions (1)
97 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

Hi @acheungR3ZK5.  That looks like it could be the DesignViewRepresentation.ShowAll method.  It only effects the currently 'active' DVR (DesignViewRepresentation) in the model file.  So, if you activate a different DVR, different things may be in different visibility statuses and different appearances, because those are the types of things that DVR's record & control.

WCrihfield_0-1759330711125.png

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

acheungR3ZK5
Contributor
Contributor

@WCrihfield Perhaps I am using the method wrong, but I get an Unspecified error (0x80004005 (E_FAIL)) when running the following code. I am using it in a part document with the goal of showing all bodies, not in an assembly document. 

 

Dim partDoc As PartDocument
partDoc = ThisApplication.ActiveDocument

Dim compDef As PartComponentDefinition
compDef = partDoc.ComponentDefinition

Dim activeViewRep As DesignViewRepresentation = compDef.RepresentationsManager.ActiveDesignViewRepresentation
activeViewRep.ShowAll

 

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor
Accepted solution

I must have been remembering wrong.  I did not see any other regular Inventor API or iLogic API method for hiding or unhiding multiple bodies at the same time, without using suppression.  But, I did some searching within my custom iLogic snippets and found something that could likely be used.  They are essentially just the 'commands' (ControlDefinitions) for the user interface tools involved, which we can 'execute' to simulate the user clicking on them.  Due to their very nature, using them will only effect the currently 'active' document (the one visible on your screen at the moment they are executed).

This is the command for showing all bodies:

ThisApplication.CommandManager.ControlDefinitions.Item("ShowAllBodiesCtxCmd").Execute()

...and here is the one for hiding all other bodies, except the one(s) selected:

ThisApplication.CommandManager.ControlDefinitions.Item("HideOtherBodiesCtxCmd").Execute()

 ...and here is an example iLogic rule for 'toggling' the visibility status of a group of bodies at once, which also uses yet another 'command execution', instead of a true API method.

Dim oApp As Inventor.Application = ThisApplication
Dim oPDoc As PartDocument = oApp.ActiveDocument
Dim oSBColl As ObjectCollection = oApp.TransientObjects.CreateObjectCollection()
For Each oSB As SurfaceBody In oPDoc.ComponentDefinition.SurfaceBodies
    oSBColl.Add(oSB)
Next
oPDoc.SelectSet.Clear()
oPDoc.SelectSet.SelectMultiple(oSBColl)
oApp.CommandManager.ControlDefinitions.Item("PartVisibilityCtxCmd").Execute()

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

acheungR3ZK5
Contributor
Contributor

Thank you Wesley! It works perfectly. And I have certainly learned something new with command executions. I expect this technique will come in handy in the future! 

0 Likes