Sequential naming of unique components eg fence palings
-
Hi, I'm designing a fence (see image) where each upright (each is a unique component) is a different length. Then I'm using TIG's component reporter++ http://sketchucation.com/forums/viewtopic.php?p=147658#p147658to export a csv.
Due to drawing process the components are not 'in order' (to make different lengths I used intersect surface, then Christ Fulmer's loose to groups, then ThomThoms groups to components) - I'd like them numbered e.g. from left to right: 1 to n, then when I export I'd have an in order column which would make it easier for the fabricator to make the fence and easily query me about any variant issues.
Has anyone solved something like this?
I'm going to add more info to this later today
-
There is a Component Instance name and a Component Definition name
To sequence the Instance names from left to right
mod = Sketchup.active_model ent = mod.active_entities sel = mod.selection unless sel.empty? cis = sel.grep(Sketchup;;ComponentInstance).sort_by{|ci|ci.bounds.min.x} cis.each_with_index{|ci,i| ci.name=(i+1).to_s} else UI.messagebox "Nothing Selected" end
To sequence the Definition names
mod = Sketchup.active_model ent = mod.active_entities sel = mod.selection unless sel.empty? cis = sel.grep(Sketchup;;ComponentInstance).sort_by{|ci|ci.bounds.min.x} cis.each{|ci| ci.make_unique if ci.definition.count_instances>1} cis.each_with_index{|ci,i| ci.definition.name=(i+1).to_s} else UI.messagebox "Nothing Selected" end
-
Hi again Sdmitch, How do I run this? (Hoping answer isn't too obvious!)
-
@unearthed said:
Hi again Sdmitch, How do I run this? (Hoping answer isn't too obvious!)
Select the components. Select, copy and paste the code into Window>Ruby Console and press Enter.If it works for you, we can make it into a plugin so you can execute it from the Plugins or Context menu.
-
Hi, It seems to work fine, the first part doesn't seem to change anything (will run again later and check tho'), and the second part does the sequential name/numbering. Amazing.
I ended up using Aerilius' console http://sketchucation.com/forums/viewtopic.php?p=414816#p414816 as the default doesn't seem to accept multiline paste.
-
The "first" part worked because the "Name:" was changed. The "second" part changed the "Definition Name:" which is apparently what you were looking for. So just ignore the first part.
My apologies, I forgot that SU8 doesn't accept multi-line input. But since you have Aerilius' console, you can save the snippet and recall and use it anytime you need it.
Be aware that, as written, the code expects the components to not be aligned with or along the "Y" axis. Otherwise, it should always work.
Advertisement