Controlling The Way Sketchup Appends Component Definition Names

I use SU for BOMs (File > Generate Report) and its great once you get used to it - one of the challenges I’ve faced is, when modelling, I might take one component and make it unique several times within a model so that I have several different lengths of that component in the model (a length of steel for example).

Sketchup handles this by appending #1 (or subsequent numbers) to the component definition whenever I make a component unique. This allows me to track that component and find it easily when I have the resulting BOM in Excel.

However, does anyone know of a way to control this appending of components so that I can make it “-1” or “+A” instead of the standard “#1”?

I don’t want to use dynamic components because they do not automatically increment definition names like the standard component definition does (using DCs results in me having to manually change dynamic component attributes if I modify a model - which is very tedious and error-prone).

This automatic definition name appending is a great (and I believe underutilized part) of Sketchup (if thats what you call it) but the power to control it a little more would be amazing.

1 Like

I would also like to know more about this. It could potentially speed things up for me during BOM production.

Ash.

Here is a snippet that you can paste into the Ruby Console to try

@mod = Sketchup.active_model
@ent = @mod.active_entities
@sel = @mod.selection
opts = UI.inputbox(["Replace # With:","Suffix Type:"],['-','Numeric'],["-|_|+","Numeric|Alpha"],"Rename Component Definitions")
if opts
  sep,typ=opts; add = typ=="Numeric" ? "0" : "@"
  @mod.definitions.each{|cd|
    name,numb=cd.name.split("#"); next unless numb
    begin
      new_name=name+sep+add.next!; puts new_name
    end while @mod.definitions[new_name]
    cd.name = new_name
  }
end

It will only rename component definitions that contain a “#” in their name. It checks to make sure that names are not duplicated.in subsequent runs.

2 Likes

Thank you sdmitch.

The shown script can prove useful for me but doesn’t solve the problem of manually inputting the definition relating to length of components.

A typical scenario for a project would be I have say 4 different types of steel section (RHS,SHS, EA and UKB)
The equal angle for example could require 40 different instances each with a different length. So these could be named EA50_B 700, EA50_B 1200 etc.

Is there any way to have the definition of the component to be driven of the dimension within the component? So, as the length changes so does the number at the end of the component definition?

I hope that makes sense.

thank you

Perhaps if it was a dynamic component or a script running with a Component Observer.

2 Likes

thanks, I will have to look into it further.