SketchUcation Premium Membership

 

 

[Plugin] Text Tools (0.1.0) — 9 July 2009

[Plugin] Text Tools (0.1.0) — 9 July 2009

Postby thomthom » Thu Jul 09, 2009 1:43 pm

By request of a colleague of mine - he needed to do a search and replace on all Text entities in a model. He had found a plugin that did a search and replace and some more functions - but I only searched the selection or active entities.

This was a quick bash-up of a script to do the job.

Plugins -> Text Tools -> Search and Replace…
Please, register (free) to access all the attachments on the forums.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17595
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Text Tools (0.1.0) — 9 July 2009

Postby TIG » Thu Jul 09, 2009 11:06 pm

Didier Bur did a similar tool some time ago... find_and_replace_text.rb ? In a selection or globally in model...
TIG
User avatar
TIG
Global Moderator
 
Posts: 13970
Joined: Mon Nov 12, 2007 7:24 pm
Location: Northumbria UK
Name: TIG
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Text Tools (0.1.0) — 9 July 2009

Postby thomthom » Thu Jul 09, 2009 11:25 pm

TIG wrote:Didier Bur did a similar tool some time ago... find_and_replace_text.rb ? In a selection or globally in model...

That might have been the script my colleague tried to use.., but it only searched active_entities.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17595
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Text Tools (0.1.0) — 9 July 2009

Postby TIG » Fri Jul 10, 2009 12:04 am

active_entities are the entities in the current edit of the model, group or definition, so that's equivalent to model.entities if it's in the model. It didn't mine into definitions...

That gets me thinking of another method - see below... simply filter the array of entities returned for text and change each bit of text to suit - works in the model, inside groups and components etc... useful for any methods where global change of some types of entities is needed - like layer and material manipulation when model is heavily grouped or componentized ?
Code: Select all
=begin
(c) TIG 2009
'all_entities.rb' adds a new Method to Sketchup's Model Class -
"model.all_entities" - it returns an array of all entities in the model
i.e. model.entities.to_a + definintion.entities [groups and components]...
=end
class Sketchup::Model
  def all_entities
    model=Sketchup.active_model
    all_entities=model.entities.to_a
    model.definitions.each{|d|d.entities.each{|e|all_entities.push(e)}}
    return all_entities
  end#def
end#class
###
TIG
User avatar
TIG
Global Moderator
 
Posts: 13970
Joined: Mon Nov 12, 2007 7:24 pm
Location: Northumbria UK
Name: TIG
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Text Tools (0.1.0) — 9 July 2009

Postby thomthom » Fri Jul 10, 2009 7:11 am

We've got such a method in the SKX library.
That reminds me; I've been meaning to get a first release for SKX out for the stable methods we got.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17595
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago

Are you a Premium Member? Get your freebies here. Are you not a Premium Member yet? Upgrade your account to grab these freebies instantly.

Ad Machine
Robot
 
Posts: 2012


Return to Plugins

Who is online

Users browsing this forum: AndyR, Box, chrislbj, chvlad, francimarmedeiros21, Google Bot, gullfo, Lenain34, McGyver, MSK_001, Nexso, Surik_Arbuzov and 10 guests