sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Mass rename components

    Scheduled Pinned Locked Moved Developers' Forum
    23 Posts 6 Posters 10.5k Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • TIGT Online
      TIG Moderator
      last edited by

      You could try editing the code as follows - inside the

      {}
      

      block of

      ...each{|d|...}
      

      substitute...
      Change the value of

      i=
      

      to how many characters you want to loose...
      To trim off the end use

      i=10;n=d.name;1.times{n=n.chop};d.name=n;
      

      To trim off the start use

      i=10;n=d.name;n=n[i..-1];d.name=n;
      
      

      TIG

      1 Reply Last reply Reply Quote 0
      • M Offline
        MAdel
        last edited by

        @tig said:

        You could try editing the code as follows - inside the

        {}
        

        block of

        ...each{|d|...}
        

        substitute...

        Change the value of

        i=
        

        to how many characters you want to loose...

        To trim off the end use

        i=10;n=d.name;1.times{n=n.chop};d.name=n;
        

        To trim off the start use

        i=10;n=d.name;n=n[i..-1];d.name=n;
        > 
        

        thanks for your help,much appreciated
        would you please create a file for me with a calling name like
        delete "last_3"
        or
        Delete"frist_5"
        i am able to use the banding "prefix-" script
        i don't know anything about coding
        but your script is what i was looking for and need

        1 Reply Last reply Reply Quote 0
        • TIGT Online
          TIG Moderator
          last edited by

          Copy/Paste this code into the Ruby Console to rename all of the model's definitions, with 3 characters off the end of their names - change i=3 to another value as desired...

          m=Sketchup.active_model;m.start_operation('chop defns',true);c=0;m.definitions.each{|d|i=3;n=d.name;(1.times{n=n.chop};d.name=n;c+=1)};puts"#{c} definition-names chopped.";m.commit_operation;
          

          Or use this code to strip 5 characters off the names' beginnings - again edit i=5 as desired...

          m=Sketchup.active_model;m.start_operation('trim defns',true);c=0;m.definitions.each{|d|i=5;n=d.name;n=n[i..-1];d.name=n;c+=1)};puts"#{c} definition-names trimmed.";m.commit_operation;
          

          TIG

          1 Reply Last reply Reply Quote 0
          • 1
          • 2
          • 2 / 2
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement