[Blender 2.8]Selected object export - Collection disabled - Error - not in view
did not found related issue, please close if there is one.

Description:
**For exporter Selected object param ONLY:**

In my Scene view list when i have hidden Collection(disabled checkbox) with bezier curves(i got them for hair construct) it throw error like below.

if i have it visible, no error is thrown and everything is properly exported.

expect it work for hidden Collection too.


error:

> Traceback (most recent call last):
>   File "C:\\Home\\tools\\Windows\\blender-2.80.0-git.9bae9b634ec6-windows64\\2.80\\scripts\\addons\\io_scene_gltf2\\__init__.py", line 412, in execute
>     return gltf2_blender_export.save(context, export_settings)
>   File "C:\\Home\\tools\\Windows\\blender-2.80.0-git.9bae9b634ec6-windows64\\2.80\\scripts\\addons\\io_scene_gltf2\\blender\\exp\\gltf2_blender_export.py", line 40, in save
>     json, buffer = __export(export_settings)
>   File "C:\\Home\\tools\\Windows\\blender-2.80.0-git.9bae9b634ec6-windows64\\2.80\\scripts\\addons\\io_scene_gltf2\\blender\\exp\\gltf2_blender_export.py", line 54, in __export
>     __gather_gltf(exporter, export_settings)
>   File "C:\\Home\\tools\\Windows\\blender-2.80.0-git.9bae9b634ec6-windows64\\2.80\\scripts\\addons\\io_scene_gltf2\\blender\\exp\\gltf2_blender_export.py", line 69, in __gather_gltf
>     scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings)
>   File "C:\\Home\\tools\\Windows\\blender-2.80.0-git.9bae9b634ec6-windows64\\2.80\\scripts\\addons\\io_scene_gltf2\\blender\\exp\\gltf2_blender_gather.py", line 34, in gather_gltf2
>     scenes.append(__gather_scene(blender_scene, export_settings))
>   File "C:\\Home\\tools\\Windows\\blender-2.80.0-git.9bae9b634ec6-windows64\\2.80\\scripts\\addons\\io_scene_gltf2\\blender\\exp\\gltf2_blender_gather_cache.py", line 51, in wrapper_cached
>     result = func(*args)
>   File "C:\\Home\\tools\\Windows\\blender-2.80.0-git.9bae9b634ec6-windows64\\2.80\\scripts\\addons\\io_scene_gltf2\\blender\\exp\\gltf2_blender_gather.py", line 52, in __gather_scene
>     node = gltf2_blender_gather_nodes.gather_node(blender_object, export_settings)
>   File "C:\\Home\\tools\\Windows\\blender-2.80.0-git.9bae9b634ec6-windows64\\2.80\\scripts\\addons\\io_scene_gltf2\\blender\\exp\\gltf2_blender_gather_cache.py", line 51, in wrapper_cached
>     result = func(*args)
>   File "C:\\Home\\tools\\Windows\\blender-2.80.0-git.9bae9b634ec6-windows64\\2.80\\scripts\\addons\\io_scene_gltf2\\blender\\exp\\gltf2_blender_gather_nodes.py", line 35, in gather_node
>     if not __filter_node(blender_object, export_settings):
>   File "C:\\Home\\tools\\Windows\\blender-2.80.0-git.9bae9b634ec6-windows64\\2.80\\scripts\\addons\\io_scene_gltf2\\blender\\exp\\gltf2_blender_gather_nodes.py", line 76, in __filter_node
>     if export_settings[gltf2_blender_export_keys.SELECTED] and blender_object.select_get() is False:
> RuntimeError: Error: Object 'BezierCurve.001' not in View Layer 'View Layer'!
> 
> 
> location: <unknown location>:-1





Screenshots:

https://i.imgur.com/LPVv2ec.png
https://i.imgur.com/uLj0kK2.png
https://i.imgur.com/SEEmd71.png

 - OS: Windows  (dont be confused with Home dir)
 - Blender Version: 2.8

diff --git a/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py b/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
index 16331ff7..20fd3ba1 100644
--- a/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
+++ b/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
@@ -79,12 +79,12 @@ def __filter_node(blender_object, blender_scene, export_settings):
             if blender_object.name not in blender_scene.objects:
                 return False
     else:
-        if export_settings[gltf2_blender_export_keys.SELECTED] and blender_object.select_get() is False:
-            return False
         if blender_scene is not None:
             instanced =  any([blender_object.name in layer.objects for layer in blender_scene.view_layers])
             if instanced is False:
                 return False
+        if export_settings[gltf2_blender_export_keys.SELECTED] and blender_object.select_get() is False:
+            return False
 
     return True
 
['addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py']