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

[Plugin] ComponentReporter++ v1.2

Scheduled Pinned Locked Moved Plugins
71 Posts 22 Posters 62.5k Views
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
    TIG Moderator
    last edited by 9 Apr 2009, 16:10

    Here's v1.1 of ComponentReporter++.rb.

    It does report names, count of instances, nested instances/groups and areas of materials etc...
    Now made MAC compatible...

    Try it - it is readily adaptable to your needs...PayPalButton


    ComponentReporter++.rb

    TIG

    1 Reply Last reply Reply Quote 0
    • R Offline
      romuloigor
      last edited by 3 Nov 2011, 00:03

      TIG, how could that do to ComponentReporter + + v1.1, export LenX, LenY and LenZ of a component, and the information if the Layer is visible or invisible?

      I await your help!

      1 Reply Last reply Reply Quote 0
      • T Offline
        TIG Moderator
        last edited by 3 Nov 2011, 09:16

        @romuloigor said:

        TIG, how could that do to ComponentReporter + + v1.1, export LenX, LenY and LenZ of a component, and the information if the Layer is visible or invisible?

        I await your help!

        This is relatively simple, compared to the full reporter, which is really only a demonstration of what you might do to suit yourself.
        Do you want it to report all components [instances] or just selected ones [I presume 'all' because if the layer is invisible you couldn't select them!]?
        The LenX, LenY and LenZ values are specific to dynamic-components... is this what you mean of the X/Y/Z dimensions of the instances bounding box ?
        It's easy enough get an instance.layer and report it's name and it's 'state' on/off...
        Once you confirm these items I can continue helping you... 🤓

        TIG

        1 Reply Last reply Reply Quote 0
        • R Offline
          romuloigor
          last edited by 3 Nov 2011, 23:14

          TIG,
          The "full report" is generated by the menu File > Generate Report > CSV file ? ( Only SU 8 PRO ).
          [ How could I generate this report by ruby ?, And saving automatically in my custon directory, silently.]
          if you can not do the "full reporter", I use your ComponentReporter++v1.1, but the need for this option to export values ​​LenX, LenY and LenZ of dynamic component.
          [ Create a Dynamic Component and Call ComponentReporter++v1.1 and view output is not LenX, LenY and LenZ ... ]

             [ Layer ] - My dynamic component has 10 layers and a select in listbox in component options the Dynamic Component user will select a layer and all objects when exporting the model will be in csv file
          

          ( I do not use the option to export only selected ) always full export.

          
          inlist.each{|c|
          dname="'"+c.definition.name ... 
          LenX=c.lenx.to_s ???
          LenY=c.leny.to_s ???
          LenZ=c.lenz.to_s ???
          if c.layer
             layer="'"+c.layer
          end
          
          

          OK?

          [I can not speak english and do not know ruby, I speak portuguese and I know python.]

          1 Reply Last reply Reply Quote 0
          • T Offline
            TIG Moderator
            last edited by 4 Nov 2011, 09:25

            So to recap...
            You want to export a CSV file of ALL Dynamic Component instances [by name ?], listing their LenX, LenY and LenZ [in what units ?], plus up to 10 Layers [by name ?] showing if they are 'on'/'off'. If it's to be saved 'silently' how will the file be 'located/named' ? Perhaps in the Model's folder with its name e.g. MyModel.skp >>> MyModelDCs.csv ???

            For example:

            MyDC#1,5.678.9.012,3.456,>>Layer1<<,Layer2,Layer3,Layer4,Layer5,Layer6,Layer7,Layer8,Layer9,Layer10
            MyDC#2,1.234,5.678.9.000,Layer1,>>Layer2<<,Layer3,Layer4,Layer5,Layer6,Layer7,Layer8,Layer9,Layer10

            Where Layer1 and Layer2 are 'on' while the rest are 'off' in their respective MyDC's...

            TIG

            1 Reply Last reply Reply Quote 0
            • T Offline
              TIG Moderator
              last edited by 4 Nov 2011, 12:21

              Here's a version that might do what you want or be adapted easily...TIG-exportDCs2csv.rb(c) TIG 2011
              Script:
              TIG-exportDCs2csv.rb
              Type:
              TIG.exportDCs2csv
              in the Ruby Console to run it.
              Exports all DCs is the model with a Name,LenX,LenY,LenZ,Layer[s]...
              'CSV' file - in the model's folder and named after the model thus:
              ModelName.skp >>> ModelNameDCs.csv
              If a new model is unsaved the current directory receives the new file.
              All Layers used in the DC are listed by name and visible ones marked
              thus >>LayerName<<
              Edit sep="," if something other than separating comma is desired e.g. ';'
              Make sep="\t" if a TSV file is desired and change ext="csv" to ext="tsv".
              It uses the current Model Units.
              Version:
              1.0 20111104 First issue.
              🤓

              TIG

              1 Reply Last reply Reply Quote 0
              • N Offline
                notekm
                last edited by 20 Dec 2011, 15:59

                my dcHi, in my dynamic component is a custom attribute "DSP",how and where it is necessary to register the plugin, so it will write out me to required attributes?Sorry for the quality of language

                1 Reply Last reply Reply Quote 0
                • T Offline
                  TIG Moderator
                  last edited by 21 Dec 2011, 23:00

                  Notekm

                  Here's a modified version of the draft .rb file, which now adds 'dsp' and 'kromka' as additional reported attributes in the CSV. [which I guess are 'Chipboard' and 'Edging'/'Lipping' thicknesses ?]
                  To get ANY DC attribute you can use its key's name, as you have typed it in the 'Custom' attribute section of the dialog, BUT all in lowercase letters - i.e. 'dsp' NOT 'DSP'...TIG-exportDCs2csv.rbTo find a specific DC's attribute keys/values you can select it in the SKP, then paste this line of code into the Ruby Console +<enter>:
                  Sketchup.active_model.selection[0].attribute_dictionaries["dynamic_attributes"].each_pair{|k,v|puts k+"="+v.to_s}
                  This will give an output list something like this:
                  _has_movetool_behaviors=0.0 _hasbehaviors=1.0 dsp=0.216 kromka=1.32 lenx=0.6299212598425197 leny=11.811023622047244 lenz=28.34645669291339
                  Note that the attributes starting with '_' are added by the system and you can't/shouldn't normally need or edit these.
                  The others attributes represent what you have added as keys/values in the dialog - e.g. 'dsp' and 0.216... etc...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • N Offline
                    notekm
                    last edited by 22 Dec 2011, 13:00

                    it works, and how to make a that would show the sum of attribute values ​​on the right key

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      TIG Moderator
                      last edited by 22 Dec 2011, 15:59

                      You can simply open it is Excel and sum the Column ?
                      However currently the units have 'mm' etc so you'd need to change those...
                      I've recast it to miss those off.
                      To =SUM a column you can add a final line of formulae...
                      See what I've done to the code... I actually summed ALL 'number columns' BUT you will probably want to sum just some...TIG-exportDCs2csv.rb

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • N Offline
                        notekm
                        last edited by 22 Dec 2011, 16:19

                        TIG.exportDCs2csv
                        Error: #<ArgumentError: C:/PROGRA~1/Google/GOOGLE~1/Plugins/TIG-exportDCs2csv.rb:50:in to_l': Cannot convert "0.6299212598425197" to Length> C:/PROGRA~1/Google/GOOGLE~1/Plugins/TIG-exportDCs2csv.rb:50 C:/PROGRA~1/Google/GOOGLE~1/Plugins/TIG-exportDCs2csv.rb:50:in exportDCs2csv'
                        C:/PROGRA~1/Google/GOOGLE~1/Plugins/TIG-exportDCs2csv.rb:47:in each' C:/PROGRA~1/Google/GOOGLE~1/Plugins/TIG-exportDCs2csv.rb:47:in exportDCs2csv'
                        (eval):50

                        1 Reply Last reply Reply Quote 0
                        • T Offline
                          TIG Moderator
                          last edited by 22 Dec 2011, 18:39

                          I have NOT changed the way the ...lenx.to_l etc works in line#50 - I added some code after that to remove 'mm' and '~' but nothing else; it's failing on the .to_l ?
                          Are you muddling ',' and '.' as decimal separators perhaps ?
                          If you copy/paste this into the Ruby Console it works too:
                          "0.6299212598425197".to_l
                          Works for me on your sample SKP.
                          Have you changed the DCs in your test SKP ?

                          TIG

                          1 Reply Last reply Reply Quote 0
                          • N Offline
                            notekm
                            last edited by 23 Dec 2011, 10:07

                            hi, I did not change, I just copied a component in the scene.
                            this task.
                            1.Select all the components in the scene
                            2. select the components of a key (such as "DSP")
                            2a. (can take the key values ​​from a separate file?)
                            3. display or save the file in the list of components (screen of what I would like to see)


                            screen of what I would like to see


                            Scene

                            1 Reply Last reply Reply Quote 0
                            • irwanwrI Offline
                              irwanwr
                              last edited by 23 Dec 2011, 10:46

                              so many versions in one page? is this free and not to difficult to learn for beginners?
                              if i may ask. which one is good for beginners to download, please?

                              1 Reply Last reply Reply Quote 0
                              • T Offline
                                TIG Moderator
                                last edited by 23 Dec 2011, 11:21

                                @irwanwr said:

                                so many versions in one page? is this free and not to difficult to learn for beginners?
                                if i may ask. which one is good for beginners to download, please?

                                Get the first one [at start] - the others are to show how to make a simple DC attribute reader/reporter...

                                TIG

                                1 Reply Last reply Reply Quote 0
                                • T Offline
                                  TIG Moderator
                                  last edited by 23 Dec 2011, 11:38

                                  @notekm said:

                                  hi, I did not change, I just copied a component in the scene.
                                  this task.
                                  1.Select all the components in the scene
                                  2. select the components of a key (such as "DSP")
                                  2a. (can take the key values ​​from a separate file?)
                                  3. display or save the file in the list of components (screen of what I would like to see)

                                  The XY [in mm] need to come from the two largest values of the 'panel' - because sometimes the Z is NOT the minimum [=thickness]. OR you could report all three XYZ and you then simply ignore the smallest one [thickness] ??
                                  Counting the number of a a specific DC and reporting it is possible:
                                  number = instance.definition.instances.length.
                                  I now see that the 'DSP' is the area [in m2] of 'chipboard' used in that panel.
                                  I'm not sure what the 'Kromka' is - probably linear 'm' of edging ?
                                  You need to adjust the way the values of these 2 are handled - so NO .to_l step since that turns the value [assumed to be in inches] into a length in current units [mm] - perhaps leave them as the float that they are, made into a string [.to_s] ?
                                  Totaling up specific columns is demonstrated in the example code I've given you - adjust it to sum just those you want.
                                  The CSV format can be linked [or save_as] into a XLS file where you format it as you like...

                                  TIG

                                  1 Reply Last reply Reply Quote 0
                                  • irwanwrI Offline
                                    irwanwr
                                    last edited by 24 Dec 2011, 03:26

                                    thank you very much TIG.
                                    for Extrusion Tool Set, i've learnt and succeed using the EEbyRail 😄
                                    it works great as if a wizard made it 😛
                                    thank you

                                    1 Reply Last reply Reply Quote 0
                                    • U Offline
                                      unearthed
                                      last edited by 22 Jan 2012, 23:34

                                      Hi TIG, thanks for the great plugin, now I can count my plants easily and sum plant areas easily.

                                      But would it be possible to add the ability to get length of curves (arcs and splines) and lines from components?

                                      Often I have many hedges in my designs, and if I could get their length, I could send this out with the report to Excel and then divide hedge length by plants per metre. I accept I will probably have to have a curve length for the hedge in a separate component but that's fine, although maybe it could just be as a nested instance.

                                      Growplan - People ∩ Plants ∩ Place

                                      windows 7 64b, 4GB RAM, SU 8.0.16846
                                      Gimp, QGIS, Vectorworks 12, Bricscad 11

                                      1 Reply Last reply Reply Quote 0
                                      • T Offline
                                        TIG Moderator
                                        last edited by 22 Jan 2012, 23:41

                                        This tool was really written as a demonstration of how you can extract information from the model into CSV files etc.
                                        As you probably already know selected lines/curves report their total length in the Entity Info dialog.
                                        It's easy enough to sum the lengths of edges and report it out.
                                        If you give a 'little more flesh to your bones' I can perhaps guide you on how to do this...

                                        TIG

                                        1 Reply Last reply Reply Quote 0
                                        • U Offline
                                          unearthed
                                          last edited by 23 Jan 2012, 00:29

                                          Well here's a very typical hedge arrangement, although 100's of metres in many pieces is also quite common.

                                          I've also put the hedge centrelines as a nested component within each component, although if there's a way of avoiding that I'm all ears.
                                          Would it be easier to export the values of dimensions to the .csv?


                                          hedge.lengths.skp

                                          Growplan - People ∩ Plants ∩ Place

                                          windows 7 64b, 4GB RAM, SU 8.0.16846
                                          Gimp, QGIS, Vectorworks 12, Bricscad 11

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

                                          Advertisement