Change sketchup layers in excel
-
Hi,
I would like to be able to export a list of components and their layers from sketchup. Then change the layers in excel to then import back into sketchup.
If anyone could point me to a plugin that does this it would be much appreciated.
Thanks!
-
There's nothing ready-made.
Accessing XLS files is possible on PC.
However, it's convoluted as the file format is binary.It'd be easier to make the exported file as text - CSV [Comma-Separate-Variable] or TSV [Tab].
This can be changed in Excel and re-saved as CSV.
Then you can read the file in and get the Component-Instance Layer names from it...However, I see a few pitfalls...
For example:
The Instances will not have an enduring ID across sessions [unless you are using v2014], so finding them again if you are not in the same session is awkward, without you adding a custom attribute to each of them.You can of course do this in pure Ruby, entirely within SketchUp - via the Console, or via a script...
It depends how you want to 're-layer' your component-instances...
Globally, in a selection, in an active_entities context etc, and how the layers are reallocated - new layer made and used, another layer assigned, Layer0 [nil] assigned etc... -
Thank you for your reply TIG,
I don't have any experience with scripting or "pure ruby". Could you give me some advice on how i would go about getting a plugin like this developed?
Thanks
-
Perhaps a step-by-step description of how you see doing this - in simple English - is a good starting point...
Then the Ruby code can be hung on that framework. -
Here are the following steps we think we will need-
1 - Create Components and assign layers in sketchup
2 - Export a list of Component Names and layers from sketchup to Excel (using Generate Report Tool)
3 - Edit list in excel to change the components assigned layers (The Component name will always stay the same)
4 - Import Excel Sheet into sketchup to automatically update Component LayersWe know know how to do steps 1 to 3 using generate report in sketchup. What we need is to be able to import the altered CSV file back into sketchup and it automatically update the component layers.
Any help would be greatly appreciated.
Thanks -
The Generate Report tool's CSV is set up thus:
Column:
A: path - e.g. says 'Model/DefnName' if if definition 'Model/InstName' if name set, 'Model/GroupName' if it's a group or 'Model/Unnamed Part' if group name is not set***
B: nesting level
name of instance/group - the column A path ends with it if group***.
E: name of definition [this is always 'blank' if it's a group]
F: layer name
...So edit the CSV using Excel and change column F [layer-name] as desired.
Save the changed CSV as say '2014-07-14.csv
'.You then need to read in the changed csv file's text and apply the values to the relevant objects...
This is relatively straightforward.
I can PM you an example...One complicating issue - if you have two or more instances of the same component definition in the same context, with the same name, and they have different layers assigned to them, then how can the code know which is which ?
There is a way, the csv file's columns HJK give the XYZ coordinates for the location of each instance/group [in inches], so these can be used to find the relevant instance - provided the model has not changed since the CSV was written...
It makes it a little convoluted, but still possible... -
TIG, would you be willing to share your example of how to do this with me? I am looking for a way to do this exact thing as well. Generate a .csv report of dynamic attribute values, open and edit in excel, and then update the values back into sketchup. I don't know a ton about ruby at this point, and while I am not opposed to learning, I would be much obliged if you might consider helping me down the path a bit.
Thanks!
Advertisement