Component name mismatching during component save

Until the core code is changed [if ever!], then what you want is a script which does two things.

If one component-instance is selected the context-menu includes an item “Save As Xxxxx.skp”…
Where “Xxxxx” is the name of that instance’s definition [or as near to it as can be - e.g. a|:/<> etc are not allowed in file names but they are acceptable in a definition name !]
When you choose that item a dialog opens to choose the location folder [defaulting to your Components folder]…

A File menu addition “Save All Definitions into a Collection”…
When you choose that item a dialog opens to choose the location folder [defaulting to your Components folder]…
All definitions are saved with the name of that definition + .skp [or as near to it as can be - e.g. a|:/<> etc are not allowed in file names but they are acceptable in a definition name !]

This is relatively easy script to set up…

Yes, thank you, it is very close to how I imagine it!

Yes, that would be nice, although in that case I can change the name of each file myself. Of course, this is time consuming, but not tragic.

It is possible that it can also be created as an additional command in the File menu, but I would prefer this command to be in the Components dialog instead of the “Save as local collection” command that is not working properly. Or, in the worst case, next to it, as “Save definitions as local collection”. Of course, the question arises as to what the “Save as local collection” command really does, because the result obtained by it is not always fully understood by the users, and uses component characteristics that the user does not actually use and does not even know about their existence.

P.S. I never use special character definitions in names. The exception is the comma, which in my country is the decimal separator. In this case, however, the program replaces it with an underscore, which is perfectly acceptable to me.

In the Ruby API we can write entries to menus, context-menus and tool’s toolbars - unfortunately there’s no access to the Components dialog itself…

The context menu sounds good.

Here’s a simple script that does what you want.
Put the RB file into your Plugins folder and restart SketchUp…
It is not an extension and it’s not signed…

Usage: There are 2 tools…

a. Select one instance of a definition in your model to see the entry, then get…
Context-menu > Save_As… Definition ‘Xxxx.skp’ [where Xxxx is the name of the selected instance’s definition]

b. File menu || Context-menu > Save All Definitions into a Collection…
There is a file-counter displayed in the directory-selector header and the status-bar.

The directory-selector always defaults to the user’s Components folder, as set in Preferences…

TIG-DefnSaver.rb (3.4 KB)

4 Likes

It works great. Thanks a lot for the help!

Prove

perhaps a few adjustments needed for saving unused components? :slight_smile:

For this guy, please https://forums.sketchup.com/t/identifying-unused-components/136182

1 Like

Perhaps you could purge unused definitions first, then save-to-collection, then do an undo to undo purge if you want to keep the unused ones ?
The saving-out does nothing to the model itself…

No, I don’t have that problem. I’m happy with the algorithm I’m using because it fully meets my needs.

Thanks, Mike, for linking me to this thread. As I’m just now learning how to save collections, I’m having all sorts of problems including over half the components not saving, and seeing name changes. Following…