sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Entity.visible? vs entity.hidden?

    Scheduled Pinned Locked Moved Developers' Forum
    21 Posts 8 Posters 2.0k Views 8 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • thomthomT Offline
      thomthom
      last edited by

      @al hart said:

      I believe they both refer the the hidden state, and have nothing to do with layer visibility.

      http://forums.sketchucation.com/viewtopic.php?f=180&t=23806#p202821 😉

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        You are right [as thomthom said] entity.hidden? is the same as !entity.visible
        You can also toggle entity.hidden=true/false and entity.visible=false/true

        TIG

        1 Reply Last reply Reply Quote 0
        • M Offline
          MartinRinehart
          last edited by

          @al hart said:

          both refer the the hidden state, and have nothing to do with layer visibility.

          Any reason not to declare visible? a bug?

          Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            @martinrinehart said:

            @al hart said:

            both refer the the hidden state, and have nothing to do with layer visibility.

            Any reason not to declare visible? a bug?

            I think the reply you would get is "By design".

            From the manual on Drawingelement.visible=:

            @unknownuser said:

            This method performs an opposite function to the hidden= method.

            http://code.google.com/apis/sketchup/docs/ourdoc/drawingelement.html#visible=

            I think a feature request for a different method that will return to whether the entity can be seen in the model or not is what we'd need to make. Drawingelement.seen? maybe? And more importantly, a method that will let us dig down backwards in the hierarchy of the entity tree.

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • Chris FullmerC Offline
              Chris Fullmer
              last edited by

              @martinrinehart said:

              Any reason not to declare visible? a bug?

              Yeah, because maybe its actually hidden? that's a bug 😄

              Ruby likes to have duplicate methods for the same process. Seems like many methods are available in the positive and negative form.

              Chris

              Lately you've been tan, suspicious for the winter.
              All my Plugins I've written

              1 Reply Last reply Reply Quote 0
              • J Offline
                Jim
                last edited by

                @chris fullmer said:

                Ruby likes to have duplicate methods for the same process. Seems like many methods are available in the positive and negative form.

                Except that hidden and visible are real attributes of objects, and should not have been used as aliases. Using visible as an alias for not hidden is crap. Leave the sugar out of the API.

                Hi

                1 Reply Last reply Reply Quote 0
                • Al HartA Offline
                  Al Hart
                  last edited by

                  @thomthom said:

                  @martinrinehart said:

                  Any reason not to declare visible? a bug?

                  At this point, if they some changed what it meant, it would break any scripts which were using it to mean "not hidden".

                  However, it would be nice if they added 1 to 3 of these new functions:

                  entity.is_visible? - not hidden, and not on a layer which is hidden (including groups and sub-components which are hidden or on layers which are hidden)
                  entity.is_in_current_view - is_visible? and also is visible in current camera view
                  entity.is_obstructed - is visible? but is behind something else which is not transparent.

                  The last two are pie-in-the-sky, but the first one would be a useful function.

                  However, as I write this I see that part of the problem is what is meant by an entity. As I drill down through the database and think I am pointed at a single, unqiue entity, I am often pointed to an entity in a component definition, which, if the component is used more than once may be in hidden instances of the same component, instances of the component which are on layers which are off, as well as in an instance which is visible.

                  What is needed here is a entity identifier which include the "path" to get to the entity, so it truly represents a single unique entity in terms of the display.

                  Al Hart

                  http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                  IRender nXt from Render Plus

                  1 Reply Last reply Reply Quote 0
                  • C Offline
                    cjthompson
                    last edited by

                    @al hart said:

                    entity.is_in_current_view - is_visible? and also is visible in current camera view
                    entity.is_obstructed - is visible? but is behind something else which is not transparent.

                    I think I would like at least these two to be part of the view object, and pass in an entity, not on the entity itself.

                    1 Reply Last reply Reply Quote 0
                    • M Offline
                      maxim1000
                      last edited by

                      It seems visible? and !hidden? are not the same...
                      I've attached model. visible?==!hidden? for all entities except the deepest one.
                      Here is log from my Ruby window:

                      m=Sketchup.active_model #<Sketchup::Model:0xb2ce678> m.entities[0].definition.entities[0].definition.visible? true m.entities[0].definition.entities[0].definition.hidden? true

                      and from my observation visible? is closer to the truth 😄


                      aaa.skp

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        You are testing the definition - definitions are not placed in the model and therefore can't be visible or hidden. ComponentInstances are what you need to test against.

                        Thomas Thomassen — SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 Reply Last reply Reply Quote 0
                        • M Offline
                          maxim1000
                          last edited by

                          @thomthom said:

                          You are testing the definition - definitions are not placed in the model and therefore can't be visible or hidden. ComponentInstances are what you need to test against.

                          Thanks for this remark, I'll adjust my code.

                          Since ComponentDefinition is inherited from Drawingelement, calling visible? and hidden? seems not to be some incorrect operation leading to undefined behaviour. Yes, they may not represent actual state of geometry, but this shows that visible? is not the same as !hidden? at least at implementation level, and thus can it be safely assumed that they are the same in all other cases?

                          1 Reply Last reply Reply Quote 0
                          • thomthomT Offline
                            thomthom
                            last edited by

                            @maxim1000 said:

                            Since ComponentDefinition is inherited from Drawingelement, calling visible? and hidden? seems not to be some incorrect operation leading to undefined behaviour. Yes, they may not represent actual state of geometry, but this shows that visible? is not the same as !hidden? at least at implementation level, and thus can it be safely assumed that they are the same in all other cases?

                            Error 404 (Not Found)!!1

                            favicon

                            (code.google.com)

                            @unknownuser said:

                            The visible= method is used to set the visible status for an element. This method performs an opposite function to the hidden= method.

                            Might be that the definition class causes an abnormality. Testing against any other DrawingElement derived class that actually is placed in the model they behave as expects. Though it is odd it should return true on both for definition.
                            In practice - they do refer to the same thing though.

                            Thomas Thomassen — SketchUp Monkey & Coding addict
                            List of my plugins and link to the CookieWare fund

                            1 Reply Last reply Reply Quote 0
                            • 1
                            • 2
                            • 1 / 2
                            • First post
                              Last post
                            Buy SketchPlus
                            Buy SUbD
                            Buy WrapR
                            Buy eBook
                            Buy Modelur
                            Buy Vertex Tools
                            Buy SketchCuisine
                            Buy FormFonts

                            Advertisement