Looking to hire someone to create a SketchUp plugin

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