sketchucation logo sketchucation
    • Login
    1. Home
    2. jeynay
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    J
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 3
    • Groups 1

    jeynay

    @jeynay

    10
    Reputation
    1
    Profile views
    3
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    jeynay Unfollow Follow
    registered-users

    Latest posts made by jeynay

    • RE: Mass rename components

      @tig said:

      The initial part of the code snippet togo=" - 3D - johnsmith_google_com level 1";
      specifies which string will be deleted in the components' names.
      I you example:
      "4_ Light Fixture - 4_ Light Fixture-1847101- 3D - johnsmith_google_com level 1-01" "4_ Light Fixture - 4_ Light Fixture-1847101- 3D - johnsmith_google_com level 1-02"
      etc
      become
      "4_ Light Fixture - 4_ Light Fixture-1847101-01" "4_ Light Fixture - 4_ Light Fixture-1847101-02"
      etc

      Just edit that to cover what you want to delete...
      So to leave the final 'ref' as say "1-01", you simply change the togo to say:
      togo=" - 3D - johnsmith_google_com level";
      and the renaming is then:
      "4_ Light Fixture - 4_ Light Fixture-1847101 1-01" "4_ Light Fixture - 4_ Light Fixture-1847101 1-02"
      etc

      You choose what's to be deleted...
      You can always run the code a second time with a new togo string, e.g.
      togo="4_ Light Fixture - ";
      Would strip off the duplicated starting reference, leaving:
      "4_ Light Fixture-1847101 1-01" "4_ Light Fixture-1847101 1-02"
      etc

      This worked beautifully!!! thank you much appreciated πŸ˜„

      posted in Developers' Forum
      J
      jeynay
    • RE: Mass rename components

      Thanks for the quick reply TIG.I'm assuming this would rename that portion of component's name as well? for exampe if i have 50 instances like
      "4_ Light Fixture - 4_ Light Fixture-1847101- 3D - johnsmith_google_com level 1-01"
      "4_ Light Fixture - 4_ Light Fixture-1847101- 3D - johnsmith_google_com level 1-02" so on so forth, would i be able to remove the" 3D - johnsmith_google_com level" portion of those instance names?

      Thanks in advance

      @tig said:

      @jeynay said:

      Hi,

      Is there a way to remove certain words from multiple components at the same time?

      for example I have 50 components that their name has "3D - johnsmith_google_com level 1" at the end of the name. like:

      "10016001_S_DLGBldg1_Central_detached_rvt-1-3D - 3D - johnsmith_google_com level 1"
      "4_ Light Fixture - 4_ Light Fixture-1847101- 3D - johnsmith_google_com level 1"
      "Aluminum Sill Extension - Aluminum Sill Extension-2131210-3D - johnsmith_google_com level 1"

      Is there a script that can remove a certain prefix or suffix? or just removing the first/last 15 or 10 characters in the name would also work.

      This issue is very annoying since the models imported from revit to sektchup end up having more than 100 characters. πŸ˜•

      Thanks
      You can batch rename components.
      I assume you mean component-definitions, rather than component-instances which can have individual names based on a shared definition...
      Here's a simple one-liner to do it...
      Edit the initial togo="..."; to suit your needs...

      togo=" - 3D - johnsmith_google_com level 1";m=Sketchup.active_model;m.start_operation('rename defns',true);c=0;m.definitions.each{|d|(d.name=d.name.gsub(/#{togo}/,'');c+=1) if d.name=~/#{togo}/};puts"#{c} definitions renamed.";m.commit_operation;
      

      Paste it into the Ruby Console + <enter>, it's one step undoable...

      posted in Developers' Forum
      J
      jeynay
    • RE: Mass rename components

      Hi,

      Is there a way to remove certain words from multiple components at the same time?

      for example I have 50 components that their name has "3D - johnsmith_google_com level 1" at the end of the name. like:

      "10016001_S_DLGBldg1_Central_detached_rvt-1-3D - 3D - johnsmith_google_com level 1"
      "4_ Light Fixture - 4_ Light Fixture-1847101- 3D - johnsmith_google_com level 1"
      "Aluminum Sill Extension - Aluminum Sill Extension-2131210-3D - johnsmith_google_com level 1"

      Is there a script that can remove a certain prefix or suffix? or just removing the first/last 15 or 10 characters in the name would also work.

      This issue is very annoying since the models imported from revit to sektchup end up having more than 100 characters. πŸ˜•

      Thanks

      posted in Developers' Forum
      J
      jeynay