Create a text file from the components list
-
-
@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' formodel=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
-
@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
-
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 tooi 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?
-
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
-
@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
-
@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
-
@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...
-
@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 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 componentSo it would be possible to multiply the right numbers between them...
-
@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.csvWith 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-5936ea9bdd48As 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...
Advertisement