Attributes - Export / Create More / Linking with Database ?
-
@unknownuser said:
TIG,
V 1.1 really is excellent.
It's extremely useful being able to run this script on a selection from a model.
I think many people will find this script useful
For an example see:
http://www.sketchucation.com/scf/viewtopic.php?f=22&t=3429
(your script could now be in Siberia !!!)
...
Currently I'm running the script on a model containing many components.
Originally some of these components were contained within other components (nested) others were grouped together.
...
I found that the script does not drill down into nested components or grouped components.
Not a huge problem as a workaround is to explode the larger components and groups.***
However, would it ever be possible to have the script drill down into more complex (nested) components and groups to get at the buried ones ???
...
Thanks once again for all your help
Regards
Howard LeslieThe script first reports ALL component definitions and how many times they are placed/used, of course this might include components nested inside other components etc. It then makes a report of all placed Instances that are accessible directly within the model. An alternative is to select a collection of objects containing some instances and it'll offer the option of reporting just on those.
***No need to explode anything... IF you have component instances inside groups or within other components then you can simply edit that group/component and select all - you then run the script and will get the chance to make a report of just the instances in that selection.
It COULD mine down into all component instances definition or groups and report on the internal bits... but you have to stop somewhere. Simply clicking the group/component to edit and Ctrl+A to select all before running it will give you a list of what instances are there...
I have previously made 'group_miner.rb' that does just that iterative delving into nested things BUT unless there's a massive clamour for it I won't be adjusting this script immediately...
-
I decided that adding the 'mining' ability wasn't too hard... so here's v1.2
http://www.sketchucation.com/forums/scf/viewtopic.php?p=6685#p6685
You now get the chance to 'mine' down through nested-groups/components to get a report on all instances found - either 'all' or in an initial selection.
-
I am getting an error message. There is a conflict with RpTools.
@unknownuser said:
C:/Program Files/Render Plus Systems/RpTools/test-Component+Report.csv NOT available for writing (it might be open) !
Exiting...RpTools puts a menu item called Model Report in the Tools menu. It offers the option to create a text or Excel file. The file is saved in the program file. The file it creates is called test_report.txt (or csv).
This error message occurs whether or not I used Model Report to create a file.
-
TIG,
Thanks for putting this mining ability into the Reporting Tool.
However, I'm also getting a similar error message to the one described by gata
(see attached)
...
Regards
Howard L' -
@unknownuser said:
TIG,
Thanks for putting this mining ability into the Reporting Tool.
However, I'm also getting a similar error message to the one described by gata
(see attached)
...
Regards
Howard L'Well at least you are getting that error !!! - I've been trying to get it for some time - without success ! It's not a clash with other scripts (I think) - where was the 'test' skp saved ?
I added an extra bit in when I made the 'miner' that tries to check if the report file is open before you start to write to it. For example you make a report and open it, you leave it open and try to make a second report - this time it can't write to the file since you already have it open in another program. It fails dumping errors into the Ruby Console. I've tried to trap this in an error message - with little success.
Here's v1.3 that has that part disabled till I get it going better. Meanwhile it works as advertised. IF it doesn't end with the closing message saying what it's written where then chances are it's failing because the older report is still open and you forgot to close it...
http://www.sketchucation.com/forums/scf/viewtopic.php?p=6686#p6686
-
I'm getting your files now - in C:\Program Files\Render Plus Systems\RpTools
RpTools reports go to the same directory. Their files are named test_report.txt (and csv).
No error messages appear in the Ruby console.
I did not get a closing saying the files were written - even the first time I successfully tried it here. I had opened the files in Excel to see how they look (had to move over the column a bit) then closed Excel.
I ran your script a second time and still did not get the closing message. The only message I get is one saying it will save the files to the RpTools directory.
XP Pro, SP2.
-
@gata said:
I'm getting your files now - in C:\Program Files\Render Plus Systems\RpTools
RpTools reports go to the same directory. Their files are named test_report.txt (and csv).
No error messages appear in the Ruby console.
I did not get a closing saying the files were written - even the first time I successfully tried it here. I had opened the files in Excel to see how they look (had to move over the column a bit) then closed Excel.
I ran your script a second time and still did not get the closing message. The only message I get is one saying it will save the files to the RpTools directory.
XP Pro, SP2.
The older/simpler ComponentReporter.rb made a csv [comma] and a txt [tab] file, BUT that went into the model's folder and were named as the ModelName-ComponentReport.XXX
The new version only makes the csv file and has a '+' sign after Component in the file name. Clearly what you are running isn't my script. I don't have the RpTools so I don't know what they do. If there is 'Class' clash it might cause my menu item to run something in their script...
To test this make a backup copy of my ComponentReporter+.rb script, open the original in Notepad [or another plain text editor BUT NOT a word-processor !]. Find and replace Reporter (which is the Class) with say ReporterPlus for every instance thus:
...
class Reporter >>> class ReporterPlus
...
def Reporter::components_plus >>> def ReporterPlus::components_plus
...
def Reporter::miner(ents) >>> def ReporterPlus::miner(ents)
...
xlist=Reporter.miner(elist) >>> xlist=ReporterPlus.miner(elist)
...
full_list=Reporter.miner(all_list) >>> full_list=ReporterPlus.miner(all_list)
...
UI.menu("Plugins").add_item("Component+ Report"){Reporter.components_plus} >>> UI.menu("Plugins").add_item("Component+ Report [TIG]"){ReporterPlus.components_plus}
...
Note when you scroll to near the end and find the menu string - you should add something onto the text like [TIG]. Save the file and re-run.
You should now get an item in the Plugins menu with the [TIG] in itthat runs my script alone... -
TIG, I made all your edits and still get your csv files in RpTools directory.
I used to have the old ComponentReporter.rb, but renamed it with TXT then removed it from the Plugin directory altogether.
And I forgot, RpTools Model Report does produce an announcement message after its file is created whereas your plugin only announces where the file will go.
-
TIG / Jim,
Thanks very much for all your hard work and time spent on writing these scripts.
They are both very useful
...
TIG,
ComponentReporter+V 1.1
I'm finding that this runs no problem. (but no mining ability).V 1.2
I'm not sure what the V1.2 error message refers to either, as I did not have any existing *.csv file open when I ran the script - that was actually the first thing I checked.
...
V 1.3
I'm finding that this runs OK. NO error messages.
I'm finding that it mines down into the Model - 1 Level of nesting.
...
The ultimate version of this script would mine down to drag out all components from the whole model - however deep they are nested inside groups / other components. Is this possible ??? - it would be brilliant if you could implement this.
...
I'm using the V 1.1 of the script until then as the model I'm working on has been exploded down somewhat and the script runs really well.
...
Thanks once again to both of you.
Regards
Howard Leslie -
@gata said:
TIG, I made all your edits and still get your csv files in RpTools directory.
I used to have the old ComponentReporter.rb, but renamed it with TXT then removed it from the Plugin directory altogether.
And I forgot, RpTools Model Report does produce an announcement message after its file is created whereas your plugin only announces where the file will go.
Seems like RpTools is screwing up the model's folder-path which is what my script uses so as to know where to save the model's reports. It's clear from you screen-shot that your model 'gata' isn't in the RpTools reports folder.
Please copy and paste the following into the Ruby Console and publish what is given.
First:
Sketchup.active_model.title
This should given the model name without the .skp extension - e.g. 'gata'Second:
mpath=Dir::pwd
This is your working directory, and should normally be the model's folder - I suspect that RpTools is changing this to suit itself.Third:
Sketchup.active_model.path
Check that RpTools doesn't mess with this...
This is the model's folder - I will change my script to use this by default. -
Rptools does a Dir.chdir before loading a Ruby Extension DLL. (This causes the DLL to search for other DLL's is uses in its own path.)
It should have changed the folder back after loading the DLL, but somehow the line:
Dir.chdir(scur_folder)
got lost.
I will put it back for future versions of RpTools.
However, there may be other Ruby scripts, or other activities which change the current folder. So it might be a good idea to have ComponentReporter.rb specify a specific folder to save the file into.
- You could grab a copy of the current directory when ComponentReporter.rb first loads with: (ComponentsReporter.rb will load before RpTools_loader.rb because it comes first alphabetically)
$srpc_cur_folder = Dir.getwd
and then reset the folder before saving the file with
Dir.chdir($srpc_cur_folder)
or add the folder name to the .CSV file name before saving it.
- You should be able to get the Windows My Documents folder with code along the lines of:
require "Win32API" # you would have to put Win32API into the SketchUp Tools folder SHGetSpecialFolderPath = Win32API.new('shell32', 'SHGetSpecialFolderPath', 'LPLL','L') my_docs_folder = " "*512 # build buffer for file name CSIDL_MYDOCUMENTS = 0x000c SHGetSpecialFolderPath.call(0, my_docs_folder, CSIDL_MYDOCUMENTS, 0)
But I wasn't quite able to get this to work. I wound up writing a ruby DLL to fetch the path of the current folder.
-
Ruby console results.
This file contains my kitty and other creatures. Nesting of groups and components is necessary in part to avoid inadvertently selecting and working on the wrong geometry and parts. Day job typically involves all milwork/woodwork for homes with 20' ceilings and 12 air conditioners. Some elements do get hand sculpting.
This deep mining accounting stuff could be useful to help manage stuff.
-
I've rewritten the Component+Reporter to get the model's directory another way, which then avoids any such problems.
Miner now goes all the way...
Also took the chance to trap for commas in the names into ';' otherwise = messed up .csv files. Although it allowed, it's still best to avoid commas in Component, Group and Layer names.
Also made a 3rd report on 'parentage' a la Outliner...
Also sorted out the File Already Open Error...
v1.4 is here: http://www.sketchucation.com/forums/scf/viewtopic.php?p=6687#p6687
-
TIG, Your files go to the right directory now No message that the files were completed though - if you still coded for that.
It might be more useful if your three files were three pages in one Excel document.
I noticed that you cannot save adjusted column widths in the csv format. Interesting. I suppose such limitations disallows pages in csv too.
Also, area doesn't have units listed.
-
@gata said:
TIG, Your files go to the right directory now No message that the files were completed though - if you still coded for that.
It might be more useful if your three files were three pages in one Excel document.
I noticed that you cannot save adjusted column widths in the csv format. Interesting. I suppose such limitations disallows pages in csv too.
Also, area doesn't have units listed.
You should always get a dialog at the end telling you where the three files went ?
It is difficult to make multi-page csv's - that's why you get three !
The easy way to use a .csv file with formatting is to make a separate full blown Excel .xls file - using the same name seems logical (XXX-Component+Report.csv and XXX-Component+Report.xls). Then open the cvs and xls. We need to link them so that the xls keeps its formatting while the csv can be rewritten and the data reflected in the linked xls without loss of formatting [There's Excel help on this too]. Here's how..Open both files.
Have the csv at the front.
Select the cells in the csv that you want to link into the xls.
Ctrl+C to copy.
Switch to xls window.
Menu > Edit > Paste Special...
In the dialog click the bottom 'As Link' button.
Now the csv is linked into the xls.
Format the xls as you wish.
Whenever the csv changes the xls will too when it next opens.
You'll need to edit the blank fields that come mover as '0' and if the csv rows increase you'll need to re-link the csv into the xls...
See Excel Help for more details...Areas. The XYZ dims are in current units BUT the areas report in the system default 'sq inches'. I'll adjust it to come in current units - look out for an update...
-
Here's v1.5
http://www.sketchucation.com/forums/scf/viewtopic.php?p=6688#p6688
Areas are now in current units... however there is guidance on how to set areas to sq m if you work in mm etc... -
Due to the excitement of the moment I thought the written to announcement showed up at the beginning - not the end. All is well.
TIG, looks like you, Al, and vendmr are giving me a reason to delve into Excel. The ability to make custom, update-able XLS could indeed be very useful.
Recent we made a bunch of custom doors and jams. On the most part the rough opening measures and count recorded in an Excel file where correct. But somehow the people fabricating everything were often given drawings with incorrect sizes and hinge side location.
Some of my current projects includes domed ceilings and adding faux beams to a groin vault. If thing were originally laid out in SU, I wouldn't have to fudge things to fit now.
-
TIG,
ComponentReporter+ V 1.5
Outstanding script.
The parentage / outliner type report - very useful addition also.
...
The deep mining ability seems to work well after an initial (tough) trial:42 MB Model (this includes 2 x Xref'd models)
Layers 30
Component Definitions 921
Component Instances 7650
Groups 3410
...
V 1.5 went to work - 30 seconds in total to produce all reports (ie very quick).
So far the script looks really good and appears to be working well.
...
A Massive Thank You for all your hard work in producing this script.
...
Regards
Howard Leslie -
Modelhead,
You asked about what you can do with this script.
...
Increasingly clients ask for information and data related to a model - not just a pretty picture of the actually geometry / 3D views etc.
Producing a model is really just the start, not the end point in many instances.
...
Currently SU is very limited in what attributes you can attach to elements (groups / components) in a model:
Layer,Definition Name,Instance Name,Material
...
In SU you could give a Steelwork Member for example the following attributes:
Layer = 7F (7th Floor)
Definition = RSJ_10x4x25 (Component Name for Steel Beam for Example)
Instance = 1234 (Beam ID No.)
Material = Steelwork
...
Draw entire model using all your pre-drawn Steelwork Components
...
Run TIGs Script
...
Now you can query the CSV (XLS) Table in many ways eg
Filter by Floor Level - All Steelwork will be listed out (used to calc floor loadings)
How many Beams / Columns of a particular size does a building have ???
etc etc
You can now also run calcs and statistics on the components as you have a count of quantities.
TIGs script allows you to select and report by area so you can restrict the report to a given area / floor level etc.
...
Equally valid for working out quantities for regular domestic buildings / constructions
(depending upon how you draw / set your model up).
...
Material field can also be used to define contents eg pipeline contents:
water (green)
crude oil (grey)
steam (blue)
(ie not really material at all)
etc
etc
...
What would be extremely useful for SU V7 and would be top of my personal wish list (although I'm probably in a minority):
Ability to View Outliner as a Table.
Ability to Link a Field in this Outliner Table (ie an ID number of a component) to an external Database / Table and Run Querys back to the Model.
MASSIVE POTENTIAL.
(I'd definitely put this above rendering ability - but its a purely personal view).
...
Currently, unless you purchase expensive GIS software its not possible to do this with SU models.
...
Hope this gives you something to think about / answers your question.
Regards
Howard L' -
I think I found another timely use for this script - ammunition.
As I have mentioned above, there have been many expensive mistakes, mostly by the draftsmen/project managers. Myself and another person have been moved up to 'office' positions because we know how to make things. Today a 'CAD specialist' consultant was brought in to help fix the flow of information.
I described things I did and the 'specialist' thought Inventor and Solid Works would be good: but expensive and with a long learning curve. He did not know SU but he doubted the usefulness of something free. I tried to correct his perception. I found his Inventor nonsense a bit funny since I rejected Inventor 3 years ago in favor of SU.
So tonight I'm pulling together stuff to showcase this program - like how easy it is to layout a beamed, groin vault. And now this script adds a shinny, new weapon to my arsenal. So again, I thank you, very much.
Advertisement