Looking to hire someone to create a SketchUp plugin

Dear Community,

I have tried to utilize ChatGPT to help me in the creation of a plugin for SketchUp but unfortunately the AI can’t get the plugin to work no matter how much information I give it. My last resort would be to potentially hire someone who could create a small plugin for me. I have some experience in programming languages but it’s not enough to flesh out the extension. If anyone could help me, please let me know. People tell me to be careful to not be scammed, so I would prefer if it was someone from this community who knows/remembers me and whom I know but it’s not a must. So if you don’t mind an hour or two of your time and would like to earn a little, feel free to DM.

The plugin in mind should simply batch rename selected/highlighted scenes in SketchUp and add a numerical suffix at the end. It should have a dialog box callout with a text field to input the new name and 2 buttons. It’s relatively primitive. I’d also like a separate toolbar for it or alternatively an ability to assign a shortcut to the plugin. No need for an icon, as I can design one myself and replace the default one later. ChatGPT nearly managed to help me but it failed in the end because it renames every single scene regardless of what’s been highlighted.

Thanks in advance!

1 Like

Will you share the code? I’d be curious to see it.

1 Like

Instead of the - in my opinion - “Super Overhyped AI will do everything”: a simple search with a common sense e.g.:
https://extensions.sketchup.com/search/?q=Rename%20Scenes

will give a better result. :wink:

s4u-export-scenes

It seems it have a similar function you want. (The video will start from 2:58 to show the function)


.
BTW:

I don’t think there is a way in Sketchup Rubi API to check what is selected/highlighted in menus/Trays of SketchUp UI. You need to write your own interface to select scenes… (as above)

2 Likes

What makes you think that I did not search with a common sense before making this post?
I have found TIG’s Ruby scripts under Is there a plugin to batch rename scenes? • sketchUcation • 1
I have found the [Re]Scene plugin under [Plugin] [Re]Scene v1.0.7 • sketchUcation • 1
Neither of them were helpful, moreover, the download link of the [Re]Scene plugin is broken.

And S4U’s plugin did not show up in my search results (apparently it’s not easy to find it through simple google searches), which is the reason I resorted to AI.

Regarding your stance about AI, while I don’t defend or condone its existence, because I find AI generated art that’s being promoted and pushed, to be a sort of an “insult” to real artists and true art forms, I am of the opinion that those industries/companies who don’t implement or at least get familiar with AI, will not do well in the coming future. The industry is changing and AI is not at all “super overhyped”. It cannot do everything, it will never replace humans but there’s more to AI than generating images. We use AI in our company to our advantage. AI already assisted me in creating an HTML animation, which was very well accepted. Not being hostile towards AI and trying to use it to your advantage might be a more open minded approach in my opinion.

2 Likes

Certainly!

So this first one I made 2 days ago with the (paid) 3.5 version of ChatGPT. This was intended to be used without a dialog box, with the means of the Ruby API window:

def batch_rename_highlighted_scenes(new_name_prefix)
  model = Sketchup.active_model
  model.start_operation("Batch Rename Highlighted Scenes", true)

  # Get all scenes in the model
  scenes = model.pages

  # Loop through all scenes and rename highlighted ones
  scenes.each_with_index do |scene, index|
    if scene != model.pages.selected_page && scene.use_camera?
      new_name = "#{new_name_prefix} #{index + 1}"
      scene.name = new_name
    end
  end

  model.commit_operation
end

# Example usage: batch_rename_highlighted_scenes("Scene")

ChatGPT also provided me with a command line:

batch_rename_highlighted_scenes("YourPrefix")

However, this did not work because instead of renaming only highlighted scenes, it renamed every Scene I had. After some time of back and forth with the AI, I decided to leave it and try the next day again.

Second time I used the free version of ChatGPT and tried to make the plugin with a toolbar icon and a dialog callbox.

module BatchRenameScenes
  def self.rename_scenes(base_name)
    model = Sketchup.active_model
    selected_scenes = model.pages.selected
    return unless selected_scenes.any?

    active_scene_index = model.pages.active_page.index if model.pages.active_page

    selected_scenes.each_with_index do |scene, index|
      new_scene_name = "#{base_name} #{index + 1}"
      scene.name = new_scene_name
    end

    model.pages[active_scene_index].make_current if active_scene_index
  end

  def self.show_dialog
    dialog = UI::HtmlDialog.new(
      {
        title: "Batch Rename Scenes",
        style: UI::HtmlDialog::STYLE_DIALOG
      }
    )

    # Set the HTML content for the dialog
    dialog.set_html(<<-HTML)
      <html>
        <head>
          <title>Batch Rename Scenes</title>
          <style>
            body {
              font-family: sans-serif;
            }
          </style>
        </head>
        <body>
          <div style="padding: 20px; text-align: center;">
            <label for="newName">Base Name:</label>
            <br>
            <input type="text" id="newName" style="width: 80%;">
            <br><br>
            <button onclick="renameScenes()">Rename</button>
            <button onclick="closeDialog()">Cancel</button>
          </div>
          <script>
            function renameScenes() {
              var baseName = document.getElementById('newName').value;
              sketchupAPI.renameScenes(baseName);
              sketchupAPI.closeDialog();
            }

            function closeDialog() {
              sketchupAPI.closeDialog();
            }
          </script>
        </body>
      </html>
    HTML

    # Set the position of the dialog to the center of the screen
    dialog.center

    dialog.add_action_callback("renameScenes") do |dlg, base_name|
      rename_scenes(base_name)
    end

    dialog.add_action_callback("closeDialog") do |dlg, _params|
      dlg.close
    end

    dialog.show
  end
end

toolbar = UI::Toolbar.new("Batch Rename Scenes")
cmd = UI::Command.new("Batch Rename Scenes") { BatchRenameScenes.show_dialog }
cmd.small_icon = "BatchRenameScenes.png" # You can replace "BatchRenameScenes.png" with your own square icon file
cmd.large_icon = cmd.small_icon
cmd.tooltip = "Batch Rename Scenes"
toolbar = toolbar.add_item(cmd)
toolbar.show

UI.menu("Extensions").add_item("Batch Rename Scenes") { BatchRenameScenes.show_dialog }

This was 50% successful, except clicking on “Rename” did not do anything at all. ChatGPT edited the script several times, trying to get it to work but sadly unsuccessfully. I was too tired at this point, so I just closed everything. :face_with_hand_over_mouth:

1 Like

I’m guessing that that part after the comma was the 50% that was unsuccessful. ;^)

It looks like you’re missing an “end” statement for your BatchRenameScenes module. Also, your module should be wrapped in a namespace.

I’m going to look at this… but this is practice for me. I may not be able to get it working…

EDIT: probably wrong about the missing “end”…

I didn’t mean to offend you with my comment. Sorry, using a smiley ( :wink: ) , I thought you understood my “humour”…

Anyway, - without further discussing AI - here it’s half-baked code, more or less working, but nowhere near finished and ugly. Use it or leave it… as you like! Copy-paste it to Ruby Console to try.
. :beer: . :peace_symbol:

require 'json.rb'
module Dezmo
module DezmoRenameScenesSuffix
  extend self
  @@loaded = false unless defined?(@@loaded)
  
  def add_suffix(text, digits)
    @suffix_number += 1
    text + @suffix_number.to_s.rjust(digits, '0')
  end
  
  def rename_pages(array = Sketchup.active_model.pages.map(&:name))
    json = array.to_json
    html = %{
      <!DOCTYPE html>
      <html>
        <head>
          <title>Page Title</title>
          <script>
            function toSu() {
              var startnum = document.getElementById("startnumber").value;
              var digits = document.getElementById("digits").value;
              var options = document.getElementById("mySelect").selectedOptions;
              var pages = Array.from(options).map(({ value }) => value);
              sketchup.rename(JSON.stringify([pages, startnum, digits]));
            }
          </script>
        </head>
        <body>
          <div id="top">
            <button id='rename' onclick='toSu()' >Rename Selected Scenes</button><br><br>
            Start number : 
            <input type="number" size="4" id="startnumber" name="startnumber" value="1" ><br><br>
            Digits..: 
            <input type="number" size="4" id="digits" name="digits" value="3">
          </div><br><br>
          <div id="pages-div"></div>
          <script>
            var data = JSON.parse('#{json}');
            var mydiv = document.getElementById("pages-div");
            var selectList = document.createElement("select");
            selectList.id = "mySelect";
            selectList.setAttribute('multiple', '');
            mydiv.appendChild(selectList);
            for (var i = 0; i < data.length; i++) {
                var option = document.createElement("option");
                option.value = data[i];
                option.text = data[i];
                selectList.appendChild(option);
            }
            selectList.setAttribute('size', selectList.childElementCount)
          </script>
        </body>
      </html>
    }

    @dialog = UI::HtmlDialog.new(
      :dialog_title => "Test Rename Scenes Dezmo 2023",
      :width => 400,
      :height => 600,
      :left => 150,
      :top => 150,
      :style => UI::HtmlDialog::STYLE_DIALOG
    )
    @dialog.set_html(html)
    @dialog.add_action_callback("rename") { |_context, data |
      pages, startnum, digits = JSON.parse(data)
      @suffix_number = startnum.to_i - 1
      len = digits.to_i.abs
      pages.each{|pagename|
        Sketchup.active_model.pages[pagename].name = add_suffix(pagename, len)
      }
      @dialog.close
    }
    @dialog.show
  end
  
  def donate
    status = UI.openURL("https://paypal.me/DezmoHU")
  end
  
  def scenes?(pages = Sketchup.active_model.pages)
    pages.size > 1
  end

  unless @@loaded
    cmd6 = UI::Command.new("Rename Scenes Dialog"){
      rename_pages()
    }
    Tip6ok1 = "Click for Rename Scenes Dialog\n(Note: Can not be undone by this plugin!)"
    Tip6no = "Create minimum two Scenes"
    cmd6.tooltip = cmd6.menu_text
    cmd6.set_validation_proc{
      if scenes?
        cmd6.status_bar_text = Tip6ok1
        MF_ENABLED
      else
        cmd6.status_bar_text = Tip6no
        MF_DISABLED | MF_GRAYED
      end
    }
    
    cmd7 = UI::Command.new("Donate"){
      donate
    }
    cmd7.tooltip = cmd7.menu_text
    cmd7.status_bar_text = "Donate me by Beer, Cookies...\nFor both parties: No obligation!\nPayPal link will open in your web browser."
    
    submenu = UI.menu("Plugin").add_submenu("Dezmo Rename Scenes")
    submenu.add_item cmd6
    submenu.add_item cmd7
    
    cmd6.small_icon = File.join(File.dirname(__FILE__), "/icon1.png")
    cmd6.large_icon = File.join(File.dirname(__FILE__), "/icon1.png")
    
    cmd7.small_icon = File.join(File.dirname(__FILE__), "/beer.png")
    cmd7.large_icon = File.join(File.dirname(__FILE__), "/beer.png")
    
    Toolbar1 = UI::Toolbar.new("Rename Scenes, ©Dezmo")
    Toolbar1.add_item(cmd6)
    Toolbar1.add_separator
    Toolbar1.add_item(cmd7)
    Toolbar1.restore
    
    @@loaded = true
  end
  
end
end

renamescenesdez

3 Likes

JFD: Dezmo, can you do a, b, c and x, y, z?

Dezmo: Hold my beer.

I’m only a little disappointed that your donate icon isn’t included ;^)!

On Su '23:

Because the topic opener said he can do it… anyway - is is a just snippet - you need to create a proper Extension structure… and include the icon in the extension folder, beside this .rb file.
beer

I will think about “a,b,c” later… (intentionally no deadline given :wink: )

Hi there!

I also experimented with using ChatGPT to quickly craft some code for renaming scenes. The outcome was quite intriguing! While a few tweaks were necessary, about 90% of the code was effectively written by AI. It’s fascinating to see how these tools can aid in our coding endeavors.

module CURIC
  module SceneManager
    module Rename
      class << self
        attr_accessor :dialog # Allows setting and getting of the @dialog instance variable

        # Entry point to run the plugin
        def run
          unless Object.const_defined?('CURIC::SceneManager::Selection')
            return UI.messagebox("Please install Curic Scene Manager to use this plugin")
          end

          @dialog && @dialog.visible? ? @dialog.bring_to_front : show_dialog
        end

        # Displays a dialog box for renaming scenes
        def show_dialog
          setup_dialog
          @dialog.set_html(html_content)
          @dialog.show
        end

        # Defines HTML content for the dialog
        def html_content
          <<-HTML
          <!DOCTYPE html>
            <html>
              <head>
                <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
              </head>
              <body class="bg-gradient-to-r from-black to-red-900 p-6">
                <div id="app" class="max-w-sm mx-auto bg-gray-700 text-white shadow-md rounded px-8 pt-6 pb-8 mb-4">
                    <h1 class="text-lg mb-4">Scene Manager</h1>

                    <div class="mb-4">
                        <label class="block text-gray-700 text-sm font-bold mb-2" for="type-select">
                            Type:
                        </label>
                        <select id="type-select" v-model="options.type" class="shadow border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
                            <option value="Replace Text">Replace Text</option>
                            <option value="Add Text">Add Text</option>
                        </select>
                    </div>

                    <div class="mb-4" v-if="options.type === 'Replace Text'">
                        <label class="block text-gray-700 text-sm font-bold mb-2">
                            Find:
                            <input type="text" v-model="options.find" placeholder="Find" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline">
                        </label>
                        <label class="block text-gray-700 text-sm font-bold mb-2">
                            Replace:
                            <input type="text" v-model="options.replace" placeholder="Replace" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline">
                        </label>
                    </div>
                    <div class="mb-4" v-else>
                        <label class="block text-gray-700 text-sm font-bold mb-2">
                            Add Text:
                            <input type="text" v-model="options.add_text" placeholder="Add Text" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline">
                        </label>
                        <label class="block text-gray-700 text-sm font-bold mb-2" for="position-select">
                            Add Position:
                            <select id="position-select" v-model="options.add_position" class="shadow border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
                                <option value="prefix">Prefix</option>
                                <option value="suffix">Suffix</option>
                            </select>
                        </label>
                    </div>

                    <div class="flex items-center justify-between">
                      <button @click="applyOptions" class="bg-red-600 hover:bg-red-800 font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
                          Apply
                      </button>
                  </div>
                </div>

                <script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.js"></script>
                <script type="text/javascript">
                  new Vue({
                    el: '#app',
                    data: function() {
                      return {
                        options: {
                          type: 'Replace Text',
                          find: '',
                          replace: '',
                          add_text: '',
                          add_position: 'prefix',
                        }
                      }
                    },
                    methods: {
                      applyOptions() {
                        sketchup.apply(this.options);
                      }
                    }
                  })
                </script>
              </body>
            </html>

          HTML
        end

        # Sets up the dialog with specified properties
        def setup_dialog
          @dialog = UI::HtmlDialog.new(dialog_title: "Rename Scenes", max_width: 500, max_height: 500)
          @dialog.center
          @dialog.add_action_callback("apply") { |_a, options| apply(options) }
        end

        # Applies renaming logic based on user input
        def apply(options)
          pages = CURIC::SceneManager.selection.get_sketchup_item
          return UI.messagebox("Please select pages to rename") if pages.empty?

          if options['type'] == 'Replace Text'
            return UI.messagebox("Please input find text") if options['find'].empty?
          elsif options['add_text'].empty?
            return UI.messagebox("Please input add text")
          end

          rename_pages(pages, options)

          UI.messagebox("Rename success: #{pages.size} Scene(s)")
          CURIC::SceneManager.refresh
        end

        # Validates input and performs renaming
        def rename_pages(pages, options)
          model = Sketchup.active_model
          model.start_operation("Rename Scenes", true)

          pages.each do |page|
            page.name = rename_page(page, options)
          end

          model.commit_operation
        end

        # Determines the new name for a page
        def rename_page(page, options)
          case options['type']
          when 'Replace Text'
            replace_text_in_name(page.name, options)
          else
            add_text_to_name(page.name, options)
          end
        end

        # Replaces text in the scene name
        def replace_text_in_name(name, options)
          name.gsub(options['find'], options['replace'])
        end

        # Adds text to the scene name
        def add_text_to_name(name, options)
          options['add_position'] == 'prefix' ? "#{options['add_text']}#{name}" : "#{name}#{options['add_text']}"
        end
      end

      # Initializes the plugin
      unless file_loaded?(__FILE__)
        ex = SketchupExtension.new('Rename Scenes', __FILE__)
        ex.creator = 'Vo Quoc Hai & GPT'
        Sketchup.register_extension(ex, true)

        cmd = UI::Command.new('Rename Scenes') { CURIC::SceneManager::Rename.run }
        UI.menu('Plugins').add_item(cmd)
      end
    end
  end
end

file_loaded(__FILE__)

2 Likes

Hey Dezmo, thank you for clarifying. I also apologize, it’s not easy to discern humour from sarcasm in a text, hence my reply. Thank you also for the script. I don’t exactly know what you mean by “ugly”, because I have no professional knowledge of programming languages :smiley: so it all looks the same to me :see_no_evil: But I appreciate you taking time. I like the beer icon btw!

1 Like

Hey Curic! Didn’t know you were also active in this Forum. Let me use this and say hats off to you for your plugins. They are an essential part of my workflow and I use several of them on a daily basis. :raised_hands:

I see you were successful with ChatGPT! I wasn’t that luck with my attempt, haha! But yes, it’s truly fascinating what it can do!

Thank you so much for your kind words! I’m glad to hear that my plugins are a part of your daily workflow. As for ChatGPT, I’m just exploring its possibilities too. Wishing you continued success and enjoyment in your projects!

1 Like

@VahePaulman I went ahead and created a registration file and a loader file using your code in “main.rb”. The gist of your extension looks like this (with the exception of the added Dezmo icon):

I believe that Dezmo may be correct that selecting active scenes (as in the Scenes in the Scenes panel/tray) will not work. I don’t use Mac so I’m guessing the Scene Manager in Curic’s video is also an extension and not the Mac version of the Scenes panel/tray.

Anyway, you can see that they are getting the scenes in the model, displaying them, and selecting from them. That may have been a point where you went off course a bit.

You have some working examples now. But I’m going to see if I can fix your version as well. “Practice makes perfect” they say (and let’s hope ‘they’ are right).

Here is your version with the adjustments for making an extension out of it:

BatechRenameScenes.rb registration file:
module IDK_Programming
    module BatchRenameScenes
  
      EXTENSION = SketchupExtension.new(
        'BatchRenameScenes',  # The name of the extension as it will appear in SketchUp
        'BatchRenameScenes/BatchRenameScenes_loader'  # The path to the loader file
      )
      EXTENSION.instance_eval {
        self.description= 'Adds an extension.'
        self.version=     '0.0.0'
        self.copyright=   "©2023 under If it's for free, it's for me."
        self.creator=     'IDK_Programming / SU Community'
      }
      Sketchup.register_extension(EXTENSION, true) 
  
    end # extension submodule
  end # top level namespace module
BatchRenameScenes_loader.rb
module IDK_Programming
    module BatchRenameScenes
      
      # Define PLUGIN_PATH constant
      PLUGIN_PATH ||= File.dirname(__FILE__)
  
      # Require the main.rb file
      require File.join(PLUGIN_PATH, 'main.rb')
  
      # Define other constants
      PLUGIN_PATH_IMAGE = File.join(PLUGIN_PATH, 'icons')
  
    end
end

Still messy,

main.rb
module IDK_Programming
  module BatchRenameScenes

        def self.rename_scenes(base_name)
            model = Sketchup.active_model
            selected_scenes = model.pages.selected
            return unless selected_scenes.any?
        
            active_scene_index = model.pages.active_page.index if model.pages.active_page
        
            selected_scenes.each_with_index do |scene, index|
                new_scene_name = "#{base_name} #{index + 1}"
                scene.name = new_scene_name
            end
        
            model.pages[active_scene_index].make_current if active_scene_index
            end
        
            def self.show_dialog
            dialog = UI::HtmlDialog.new(
                {
                title: "Batch Rename Scenes",
                style: UI::HtmlDialog::STYLE_DIALOG
                }
            )
        
            # Set the HTML content for the dialog
            dialog.set_html(<<-HTML)
                <html>
                <head>
                    <title>Batch Rename Scenes</title>
                    <style>
                    body {
                        font-family: sans-serif;
                    }
                    </style>
                </head>
                <body>
                    <div style="padding: 20px; text-align: center;">
                    <label for="newName">Base Name:</label>
                    <br>
                    <input type="text" id="newName" style="width: 80%;">
                    <br><br>
                    <button onclick="renameScenes()">Rename</button>
                    <button onclick="closeDialog()">Cancel</button>
                    </div>
                    <script>
                    function renameScenes() {
                        var baseName = document.getElementById('newName').value;
                        sketchupAPI.renameScenes(baseName);
                        sketchupAPI.closeDialog();
                    }
        
                    function closeDialog() {
                        sketchupAPI.closeDialog();
                    }
                    </script>
                </body>
                </html>
            HTML
        
            # Set the position of the dialog to the center of the screen
            dialog.center
        
            dialog.add_action_callback("renameScenes") do |dlg, base_name|
                rename_scenes(base_name)
            end
        
            dialog.add_action_callback("closeDialog") do |dlg, _params|
                dlg.close
            end
        
            dialog.show
            end
           
        
            toolbar = UI::Toolbar.new("Batch Rename Scenes")

            # Existing command for Batch Rename Scenes
            rename_cmd = UI::Command.new("Batch Rename Scenes") { BatchRenameScenes.show_dialog }
            icon_path = File.join(File.dirname(__FILE__), 'icons', 'BatchRenameScenes.png')
            rename_cmd.small_icon = icon_path
            rename_cmd.large_icon = icon_path
            rename_cmd.tooltip = "Batch Rename Scenes"
            toolbar = toolbar.add_item(rename_cmd)

            # New command for Beer button - add link.
            beer_cmd = UI::Command.new("Beer") {
            UI.messagebox("Cheers with Beer!")
            }
            beer_icon_path = File.join(File.dirname(__FILE__), 'icons', 'beer.png')
            beer_cmd.small_icon = beer_icon_path
            beer_cmd.large_icon = beer_icon_path
            beer_cmd.tooltip = "Beer"
            toolbar = toolbar.add_item(beer_cmd)

            toolbar.show

            UI.menu("Extensions").add_item("Batch Rename Scenes") { BatchRenameScenes.show_dialog }

    end
end
1 Like

If I’m honest I didn’t understand half of what you wrote because I’m not familiar what is a loader and what is a registration file? :smiley: The s4u plugin suggested by Dezmo seems to have done the job but now as I have the seen what making a plugin looks like I’m intrigued of trying it again. This time asking SketchUp to highlight all scenes that contain a certain number.
ChatGPT tells me:

In SketchUp, the model.pages.selected expression refers to a collection of the currently selected scenes (or pages) within the active SketchUp model"

Also that

model.pages.selected and the currently active scene are not the same.

  1. model.pages.selected: This represents a collection of scenes (or pages) that are currently highlighted or selected in the SketchUp interface. These are scenes that the user has interacted with, typically by clicking on them or using a selection method. You can perform operations on the scenes in this collection.
  2. Currently Active Scene: The currently active scene, on the other hand, is the scene that is currently set as the “active” scene in the SketchUp model. The active scene is the one that will be displayed when you switch to that scene. You can access the active scene using model.pages.active_page.

Dezmo said there is no way in SketchUp to check what is selected/highlighted. But then I don’t understand what is the “model.pages.selected” intended for.

def add_suffix(text, digits, fillstring)
   new_text = text + @suffix.rjust(digits, fillstring)
   @suffix = @suffix.next
   new_text
end

You can test like e.g.:

@suffix = "a"
100.times{
  puts add_suffix("Test-", 5, "_")
}

Play with parameters… :bulb: you can also use ljust instead of rjust.
Ps: String #next method

It lies unabashedly.

There is no such a #selected method in Class: Sketchup::Pages (and at all in Sketchup Ruby API)

Again WRONG! Actually it is:
The Pages #selected_page method is used to retrieve the currently selected page.

Still saying. :slight_smile:

It is representing the user interface selection - It is poorly worded and the syntax suggests ruby code, which is very misleading, as I told you can not retrieve it by Ruby API.

1 Like

Woah, thank you! I was aware that ChatGPT makes mistakes or rather spreads misinformation (tested it personally on historically proven questions and got lies as a reply). But I didn’t expect that it would straight out lie to such degree. I’ll make sure to let it know tomorrow, haha! :smiley:

1 Like

So, for SU extensions, there is a registration file and an extension folder in the SU Plugins folder (something like, C:\Users\username\AppData\Roaming\SketchUp\SketchUp 2022\SketchUp\Plugins\BatchRenameScenes). This registration file has the same name as the extension folder. For example, you might see the “su_sandbox.rb” registration file in the SketchUp Plugins folder along with the “su_sandbox” folder if you have the Sandbox Tools extension installed. For a basic setup, the registration file in the Plugins folder points at the ‘main.rb’ in the extension folder. The registration file I shared points at a loader file instead of a ‘main’. This is just an additional step where the loader file points at the main.rb and some file paths are set up. This can be helpful for organization. For example you could have:

require File.join(PLUGIN_PATH, 'main.rb')
require File.join(PLUGIN_PATH, 'myHtml.html')
require File.join(PLUGIN_PATH, 'myGreatJavascript.js')

and

PLUGIN_PATH_IMAGE = File.join(PLUGIN_PATH, 'icons')
PLUGIN_PATH_HTML = File.join(PLUGIN_PATH, 'html')
PLUGIN_PATH_IMAGE = File.join(PLUGIN_PATH, 'css')
PLUGIN_PATH_HTML = File.join(PLUGIN_PATH, 'js')

That’s more than you need to get started but it’s worth mentioning.

I’m not sure that is possible either… at least as far as highlighting scenes in the Scenes Panel. This is similar to the issue of using ‘selected scenes’. You can’t necessarily use selected scenes-that-are-in-the-SU-Scenes-panel. You need your extension to display the scenes in some way, then select them there. Same for highlighting. You could display the scenes in your extension, search the scenes for a number and highlight those (Or search the scenes and only display those with a certain number, etc.). But highlighting in the Scenes panel… I doubt that. But I haven’t monkeyed around with scenes much to know what’s possible…

I have a basic scene re-namer working. It stared using your example… but now it’s its own animal.

1 Like

Ut-oh. ;^)! I just meant to imply that you bust out code like it aint no thang. But you took it upon yourself to demonstrate the truth of the matter :). I’ll take a look at those links.

2 Likes