Looking through your posts, I think I misunderstood you quite a bit (rather a lot)..
My mother never spoke English to me.
Having worked for an international company for 25 years, I thought I understand the language of the kitchen, I understand the dialects and quite a few slang… but if someone speaks the language of the kitchen and slang with a dialect and typo… it can be a problem.
A raw translation does not reflect the actual meaning. I still need to improve on this!
Anyway, I already wrote what I wrote, even if I didn’t get what you meant at first…, I hope it will be useful to you or someone…
If I make a joke and give a compliment but the joke isn’t good, just take the second part as my meaning
*‘Aint’ aint word = ‘aint’ is not a word. “Thang” = “Thing” Usually if I speak like that, I inflect my voice so it’s more obvious that I’m kidding ;^)!.
But in this thread we’re supposed to be focused on a language you know well and I don’t… which is why I haven’t posted the code for the extension yet. I’ll get back to that now…
@VahePaulman Hi, chatgpt works great but it makes a few mistakes for which you need to have the knowledge of how Sketchup API works. I am a developer and use chatgpt a lot but for smaller modules and functions and it works great. If you still need to plugin to be made and it is just to rename scene I can do it for you. Just mention me and reply and I would know that you need my help.
I can also have a zoom meeting and teach you how to do it by using chat gpt, while creating the plugin in session.
I have over 60 scenes in a file, where I need to replace for example the B40 with B120.
So in a nutshell it’s a “find and replace” feature, that neither s4u nor @curic4su 's plugins have.
Is anyone aware of such a plugin?
Currently I am using the “Advanced Renamer” PC software and renaming my renderings in post. But the SKP files also need to be “clean” and error free, so a find-and-replace feature would really be the savior in this situation.
Note:
SketchUp (therefore, Ruby API either) does not keep track about the changes of the scenes or its properties. Therefore the text replacement what this snippet do, cannot be undone. (Ctrl+z, Alt+Backspace, undo button wont work.)
However using the opposite find-replace string pair can be appropriate.
I told you! Don’t be lazy to make a backup(s)!
Copy paste the code below to Ruby console and hit Enter. You will have a menu in Extension>“Find-Replace in Scene names”
Enter what you want to Find and Replace to into the popup.
All occurrences of the “Find:” string will be replaced to a “Replace to:” string in all scene names.
Does not really tested…
No warranties! Use at your own risk!
module Dezmo::FindReplaceinPageNames
extend self
def run
prompt = ["Find:", "Replace to:"]
defaults = ["", "" ]
input = UI.inputbox(prompt, defaults, "Find&Replace in Scene names")
return unless input
rename_pages(*input)
end
def rename_pages(find, replace)
model = Sketchup.active_model
pages = model.pages
model.start_operation("Find&Replace in Scene names", true)
pages.each do |page|
page.name = page.name.gsub(find, replace)
end
model.commit_operation
end
unless defined?(@ui_loaded)
UI.menu("Plugins").add_item("Find-Replace in Scene names") { run }
@ui_loaded = true
end
end
Thank you so much for your time and the code @dezmo!
I’ll give it a try and let you know how it goes.
I do make backups! Trust me I’ve learned my lesson 11 years ago, while I was still in uni, when an architectural SKP file I was working on for 4 months became corrupted 1 week before deadline and I had no backups…
In this case however, it’ not a question of backups. The “B” from my screenshots stands for “Breite” (width in German). It’s a furniture unit with 4 different widths. We first modelled and finished the narrowest one and since it’s modular, we just duplicated the SKP and stretched the width accordingly. The difficulty rose from the scene names. The scenes have to be named precisely according to internal product code guidelines. We already named and rendered everything in the first SKP file, but since the second file contains a wider version, the B-attribute needs to be adjusted of course.
A backup copy would not help in this case. Looking forward to giving your code a try! Thank you again!
Like @VahePaulman, I was interested by the possibility of editing scene names or —even better— find and replace part of scene names.
I found your post and your work seemed very interesting and promising.
Unfornatunately, your code and your extension do not work with my version of Sketchup 2024 on my Mac and I was disapointed because your work seemed to be exactly what I needed (and for free!).
Just passing by this thread, i actually made 1 plugin successfully similar to this. The only difference is it functions similar to outliner, but instead in out liner, it creates each group into 1 layer with a unique name. Pretty raw since you have to rename the prefixes in the ruby code.
It seams that the syntax is changed in the Ruby version used by SU 2024.
You workaround seams to be okay, but for better “isolation” i would still use Dezmo as outside namespace module:
Code
module Dezmo
module FindReplaceinPageNames
extend self
def run
prompt = ["Find:", "Replace to:"]
defaults = ["", "" ]
input = UI.inputbox(prompt, defaults, "Find&Replace in Scene names")
return unless input
rename_pages(*input)
end
def rename_pages(find, replace)
model = Sketchup.active_model
pages = model.pages
model.start_operation("Find&Replace in Scene names", true)
pages.each do |page|
page.name = page.name.gsub(find, replace)
end
model.commit_operation
end
unless defined?(@ui_loaded)
UI.menu("Plugins").add_item("Find-Replace in Scene names") { run }
@ui_loaded = true
end
end
end
Dezmo,
I looked into this error because I had periodically seen it and not understood the cause.
From the Ruby Docs (all versions)
You may also define inner modules using :: provided the outer modules (or classes)
are already defined:
module Outer::Inner::GrandChild
end
Note that this will raise a NameError if Outer and Outer::Inner are
not already defined.