Browser/Tree doesn't update to reflect visibility tag when changed by rule

Browser/Tree doesn't update to reflect visibility tag when changed by rule

Nicholas_SmithF4ZUA
Participant Participant
354 Views
7 Replies
Message 1 of 8

Browser/Tree doesn't update to reflect visibility tag when changed by rule

Nicholas_SmithF4ZUA
Participant
Participant

A few weeks ago I set up an external rule that simply ensure all objects in an assembly are set to visible all the same as what the 'All Visible' button in Representations does but able to be thrown on toolbar for quicker access.

While it makes everything visible just fine, the browser doesnt update to recognize that the parts are in fact set to visible leading to weird issues such as showing the bounding box of the object and sometimes making for weird interactions with constraints or movement.

 

Right clicking the objects and clicking the visible button will toggle the checkbox and browser to 'on' and clear these issues for that specific part, but it shouldnt be doing this to begin with.

Nicholas_SmithF4ZUA_1-1753808202145.png

 

Figure: The clearly visible door subassembly has a bounding box in viewport and is listed as invisible by the browser...
I have tried forcing updates, global updates, Rebuild All, refreshing the component itself, all kinds of things. Whatever the visibility flag targeted by the Ilogic rule is, it must be separate from the one the browser populates from.

Nicholas_SmithF4ZUA_2-1753809206506.png

^ Iproperties 'Occurrence tab, Visibility flag not checked despite again, door being visible

Dim oDoc As Document
Dim Occ As ComponentOccurrence
Dim comp As ComponentOccurrencesEnumerator
Dim invApp As Inventor.Application
invApp = ThisApplication
oDoc = ThisDoc.Document 'local variable to shorthand to current document
comp =oDoc.ComponentDefinition.Occurrences.AllleafOccurrences '"AllLeafOccurrences" make rule read the lowest level components making hidden parts within subassemblies visible (unclear of top-level equivalent)
For Each Occ In comp 'Applies following to all components encompased
   Occ.Visible = True 'Sets visible boolean to True
Next


note: no file attached as bug seems to work in any assembly

 

0 Likes
Accepted solutions (1)
355 Views
7 Replies
Replies (7)
Message 2 of 8

WCrihfield
Mentor
Mentor

You mentioned document updates, rebuilds, and such, but did you also try this one:

ThisApplication.ActiveView.Update()

 If that also does not do what you are wanting, then you may have to check the value of the Application.ScreenUpdating Property, and if it is set to False, then set it to True.  Sometimes folks set that to False in their code processes, but an error happens before their code can set its value back to True, leaving a condition like this.  Should always use a Try...Catch...End Try statement for those types of situations, to ensure it always gets set back, even if an error happens.

If Not ThisApplication.ScreenUpdating Then ThisApplication.ScreenUpdating = True

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 8

WCrihfield
Mentor
Mentor

Another thing that came to mind is the BrowserPane.Refresh method, or more likely the BrowserPane.Update method (see its description).  I was originally thinking about activating (BrowserPane.Activate) a different browser pane, the reactivating the 'model' one again, but one of those other methods should be sufficient to try first.  Not something I necessarily do often (if ever), but something that could be tried I suppose.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 8

Nicholas_SmithF4ZUA
Participant
Participant

I had tried ThisApplication.ActiveView.Update() already to no success both within the For Each and just at the end of the script.
I gave ThisApplication.ScreenUpdating() = True a shot at the top of the script and at the bottom but it made for no difference either. 
Logs and debug testing suggest no reason to assume an error in the script as far as I can tell.

I had noted that the error was reproduceable in any assembly, thats not entirely accurate, it seems to need a sufficient complexity or something before it shows up or something to do with subassemblies being present, not quite pinpointed yet.

I played around with the BrowserPane refresh and update lines but couldnt get anything to really happen with them while I had time to play with it today.
If you have a complete code snippet for it that you think should work please toss it in here and I'll try it.

I'll be back at work to try any follow-up suggestions Tuesday. Thank you for the suggestions sofar.

0 Likes
Message 5 of 8

WCrihfield
Mentor
Mentor

OK.  As for the browser pane code example, I would just try something simple like the following line of code:

oActiveDoc.BrowserPanes.ActivePane.Update()

...where the 'oActiveDoc' variable represents the currently 'active' Document object (not a 'referenced' document or invisibly opened one).

Out of curiosity, is the assembly 'fully loaded' or is it in 'express mode' when this happens?  There is a setting in Inventor's Application Options dialog, on the Assembly tab, near the bottom, for enabling express mode, and setting a threshold for when it will be used to a specific number of files involved.  For a long time I had that number set pretty low, so that most assemblies would automatically load in express mode by default, which seemed to be working just fine.  However, when it is a relatively complex assembly with lots of 'work features' and components in it, the assembly would not look normal at first, because a lot of stuff would be showing/visible that I know I had turned the visibility off for.  But once I clicked the button in the ribbon to fully load the assembly (opposite of express mode), that fixed all that visibility issues.  This is because while in express mode, it was not obeying all of the 'view representations' settings, but once it was fully loaded, it obeyed them again, as it should.  Just reminds me a bit of the behavior you were seeing, but maybe not quite the same.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 8

harvey3ELEA
Advocate
Advocate
Accepted solution

I may be off target here, but I use this ultra-simple "All-Visible" code to run an iLogic external rule:

 

ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.ActiveDesignViewRepresentation.ShowAll

'ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.ActiveDesignViewRepresentation.HideAll

 

Then I simply create a ribbon button of it via "Customize/Ribbon Tab", selecting the code and adding it to the right-hand window:

harvey3ELEA_0-1753995059669.png

 

That subsequently creates this quick-access button on the panel I choose (not skilled at changing the button icon):

harvey3ELEA_1-1753995119877.png

 

Lastly, this does change the tree's icon from gray to colored indicating it's visible/active.

 

 

0 Likes
Message 7 of 8

Nicholas_SmithF4ZUA
Participant
Participant

@harvey3ELEA That may be perfect, didnt realize we could just call the command that representations uses directly like that, does exactly what I needed.

 

@WCrihfield Thanks again for your help, even if Im running with Harvey's solution.
To answer your questions for posterity's sake, Express was enabled but only after 500 unique references but we only have 113 in the assembly I'm primarily testing in.
I turned Express off just to check but still had the issue.
I also worked in the ActivePane code, but it didn't resolve the tree displaying weird either.
I would guess that the issue lies in the method of recursively setting the visibility tag and that seeming to effect maybe only a graphical tag or maybe not making a proper change within the assembly, but thats all over my head I think, I just make 3D lol

Thanks again both of you o7

Message 8 of 8

harvey3ELEA
Advocate
Advocate

Nicholas, I was in the same boat a while back when I stumbled upon that 'All Visible - All Hidden' code from this very forum.  I was thrilled to see how simple it was to set up since I'm rather inept at Ilogic coding, although I can understand some of it.

 

I also set a keystroke (AV) to run that All Visible routine.  Both the keystroke and button methods make a lot of these rules quick and easy.

 

WCrihfield is very talented (and extremely helpful) with the concept of compiling ilogic rules and I have saved a couple of those in my Ilogic code library.  He understands the Ilogic coding side of things at a different, higher level than most.