[Plugin] ComponentReporter++ v1.2

[Plugin] ComponentReporter++ v1.2

Postby TIG » Thu Apr 09, 2009 5:10 pm

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...
3
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] ComponentReporter++ v1.1

Postby romuloigor » Thu Nov 03, 2011 1:03 am

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!
0
User avatar
romuloigor 
Premium Member
Premium Member
 

Re: [Plugin] ComponentReporter++ v1.1

Postby TIG » Thu Nov 03, 2011 10:16 am

romuloigor wrote: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... :geek:
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] ComponentReporter++ v1.1

Postby romuloigor » Fri Nov 04, 2011 12:14 am

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.

Code: Select all
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.]
0
User avatar
romuloigor 
Premium Member
Premium Member
 

Re: [Plugin] ComponentReporter++ v1.1

Postby TIG » Fri Nov 04, 2011 10:25 am

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...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] ComponentReporter++ v1.1

Postby TIG » Fri Nov 04, 2011 1:21 pm

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.
:geek:
1
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] ComponentReporter++ v1.1

Postby notekm » Tue Dec 20, 2011 4:59 pm

1.skp
Hi, 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
0

notekm 
 

Re: [Plugin] ComponentReporter++ v1.1

Postby TIG » Thu Dec 22, 2011 12:00 am

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.rb
To 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...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] ComponentReporter++ v1.1

Postby notekm » Thu Dec 22, 2011 2:00 pm

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

notekm 
 

Re: [Plugin] ComponentReporter++ v1.1

Postby TIG » Thu Dec 22, 2011 4:59 pm

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
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] ComponentReporter++ v1.1

Postby notekm » Thu Dec 22, 2011 5:19 pm

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
0

notekm 
 

Re: [Plugin] ComponentReporter++ v1.1

Postby TIG » Thu Dec 22, 2011 7:39 pm

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 ?
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] ComponentReporter++ v1.1

Postby notekm » Fri Dec 23, 2011 11:07 am

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)
1

notekm 
 

Re: [Plugin] ComponentReporter++ v1.1

Postby irwanwr » Fri Dec 23, 2011 11:46 am

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?
0
User avatar
irwanwr 
 

Re: [Plugin] ComponentReporter++ v1.1

Postby TIG » Fri Dec 23, 2011 12:21 pm

irwanwr wrote: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...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] ComponentReporter++ v1.1

Postby TIG » Fri Dec 23, 2011 12:38 pm

notekm wrote: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...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] ComponentReporter++ v1.1

Postby irwanwr » Sat Dec 24, 2011 4:26 am

thank you very much TIG.
for Extrusion Tool Set, i've learnt and succeed using the EEbyRail :D
it works great as if a wizard made it :P
thank you
0
User avatar
irwanwr 
 

Re: [Plugin] ComponentReporter. query re getting curve lengt

Postby unearthed » Mon Jan 23, 2012 12:34 am

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.
0
Growplan - People ∩ Plants ∩ Place

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

unearthed 
 

Re: [Plugin] ComponentReporter++ v1.1

Postby TIG » Mon Jan 23, 2012 12:41 am

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...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] ComponentReporter++ v1.1

Postby unearthed » Mon Jan 23, 2012 1:29 am

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?
0
Growplan - People ∩ Plants ∩ Place

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

unearthed 
 

Re: [Plugin] ComponentReporter++ v1.1

Postby TIG » Mon Jan 23, 2012 12:03 pm

IF you want to use the nested component containing the linear info then you can readily add extra code into another column in the CSV. OR make a separate CSV report on linear info.
Here's how to do it separately.
The tool runs***, its code finds all components in the model with instances having a name containing 'hedge' and thereby their nested component giving the linear info drawn as a line or curve.
It takes all edges in this nested component and totals their length.
It writes a CSV listing the instance-name [e.g. 'c.hedge'], instance's-layer, definition-name, linear total [in meters]
Sorted in order, with a header line and a total of the minear-meterage.
Copy/paste this whole set of code into a new file [Notepad.exe] that you make in the Plugins folder named 'TIG-hedgelengths.rb'
Code: Select all
require 'sketchup.rb'
module TIG
 ###
 unless file_loaded?(File.basename(__FILE__))
   UI.menu("Plugins").add_item("Hedges Length CSV"){self.hedgelengths()}
 end
 file_loaded(File.basename(__FILE__))
 ###
 def self.hedgelengths()
  model=Sketchup.active_model
  if model.path.empty?
    dir=Dir.pwd
   tit="Untitled"
  else
    dir=File.dirname(model.path)
   tit=model.title
  end
  ###
  rows=[]
  model.definitions.each{|d|
    next if d.group? or d.image?
   d.instances.each{|i|
     txt=""
     if i.name=~/[Hh]edge/
      txt << i.name+","
      txt << i.layer.name+","
      txt << d.name+","
      lin=0
      d.entities.each{|c|
        if c.class==Sketchup::ComponentInstance
          c.definition.entities.each{|e|
           if e.class==Sketchup::Edge
             lin+=e.length
           end
         }
        end
      }
      txt << sprintf("%.3f", lin.to_m) ### 3d.p.
     end
     rows << txt
   }
  }
  rows.dup.each{|e| rows.delete(e) if e.empty? }
  rows.sort!
  ## add total
  rows=["INST-NAME,INST-LAYER,DEFN,LIN.METERS"]+rows
  tot=rows.length.to_s
  rows << "\n,,TOTAL,=SUM(D2:D#{tot})"
  ###
  csv=File.join(dir, tit+"_HedgesLength.csv").tr("\\","/")
  ###
  begin
     file=File.open(csv,"w")
  rescue### trap if open
     UI.messagebox("Report:\n\n  "+csv+"\n\nCannot be written - it's probably already open.\nClose it and try making the Report again...\n\nExiting...")
    return nil
  end
  ###
  rows.each{|row| file.puts(row) }
  file.close
  ###
  UI.messagebox("Report:\n"+csv+"\nWritten.")
  UI.openURL("file:///"+csv)
  ###
 end
end
***Usage: either type TIG.hedgelengths in the Ruby Console... OR more easily use the Plugins menu item...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] ComponentReporter++ v1.1

Postby unearthed » Mon Jan 23, 2012 10:49 pm

Thanks TIG, that's simply amazing :sketchstatic: Elegant and simple.

Now thanks to your plugins I've got the basis for a complete plant counter (areas, individual plants and hedges and shelterbelts - Sketchup has just become a LOT more useful), thanks again.
0
Growplan - People ∩ Plants ∩ Place

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

unearthed 
 

Re: [Plugin] ComponentReporter++ v1.1

Postby samyell77 » Wed Feb 29, 2012 6:15 pm

Hi Tig,
Great plugin - thanks. Ive used this on several jobs now and wonder if you can help me to make a few tweaks. I've been trying to use this to count components in a selection. I know that the plugin exports 3 csv documents and was wondering if you can help me to tailor the script to get the count Im after - Im afraid Im a total noob to Ruby but am more than happy to have a play with it if you can offer a little advice.

Id like to be able to generate a count for either a whole model or for a selection within the model. I know that the script already generates a count for a selection but I'd like to be able to summarize items with the same name -giving me a total number.

I also wonder if its possible to only display the component name and the count and none of the other information (guid, description, material etc). Im trying to reduce the amount of work I need to do to tidy up the csv files that are generated.

Ive been playing with this whenever I get some spare time but would love a little advice.

Any help much appreciated.

Thanks

Sam
0
SU Pro 2016
Dell Precision M4800
PC Windows 10
Intel Core i7-4900MQ @ 2.80ghz
Nvidia Quadro K2100M
16gb RAM

samyell77 
 

Re: [Plugin] ComponentReporter++ v1.2

Postby TIG » Mon Oct 08, 2012 1:19 pm

Here's v1.2 made MAC compatible... viewtopic.php?p=147658#p147658
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] ComponentReporter++ v1.2

Postby sidpickle » Mon Oct 22, 2012 5:55 pm

Thanks TIG seems to work OK. I'll have a play with it.

Ted Robbens
0

sidpickle 
 

Re: [Plugin] ComponentReporter++ v1.2

Postby quarch » Sun Jan 06, 2013 3:04 pm

Unfortunately I am having errors in counts for nested components...
example...
3 component 1 in model
1 component 2 inside component 1...

Report returns 3 counts of 1 and 1 count of 2 in stead of 3 counts of 1 and 3 counts of 2

Counts in instances report are correct.
0

quarch 
 

Re: [Plugin] ComponentReporter++ v1.2

Postby TIG » Sun Jan 06, 2013 7:53 pm

quarch wrote:Unfortunately I am having errors in counts for nested components...
example...
3 component 1 in model
1 component 2 inside component 1...
Report returns 3 counts of 1 and 1 count of 2 in stead of 3 counts of 1 and 3 counts of 2
Counts in instances report are correct.
There ARE 3 instances of compo1.
There IS 1 instance of compo2.
You might 'see' 3 of compo2, but these are actually three representations on the same object.
The different reporting formats are a way of covering various bases...

If you want it to somehow report things differently, then rework the code as you wish...
It is 'open source' after all... :roll:
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] ComponentReporter++ v1.2

Postby Omarian » Thu Apr 04, 2013 8:53 am

TIG,

This is similar to a problem I am having. I want to call up the running length of walls at base (where Y axis would be zero, and which would exclude door openings)or ceiling (which would give total lengths for molding etc). Is it possible to convert the above reporting script into a DCfunction in much the same way as you had created the DCvolume function? You may need specific functions that would take only the sum of lengths of the edges of the outer or inner faces of the wall at the base(ie excluding doors) and at the ceiling (which would include door openings).
0

Omarian 
 

Re: [Plugin] ComponentReporter++ v1.2

Postby TIG » Thu Apr 04, 2013 10:34 am

It wouldn't be so easy...

BUT you can write any custom function you like to add to a DC...

So let's say you want the perimeter of all faces that have a normal==Z_AXIS.reverse [facing down - i,e, the bottom of a ceiling slab] inside a DC you do something like:
Code: Select all
require('sketchup')
require('dynamiccomponents.rb')
if defined?($dc_observers)
  # Open Dynamic Component Functions (V1) class, only if DC extension is active
class DCFunctionsV1
 protected
 # return the perimeter (in inches) of face.normal==Z_AXIS.reverse
 if not DCFunctionsV1.method_defined?(:perimeter)
  def perimeter(a) # Usage as DC function: =perimeter()
   se = @source_entity
   if se.is_a?(Sketchup::Group)
      allfaces = se.entities.grep(Sketchup::Face)
   else #component-instance
      allfaces = se.definition.entities.grep(Sketchup::Face)
   end
   faces=[]
   allfaces.each{|face| faces << face if face.normal==Z_AXIS.reverse }
   tr = se.transformation
   xs = tr.xscale #***
   ys = tr.yscale #***
   peri = 0.0
   faces.each{|face|
      tlen = 0.0
      face.outer_loop.edges.each{|e|
         elen = e.length # this is an unscaled length
         slen = elen*(1) #*** adjust for any X/Y scaling in (1) if needed ?
         tlen += slen
      }
      peri += tlen
   }
    return peri
  end
 end
end#class
end#if
This takes no notice of any scaling applied to the DC object, reporting the original perimeter...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] ComponentReporter++ v1.2

Postby Omarian » Fri Apr 05, 2013 2:31 am

Thanks a million, it worked like a charm.
0

Omarian 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Next


 

Return to Plugins

Who is online

Users browsing this forum: Carto, Google Bot and 13 guests

Visit our sponsors: