sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Kill dynamic components?

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    14 Posts 9 Posters 3.8k Views 9 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.
    • M Offline
      Marron
      last edited by

      How do I make a dynamic component non dynamic. Sometimes I want to make some changes in the dynamic component, but the "settings" of the groups make the components unmovable. For example move the legs of a table to another position. I want to keep the groups of the object that the dynamic component exists of, but clear all settings.

      Thanks in advance.

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

        This one-liner copy+paste+<enter> in the Ruby Console will stop a selected DC from being dynamic

        Sketchup.active_model.selection[0].definition.attribute_dictionaries.delete('dynamic_attributes')
        

        use wisely... 😲

        TIG

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

          I have a plugin that can "strip DC attributes", optionally delete sub-components which are hidden, and reset the scale mask. I wrote it for a business that uses DC's internally but wanted to protect their IP and reduce file size before making their models public. I have been meaning to get it posted.

          Hi

          1 Reply Last reply Reply Quote 0
          • AnssiA Offline
            Anssi
            last edited by

            How about exploding and immediately creating a new component?

            Another way is to insert the DC in a new model, save it and import that. The DC attributes won't be usable until you explode the component once. Exploiting a common error with DCs.

            Anssi

            securi adversus homines, securi adversus deos rem difficillimam adsecuti sunt, ut illis ne voto quidem opus esset

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

              @jim said:

              I have a plugin that can "strip DC attributes", optionally delete sub-components which are hidden, and reset the scale mask. I wrote it for a business that uses DC's internally but wanted to protect their IP and reduce file size before making their models public. I have been meaning to get it posted.

              I'm very interested, could you send it to me in some way? πŸ˜ƒ

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

                @tig said:

                This one-liner copy+paste+<enter> in the Ruby Console will stop a selected DC from being dynamic

                Sketchup.active_model.selection[0].definition.attribute_dictionaries.delete('dynamic_attributes')
                

                use wisely... 😲

                Hm, yes it worked. But I want to keep the groups in the component. Now I get the same problem as when exploding the component as many times as possible and then making a new component.
                Thanks anyway πŸ˜ƒ

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

                  You asked to "kill dynamic components" - thats what his one line script does.

                  So what do you REALLY want to do?

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

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

                    @chris fullmer said:

                    You asked to "kill dynamic components" - thats what his one line script does.

                    So what do you REALLY want to do?

                    In my first post I wrote: "I want to keep the groups of the object that the dynamic component exists of, but clear all settings."

                    I just want the component attributes to be cleared. But I want to keep the groups in the component.

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

                      Sketchup.active_model.selection[0].definition.attribute_dictionaries.delete('dynamic_attributes')
                      

                      just stops the selected DC from being a DC!
                      If you have nested DC's within a DC you'll need to run the tool recursively like this

                      def dck(c);c.definition.attribute_dictionaries.delete('dynamic_attributes');c.entities.each{|e|dck(e)if e.class==Sketchup;;ComponentInstance};end;dck(Sketchup.active_model.selection[0])if e.class==Sketchup;;ComponentInstance
                      

                      where the method 'dck' is the 'dc_killer' applied to a selected component AND all of its nested DCs down to any depth... use with care

                      TIG

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

                        @jim said:

                        I have a plugin that can "strip DC attributes", optionally delete sub-components which are hidden, and reset the scale mask. I wrote it for a business that uses DC's internally but wanted to protect their IP and reduce file size before making their models public. I have been meaning to get it posted.

                        Hi, I know this was a while ago - but any chance I could snag the plugin you reference? Thanks.

                        s.

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

                          @tig said:

                          Sketchup.active_model.selection[0].definition.attribute_dictionaries.delete('dynamic_attributes')
                          

                          just stops the selected DC from being a DC!

                          If you have nested DC's within a DC you'll need to run the tool recursively like this

                          def dck(c);c.definition.attribute_dictionaries.delete('dynamic_attributes');c.entities.each{|e|dck(e)if e.class==Sketchup;;ComponentInstance};end;dck(Sketchup.active_model.selection[0])if e.class==Sketchup;;ComponentInstance
                          

                          where the method 'dck' is the 'dc_killer' applied to a selected component AND all of its nested DCs down to any depth... use with care

                          I tried pasting this into the ruby editor - but it didn't work 😞

                          "Error: #<NameError: undefined local variable or method `e' for main:Object>"

                          I'm in SU15. The single line top-level version did work....but I'm really trying to zap the tree.

                          s.

                          1 Reply Last reply Reply Quote 0
                          • halroachH Offline
                            halroach
                            last edited by

                            @skavan said:

                            I tried pasting this into the ruby editor - but it didn't work 😞

                            "Error: #<NameError: undefined local variable or method `e' for main:Object>"

                            I'm in SU15. The single line top-level version did work....but I'm really trying to zap the tree.

                            s.

                            I'm getting the same error. Ideas?

                            FlexTools - Super Quick Windows, Doors, Slats...

                            1 Reply Last reply Reply Quote 0
                            • sdmitchS Offline
                              sdmitch
                              last edited by

                              @halroach said:

                              @skavan said:

                              I tried pasting this into the ruby editor - but it didn't work 😞

                              "Error: #<NameError: undefined local variable or method `e' for main:Object>"

                              I'm in SU15. The single line top-level version did work....but I'm really trying to zap the tree.

                              s.

                              I'm getting the same error. Ideas?

                              Try

                              def dck(c);c.definition.attribute_dictionaries.delete('dynamic_attributes');c.definition.entities.each{|e|dck(e)if e.class==Sketchup;;ComponentInstance};end;dck(Sketchup.active_model.selection[0])
                              

                              after selecting the dynamic component.

                              Nothing is worthless, it can always be used as a bad example.

                              http://sdmitch.blogspot.com/

                              1 Reply Last reply Reply Quote 0
                              • O Offline
                                Oly80
                                last edited by

                                I'm not sure what other aspects of sketchup may be lost?...But saving as sketchup version 6 or below removes dynamic attributes, retaining the component and sub components.

                                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