sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Remove and purge hidden components.

    Scheduled Pinned Locked Moved Developers' Forum
    19 Posts 4 Posters 4.0k Views 4 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.
    • TNTDAVIDT Offline
      TNTDAVID
      last edited by

      **Hello, ☀

      I'm currently finalizing Click-Cuisine 2.

      In order to offer a complete tool, it is essential for me to offer Click-Cuisine 2 specific functions.

      **Thanks to the many subjects opened in this formum and your help, Click-Cuisine allows to:
      **

      • Remove the included dynamic thumbnails of each furniture through their definitions and purge their materials.

      • Purge materials not used by Click-Cuisine furniture 2.

      To finish the functions of cleaning, I have to write 2 methods:

      • Purge the hidden dynamic components in all components with the "IKEA" definition.

      • Remove all dynamic attributes of components with the "IKEA" definition.

      I want to target the components with the IKEA definition, so as not to involuntarily affect other dynamic components.

      Any help from you will be greatly appreciated.

      Cordially

      David Barros**

      [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

      1 Reply Last reply Reply Quote 0
      • TNTDAVIDT Offline
        TNTDAVID
        last edited by

        **Hello, ☀

        After some research, I found this sample code:

        Sketchup.active_model.definitions.each {| d | d.entities.to_a.each {| e | e.erase! if e.hidden?}}
        

        The problem with this example is that hidden lines are deleted.

        I only want to remove he hidden components.

        thank you in advance for your help

        David**

        [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

        1 Reply Last reply Reply Quote 0
        • S Offline
          slbaumgartner
          last edited by

          Perhaps add && e.is_a?(SketchUp::ComponentInstance) to the if test? Also note that it would be good to check whether e.respond_to?(:hidden?) before doing e.hidden? since not all Entities support hidden, and if your code ever encounters one of these it will throw an exception.

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

            Consider this with 'grep'...

            Sketchup.active_model.definitions.each{|d|d.entities.grep(Sketchup;;ComponentInstance).each{|e|e.erase! if e.hidden?}}
            

            This will include only nested instances found inside definition's and then erase them, if they are hidden.

            TIG

            1 Reply Last reply Reply Quote 0
            • TNTDAVIDT Offline
              TNTDAVID
              last edited by

              Thank you TIG and slbaumgartner ☀

              The TIG example works perfectly. 👍

              [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

              1 Reply Last reply Reply Quote 0
              • TNTDAVIDT Offline
                TNTDAVID
                last edited by

                **Is it possible to purge hidden components inside components with the IKEA definition only?

                This will avoid affecting all the file to target only the 3D models proposed by Click-Kitchen 2.

                For example:

                Method A selects all components with the IKEA definition.

                # Method A
                m=Sketchup.active_model;s=m.selection;m.definitions.each{|d|s.add d.instances if d.name=~/#{"IKEA"}/}
                

                Method B searches for hidden components inside the selection and deletes them.

                To write Method B, I need your help.

                Thank you

                David**

                [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

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

                  (1) Why are you putting quotes around IKEA ? (The regular expressions are themselves specially treated double quoted strings.)

                  I'm not here much anymore.

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

                    (2) You are wasting time pushing objects into the selection set.
                    This is not necessary in order to modify them.

                    (3) Instances do not "own" any nested components. Definitions own nested objects.
                    So you should be collecting a set of IKEA definitions, and then searching the definitions entities collection(s) (in that set,) for hidden objects.
                    When a definition has a child object that is hidden, it will be hidden in ALL of the definition's instances.
                    When you delete a hidden object from a definition, ALL of it's instances will have that child object deleted.

                    I'm not here much anymore.

                    1 Reply Last reply Reply Quote 0
                    • TNTDAVIDT Offline
                      TNTDAVID
                      last edited by

                      **I'm not sure I understand all of your logical reasoning Dan. 😕

                      I want to delete hidden definitions and not instances.

                      For example:

                      Dynamic Cabinet consists of a Drawer and a Door.

                      The Drawer is hidden by its "Hidden" attribute.

                      The Gate is visible by its "Hidden" attribute.

                      Both have instances "Handles" in "sub-component".

                      The method must delete the "Drawer" definition because it is hidden.

                      Thus, only the "Handles" instance of the drawer will be deleted without affecting the same instances of the door.

                      Cordially

                      David**

                      [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

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

                        @tntdavid said:

                        I want to delete hidden definitions and not instances.

                        Definitions are not hidden in the model, because they do not exist in the model entities collection (only instances do.)

                        When a definition is "hidden", it does not appear in the Components Browser list, but still is a member of the model's DefinitionList collection.

                        I'm not here much anymore.

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

                          As Dan says don't mess on with the selection-set...
                          IF you actually need to collect things for later use, consider using an array [] or a hash {}...
                          But that is NOT needed here...
                          How about this ?

                          Sketchup.active_model.definitions.each{|d|next unless d.name=~/IKEA/; d.entities.grep(Sketchup;;ComponentInstance).each{|e|e.erase! if e.hidden?}}
                          

                          This deletes all nested entities within any definition named /IKEA/, if they are hidden...

                          TIG

                          1 Reply Last reply Reply Quote 0
                          • TNTDAVIDT Offline
                            TNTDAVID
                            last edited by

                            **Sorry Dan, I mixed brushes between definitions and instances ...

                            It's wonderful TIG, your code meets 100% to my needs. 👍

                            I want to be very careful with the selections or deletes, for this reason your example is perfect.

                            The code below removes all attributes of all dynamic components present in a SketchUp file.

                            m=Sketchup.active_model;m.start_operation("unDC");m.definitions.each{|d|d.attribute_dictionaries.delete("dynamic_attributes") if d.attribute_dictionaries and d.attribute_dictionaries["dynamic_attributes"];d.instances.each{|i|i.attribute_dictionaries.delete("dynamic_attributes") if i.attribute_dictionaries and i.attribute_dictionaries["dynamic_attributes"]}};m.commit_operation
                            

                            How to adapt this code so that it only deletes the dynamic attributes of all nested entities in the named definitions / IKEA / ?

                            Thank you**

                            [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

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

                              Adjust ...;m.definitions.each{|d|d.attribute_dictionaries...
                              to something like this:
                              ...;m.definitions.each{|d|**next unless d.name=~/IKEA/;**d.attribute_dictionaries...
                              To limit the action to /IKEA/ named definitions...

                              TIG

                              1 Reply Last reply Reply Quote 0
                              • TNTDAVIDT Offline
                                TNTDAVID
                                last edited by

                                **


                                Wonderful! Your example works TIG, for instances with IKEA definitions:**

                                m=Sketchup.active_model;m.start_operation("unDC");m.definitions.each{|d|next unless d.name=~/IKEA/; d.attribute_dictionaries.delete("dynamic_attributes") if d.attribute_dictionaries and d.attribute_dictionaries["dynamic_attributes"];d.instances.each{|i|i.attribute_dictionaries.delete("dynamic_attributes") if i.attribute_dictionaries and i.attribute_dictionaries["dynamic_attributes"]}};m.commit_operation
                                

                                Is it possible to purge dynamic attributes of nested components in instances with IKEA definitions?

                                Thank you

                                [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

                                1 Reply Last reply Reply Quote 0
                                • TNTDAVIDT Offline
                                  TNTDAVID
                                  last edited by

                                  **Bonjour,

                                  Votre solution TIG pour supprimer les composants masqués à l'intérieur des définition IKEA, fonctionne très bien! 😉

                                  Sketchup.active_model.definitions.each{|d|next unless d.name=~/IKEA/; d.entities.grep(Sketchup;;ComponentInstance).each{|e|e.erase! if e.hidden?}}
                                  

                                  A l'intérieur de la définition IKEA, il y a beaucoup d'autres définitions qui ont des sous composants masqués.

                                  Est-il possible de supprimer tous les composants masqués pour toutes les définitions présentes dans les meubles IKEA ?

                                  L'idéal serait de na pas avoir à citer toutes les définitions existant dans les meubles IKEA.

                                  Merci**

                                  [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

                                  1 Reply Last reply Reply Quote 0
                                  • TNTDAVIDT Offline
                                    TNTDAVID
                                    last edited by

                                    **Little reminder:

                                    It is possible to remove all hidden components of a SketchUp file, with this method:

                                    Sketchup.active_model.definitions.each{|d|d.entities.grep(Sketchup;;ComponentInstance).each{|e|e.erase! if e.hidden?}}
                                    

                                    It is possible to remove all hidden components with the name of a definition, with this method:

                                    Sketchup.active_model.definitions.each{|d|next unless d.name=~/IKEA/; d.entities.grep(Sketchup;;ComponentInstance).each{|e|e.erase! if e.hidden?}}
                                    

                                    How to remove all hidden components and sub-components in a selection?

                                    Thank you

                                    David**

                                    [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

                                    1 Reply Last reply Reply Quote 0
                                    • TNTDAVIDT Offline
                                      TNTDAVID
                                      last edited by

                                      **I finally found how to remove hidden sub-components from a selection:

                                      mod = Sketchup.active_model
                                      sel = mod.selection
                                      sel.grep(Sketchup;;ComponentInstance).each{|s|;
                                      s.definition.entities.grep(Sketchup;;ComponentInstance).each{|e|e.erase! if e.hidden?}}
                                      

                                      The problem is that only the first level of nesting is removed by the method.

                                      I will continue to search in esperente found the solution.

                                      See you

                                      David**

                                      [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

                                      1 Reply Last reply Reply Quote 0
                                      • TNTDAVIDT Offline
                                        TNTDAVID
                                        last edited by

                                        **I can select all the definitions by their names and apply a cleaning of hidden components:

                                        
                                        def methode1 ### select components and sub-components with the name of the definitions.	
                                            ["IKEA","DOOR","DRAWER","HANDLES"].each{|name|
                                            match = /#{name}/i	
                                            m=Sketchup.active_model;
                                            s=m.selection;
                                            m.definitions.each{|d|s.add d.instances if d.name =~ match }}
                                            end	
                                        	
                                        def methode2 ### remove hidden components in the selection		
                                            Sketchup.active_model.selection.grep(Sketchup;;ComponentInstance).each{|s|
                                            s.definition.entities.grep(Sketchup;;ComponentInstance).each{|e|e.erase! if e.hidden?}}
                                            end
                                        		
                                        def methode_end 
                                            methode1
                                            methode2	
                                            end
                                        

                                        I'm progressing but this solution is not great. 😕

                                        Any help would be highly appreciated.**

                                        [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

                                        1 Reply Last reply Reply Quote 0
                                        • TNTDAVIDT Offline
                                          TNTDAVID
                                          last edited by

                                          **They always told me to be persistent and I thank all those who gave me this advice. 😄

                                          Here is the method to remove all hidden sub-components in a parent component:

                                          
                                          def supprimer_tous_les_sous_composants_selection(instance)
                                              children = instance.definition.entities.select { |e| e.respond_to?(;definition) }
                                              children.each { |c| supprimer_tous_les_sous_composants_selection(c);
                                              c.erase! if c.hidden?
                                              }
                                              end
                                          	
                                              supprimer_tous_les_sous_composants_selection(Sketchup.active_model.selection.first)
                                          

                                          Here is the method to remove all the dynamic attributes of all the components present in a selection:

                                          
                                          def selectionner_tous_les_sous_composants_selection(instance)
                                              children = instance.definition.entities.select { |e| e.respond_to?(;definition) }
                                              instance.model.selection.add(children)
                                              children.each { |c| selectionner_tous_les_sous_composants_selection(c);
                                              }
                                              end	
                                          	
                                          def supprimer_tous_les_attributs_dynamiques_selection
                                              mod = Sketchup.active_model
                                              sel = mod.selection
                                              sel.each{|s|s.definition.attribute_dictionaries.delete("dynamic_attributes");
                                            sel.grep(Sketchup;;ComponentInstance).each{|i|i.attribute_dictionaries.delete("dynamic_attributes")}}
                                              end	
                                          	
                                          def desactiver_toutes_les_selections
                                              mod = Sketchup.active_model
                                              ent = mod.active_entities
                                              sel = mod.selection
                                              instances = sel.grep(Sketchup;;ComponentInstance)
                                              sel.clear
                                              end		
                                          	
                                          selectionner_tous_les_sous_composants_selection(Sketchup.active_model.selection.first)
                                          supprimer_tous_les_attributs_dynamiques_selection
                                          desactiver_toutes_les_selections
                                          
                                          

                                          You can test these methods directly with the ruby console, after selecting a dynamic component.

                                          You will notice that all hidden components and dynamic attributes will be removed, even if they are nested at multiple levels.

                                          Thank you to everyone who helped me. 😉

                                          See you

                                          David**

                                          [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

                                          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