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

    Create a text file from the components list

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    12 Posts 4 Posters 536 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.
    • G Offline
      glro
      last edited by

      would it be possible to write a plugin that would produce automatically a text file, in the current folder, listing the components list, as it appears when you do
      windows>model info>statistics>components (developp hierarchy)
      ?

      1 Reply Last reply Reply Quote 0
      • D Offline
        dedmin
        last edited by

        http://rhin.crai.archi.fr/rubylibrarydepot/plugin_details.php?id=198

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

          @glro said:

          would it be possible to write a plugin that would produce automatically a text file, in the current folder, listing the components list, as it appears when you do
          windows>model info>statistics>components (develop hierarchy)
          ?

          The 'Component List' part of Model Info > Statistics is only 'Component Definitions' and 'Component Instances' each returning an integer.
          This hardly seems worth exporting to a text file ?
          Do you want more like a list of Definitions by name and a count of their instances ?
          My 'ComponentReporter++.rb' does this and a lot more...
          The following simple code mimics the part you actually 'asked' for

          model=Sketchup.active_model
          defs=0
          insts=0
          model.definitions.each{|d|defs+=1; insts=insts+d.instances.length}
          path=model.path
          path=Dir.pwd if not path ### in case not saved
          report=File.join(path,"report.txt")
          ### or whatever name you want e.g. report.csv
          file=File.new(report, "w")
            file.puts("Component Definitions, " + defs.to_s)
            file.puts("Component Instances, " + insts.to_s)
          file.close
          
          

          TIG

          1 Reply Last reply Reply Quote 0
          • G Offline
            glro
            last edited by

            @dedmin said:

            http://rhin.crai.archi.fr/rubylibrarydepot/plugin_details.php?id=198

            the text written by this plugin shows one line for each instance of a component

            it doesn't make the total for each component

            1 Reply Last reply Reply Quote 0
            • G Offline
              glro
              last edited by

              simple things are not as easy as they seem, sometimes.

              i tried 'ComponentReporter++.rb'; it does a lot of things; the component-report.csv would be the closest result to what i am looking for; but there is a problem with nested components

              if COMP1 is nested once in COMP2, and there are 6 instances of COMP2, for example, COMP2 will be counted 6 times in the list, but COMP1 will be counted only once...

              on the countrary, in the list you get in sketchup from
              windows>model info> statistics>components
              COMP2 AND COMP 1 are both counted 6
              and this is what i would like to be in the text file too

              i tried to copy paste the code you wrote in a ruby console, but it doesn't work... i am sorry for being so ignorant... what would be the way to test the code you wrote?

              1 Reply Last reply Reply Quote 0
              • D Offline
                dedmin
                last edited by

                Welcome to component's hell 💚 I have been struggling with this a lot and finally started using components only at the top level hierarchy - everything down are groups 😆

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

                  @glro said:

                  would it be possible to write a plugin that would produce automatically a text file, in the current folder, listing the components list, as it appears when you do
                  windows>model info>statistics>components (developp hierarchy)
                  ?

                  You can select and copy the report from the statistics window to an empty text file or an Excel sheet. No need for a plugin

                  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
                  • G Offline
                    glro
                    last edited by

                    @dedmin said:

                    Welcome to component's hell 💚 I have been struggling with this a lot and finally started using components only at the top level hierarchy - everything down are groups 😆

                    yes, but you cannot list groups, can you?... and the purpose is to get a list; so i have to use only components

                    1 Reply Last reply Reply Quote 0
                    • G Offline
                      glro
                      last edited by

                      @anssi said:

                      @glro said:

                      would it be possible to write a plugin that would produce automatically a text file, in the current folder, listing the components list, as it appears when you do
                      windows>model info>statistics>components (developp hierarchy)
                      ?

                      You can select and copy the report from the statistics window to an empty text file or an Excel sheet. No need for a plugin

                      Anssi

                      yes, i could do that; but he idea is to use the text file as an input for a further operation; and the less clicks, the better...

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

                        @glro said:

                        @dedmin said:

                        http://rhin.crai.archi.fr/rubylibrarydepot/plugin_details.php?id=198

                        the text written by this plugin shows one line for each instance of a component

                        it doesn't make the total for each component

                        You never asked for that 😒

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • G Offline
                          glro
                          last edited by

                          @tig said:

                          @glro said:

                          @dedmin said:

                          http://rhin.crai.archi.fr/rubylibrarydepot/plugin_details.php?id=198

                          the text written by this plugin shows one line for each instance of a component

                          it doesn't make the total for each component

                          You never asked for that 😒

                          right; i have been on this problem for such a long time that i forgot to mention it; anyway, your plugin does make the right total in one text file; except for the nested components.
                          And in another text file, you establish the relation between the nested component and the nesting component

                          So it would be possible to multiply the right numbers between them...

                          1 Reply Last reply Reply Quote 0
                          • G Offline
                            glro
                            last edited by

                            @tig said:

                            @glro said:

                            @dedmin said:

                            http://rhin.crai.archi.fr/rubylibrarydepot/plugin_details.php?id=198

                            the text written by this plugin shows one line for each instance of a component

                            it doesn't make the total for each component

                            You never asked for that 😒

                            your plugin "ComponentReporter++.rb" produces 3 text files:
                            *_CR-Component+Report.csv
                            *_CR-Instances+Report.csv
                            *_CR-Parentage+Report.csv

                            With the included example:

                            "essai_CR-Component+Report.csv":

                            DEFN-NAME,COUNT,DESCRIPTION,GUID
                            Composant#1,1,,29b53a7c-2e6c-40b9-9f78-41e4abc0a62f
                            Composant#2,1,,2306d93d-9156-46c9-bf4a-5a4e8a2f5e38
                            Composant#3,4,,c969203b-e788-468f-b495-5936ea9bdd48

                            As you can see, Composant#1 and Composant#2 are counted once only, when in reality, they appear 4 times in the model; the problem comes from the fact they are nested within Composant#3

                            If Composant#3 instances are exploded, Composant#1 and Composant#2 are counted 4 times, and it is what i am looking for.

                            But would be possible to get this result without exploding anything, using the information in your file "essai_CR-Parentage+Report.csv":
                            'essai_CR'<Model>,''Composant#3<Instance>,
                            'essai_CR'<Model>,''Composant#3<Instance>,
                            'essai_CR'<Model>,''Composant#3<Instance>,
                            'essai_CR'<Model>,''Composant#3<Instance>,
                            'essai_CR'<Model>,'Composant#3'<Definition>,''Composant#1<Instance>,
                            'essai_CR'<Model>,'Composant#3'<Definition>,''Composant#1<Instance>,
                            'essai_CR'<Model>,'Composant#3'<Definition>,''Composant#1<Instance>,
                            'essai_CR'<Model>,'Composant#3'<Definition>,''Composant#1<Instance>,
                            'essai_CR'<Model>,'Composant#3'<Definition>,''Composant#2<Instance>,
                            'essai_CR'<Model>,'Composant#3'<Definition>,''Composant#2<Instance>,
                            'essai_CR'<Model>,'Composant#3'<Definition>,''Composant#2<Instance>,
                            'essai_CR'<Model>,'Composant#3'<Definition>,''Composant#2<Instance>,

                            By counting the last definition instance of each line, and produce the result in a file like "essai_CR-Component+Report.csv"?

                            This is what sketchup does in the statistics windows, when you ask to developp for the component hierarchy, and it was my first question...


                            nested components example

                            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