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

    DC - hidden parts

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 196 Views 3 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.
    • T Offline
      tomasz
      last edited by

      How can I recogize a DynamicComponent? I guess I can look for a certain attribute, right?
      Is there a way in Ruby to recognize which part of a DC is currently not being displayed?

      Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        @unknownuser said:

        How can I recogize a DynamicComponent? I guess I can look for a certain attribute, right?

        def is_a_DC?( obj )
          obj.is_a?(Sketchup;;ComponentInstance) && obj.definition.attribute_dictionary("dynamic_attributes")
        end
        

        @unknownuser said:

        Is there a way in Ruby to recognize which part of a DC is currently not being displayed?

        ents = obj.definition.entities.to_a
        ehid = []
        ents.each {|e| ehid<<e if e.hidden? }
        

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • T Offline
          tomasz
          last edited by

          @dan rathbun said:

          obj.definition.attribute_dictionary("dynamic_attributes")

          Thanks!

          @dan rathbun said:

          ents = obj.definition.entities.to_a
          ehid = []
          ents.each {|e| ehid<<e if e.hidden? }

          I have to check this, but I test all entities visibility with .visible? and this doesn't work in components like a door with several wing types.
          hidden?==!visible? ?
          I have the attribute dictionary anyway. I can dig deeper now.

          Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            Components can contain nested Groups and other Components. The Components could be normal or dynamic.

            If nested, you'll need to do a recursive search (make a search method that calls itself.)

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • AdamBA Offline
              AdamB
              last edited by

              I believe there is a fundamental bug in the .visible? method.

              If you walk the hierarchy and query an entity.visible? state, it simply tells you whether it has explicitly been hidden, not whether it is visible.. very un-useful!

              You would need to follow the hierarchy all the way to the top to determine if any antecedent (parent) was hidden - and thus all subsequent children are hidden - to get the correct answer.

              Basically it requires you to structure code as a recursive descent.. which runs counter to the definition.instances graph-like structure.

              EDIT: as I'm writing this..are you saying hidden? and visible? are actually different?

              Developer of LightUp Click for website

              1 Reply Last reply Reply Quote 0
              • T Offline
                tomasz
                last edited by

                @dan rathbun said:

                Components can contain nested Groups and other Components. The Components could be normal or dynamic.
                If nested, you'll need to do a recursive search (make a search method that calls itself.)

                Dan, I am an author of two exporters , I have learned it few years ago. 😄 SU2Thea exports whole SU model hierarchy.

                @adamb said:

                You would need to follow the hierarchy all the way to the top to determine if any antecedent (parent) was hidden - and thus all subsequent children are hidden - to get the correct answer.
                Basically it requires you to structure code as a recursive descent.. which runs counter to the definition.instances graph-like structure.

                I do walk all the hierarchy from the very top till the last visible? entity. It works perfectly on all objects. SU2Thea exports everything fine except this door for example:

                The door has several layouts of a door leaf defined. They are all being exported, because when I check e.definition.entities all return true although not all are being visible on a screen at the same moment in the same instance.

                I guess I have to recognize whether I have a DC, then check which option has been chosen for the instance I investigate (probably an attribute) and then discard all faces in a definition that doesn't belong to the 'option' (I guess defined in an attribute of the instance again).

                I hope that is easy to distinguish parts of DC definition that are optional. If it isn't obvious from attributes that a DC stores then.. it will be hit or miss.

                @adamb said:

                EDIT: as I'm writing this..are you saying hidden? and visible? are actually different?

                I was asking Dan whether there is a difference, but I doubt. API Docs don't mention it.

                I will dig into the issue. I just thought someone has already been there.

                Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

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

                Advertisement