sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Mass rename components

    Scheduled Pinned Locked Moved Developers' Forum
    23 Posts 6 Posters 10.2k 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 Offline
      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 Offline
          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