[Plugin] Select component instances on right click

[Plugin] Select component instances on right click

Postby confitex architure » Sun May 18, 2008 10:58 am

Hi there,

You'll find a short .rb files that select component instances on the fly.
You just have to select one or more different components one your model, right click and choose "Select Instances" on the drop down menu.
I tought it would be faster to attach this plugin on this drop down menu.
Rather than to go on your "Component window" with this bunch of compo, and hunt for the one you need to select in the entire model, this plugin should simplify.

NEW Version 2:
This new version includes a new function that is "Select Families" on right click.
A family would be a bunch of components that were created by making a parent compo unique.
Every component name that begins with the same name before the '#' will be considered as part of the family. Capisci? 8-)

So just create a component, copy it a couple of time, make one of the instance unique, select any of the created component and right click "Select families".

Enjoy!
6
Last edited by confitex architure on Mon Jun 02, 2008 9:22 am, edited 9 times in total.

confitex architure 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Select component instances on right click

Postby kwistenbiebel » Sun May 18, 2008 12:05 pm

That is really handy!

Thank you very much.
0

kwistenbiebel 
 

Re: [Plugin] Select component instances on right click

Postby Didier Bur » Sun May 18, 2008 5:29 pm

Hi,

Very handy. May I suggest to change last line of the script
Code: Select all
file_loaded "fr_cleanup.rb"
to
Code: Select all
file_loaded "select_instance.rb"

and it would be nice to have the option in the context menu ONLY if selection is not empty AND all objects selected are components.

For instance, the following function should do it:

Code: Select all
def compos_valid_selection
s=Sketchup.active_model.selection
return false if s.empty?
types=[]
s.each { |e| types.push(e.typename) }
types.uniq!
return false if types.length != 1
return false if types[0]!= "ComponentInstance"
return true if types[0]== "ComponentInstance"
end


Then in the menu definition:
Code: Select all
UI.add_context_menu_handler do |menu|
  if compos_valid_selection
  menu.add_separator
  menu.add_item("Select Instances") { select_component_instance }
  end
end

Regards,
0
Didier Bur (Bytes Farmer)
Ecole Nationale Supérieure d'Architecture de Nancy (F)
http://rld.crai.archi.fr/rubylibrarydepot/
User avatar
Didier Bur 
 

Re: [Plugin] Select component instances on right click

Postby confitex architure » Tue May 27, 2008 8:07 pm

The new version (v2) has been posted!
See above.
0

confitex architure 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Select component instances on right click

Postby boofredlay » Tue May 27, 2008 9:03 pm

Thank you very much.
0
User avatar
boofredlay 
Global Moderator
 

Re: [Plugin] Select component instances on right click

Postby sepo » Tue May 27, 2008 9:38 pm

I have just tried with simple component. Copied it couple of times and make one unique. Went into component and changed colour of the group (also made unique). In the context menu I have "select instances" but not "select families". I have installed the version 2 from the top of this tread.
Thanks
0

sepo 
 

Re: [Plugin] Select component instances on right click

Postby RickW » Tue May 27, 2008 11:21 pm

Wow, I need to do more marketing! Instances has been available at Smustard for a couple of years, now. :)

You've added some nice additional functionality.
0

RickW 
 

Re: [Plugin] Select component instances on right click

Postby confitex architure » Wed May 28, 2008 7:18 am

sepo wrote: I have installed the version 2 from the top of this tread.
Thanks


Hi sepo, What are the name of your instances? select instances only works when components are selected, no groups allowed in the selection set.
Are you sure you've deleted the first version of the plugin?
0
Last edited by confitex architure on Wed May 28, 2008 3:27 pm, edited 2 times in total.

confitex architure 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Select component instances on right click

Postby confitex architure » Wed May 28, 2008 7:23 am

RickW wrote:Wow, I need to do more marketing! Instances has been available at Smustard for a couple of years, now. :)

You've added some nice additional functionality.


Oops, I wish I could know this a couple of years ago :?
Thanks Rick!
0

confitex architure 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Select component instances on right click

Postby watkins » Wed May 28, 2008 7:37 am

Dear Rick,

I have been using your script for quite a while now, and find it very useful. Particularly for making arrays of holes. I draw the first circle on the surface and then make it a component - say Hole_1. I then use move and copy to array the component on the surface. Then I select one of the hole components and go to "select instances". I then explode the components which makes all the circles sink nicely into the surface (no need to trace over circles). This is followed by the push/pull tool to drive the holes through the component (double click if uniform thickness).

Thanks once again.

Regards,
Bob
0

watkins 
 

Re: [Plugin] Select component instances on right click

Postby sepo » Wed May 28, 2008 1:11 pm

OK found the culprit. Did not remove old selectinstance.rb. Now have the select families and it works like charm.... Thanks for very useful script.

Coen :) did not get your comment.
0

sepo 
 

Re: [Plugin] Select component instances on right click

Postby Jorgensen » Wed May 28, 2008 2:28 pm

Would it be possible to change the script so that it don't select instances that are hidden, or instances that are on a hidden layer ?

Just an idea, don't know if others have this need :-)

Thanks
Jorgensen
0
sketchup pro 2016 16.1.1449 64 bit | windows 10 pro | i7-3770k @3.5 GHz | 16gb ram | gtx 780 ti / gtx 980 ti | nvidia driver 368.39

Jorgensen 
 

Re: [Plugin] Select component instances on right click

Postby confitex architure » Wed May 28, 2008 3:06 pm

Jorgensen wrote:Would it be possible to change the script so that it don't select instances that are hidden, or instances that are on a hidden layer ?


Yes it is. It's even far better. The link on the first post has been refreshed
0

confitex architure 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Select component instances on right click

Postby Morpeth » Sat May 31, 2008 12:11 pm

very impressed.
0

Morpeth 
 

Re: [Plugin] Select component instances on right click

Postby JClements » Sat May 31, 2008 5:17 pm

Doesn't work for me for the Families.

If I select either a unique component version or the original component, right-click, choose Families from the menu the result is that the geometry is DESELECTED.

I copied the script at the top of the posting 31 May 08 (a.m.).

Also, note that the there are two .rb's listed in the script, one with "v2", the other without.
0
John
Illustrator
Beaverton, Oregon
User avatar
JClements 
Premium Member
Premium Member
 

Re: [Plugin] Select component instances on right click

Postby confitex architure » Sat May 31, 2008 11:10 pm

Hi John,
I don't understand what's wrong with the list. Do you mean in your plugins folder? You should erase the former version, the one without the "v2", from this folder.
I tried again and again and everything is ok on my side. What are the name of your components ?
0
Last edited by Gaieus on Sun Jun 01, 2008 2:25 pm, edited 1 time in total.
Reason: Deleted double post

confitex architure 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Select component instances on right click

Postby JClements » Sun Jun 01, 2008 12:26 am

This is a copy of part of the script's code. See the reference to the .rb in the 1st and last line:

if (not file_loaded?("select_instance.rb") )
UI.add_context_menu_handler do |menu|
if compos_valid_selection
menu.add_separator
menu.add_item("Select Instances") { select_component_instance }
menu.add_item("Select Families") { select_component_made_unique }
end
end
end

file_loaded "select_instancev2.rb"


Attached is a test file. Now when I run the script, choosing Select Families recogizes a family component and selects one family instance.

Try right-clicking on each component instant and the choose Select Families; for me the resulting selection always changes to Object B. Is the script intended to work or is it supposed to select all family instances at once?
0
John
Illustrator
Beaverton, Oregon
User avatar
JClements 
Premium Member
Premium Member
 

Re: [Plugin] Select component instances on right click

Postby confitex architure » Mon Jun 02, 2008 6:30 am

Hi John,

Is the script intended to work or is it supposed to select all family instances at once?
:!:

it has been fixed (DL on the first post)
0

confitex architure 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Select component instances on right click

Postby JClements » Mon Jun 02, 2008 7:33 pm

Thank you.
0
John
Illustrator
Beaverton, Oregon
User avatar
JClements 
Premium Member
Premium Member
 

Re: [Plugin] Select component instances on right click

Postby Abdullah » Fri Jan 27, 2012 8:58 am

Hi,
I want to select multiple components with similar definition names (like "compo" and "comp#1") in the entire Model. It means, it means not only those inside the selected object, but also the others ones which are inside other objects.

I have the following plugins:
[*] "Selection Toys", which selects components from everywhere, but only those with same name.
[*] "Select Instances", which selects component families with similar names (like "compo" and "comp#1"), but only inside the selected object and not everywhere.
0

Abdullah 
 

Re: [Plugin] Select component instances on right click

Postby TIG » Fri Jan 27, 2012 12:06 pm

Take care making selection sets that span different contexts - you can Bugsplat it you try to manipulate them !
To select instances of similar named definitions this will work
Code: Select all
n="match";m=Sketchup.active_model;s=m.selection;s.clear;m.definitions.each{|d|s.add d.instances if d.name=~/#{n}/}
Change the string 'match' within the "" to the pattern match you want - I suggest that you read-up of pattern-matching - e.g. n="[Cc]at" finds all definitions like 'Cat', 'cat1', 'tomcat', whereas anchoring the pattern to the start/end like this n="^[Cc]at" only matches 'Cat and 'cat1', or n="m[Cc]at$" to only matches '#tomcat' and 'TomCat'...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Select component instances on right click

Postby Abdullah » Fri Jan 27, 2012 2:55 pm

It didn't work first, because there was a "$" in the string (it looked like "abc$match"), so took only the part after "$" (and it looked like "match")and it work well. Thank you very much.

By the way, are there any "good" Sketchup Ruby Tutorials/Books for Beginners? I would really like to learn it.
0

Abdullah 
 

Re: [Plugin] Select component instances on right click

Postby TIG » Fri Jan 27, 2012 4:07 pm

Abdullah wrote:It didn't work first, because there was a "$" in the string (it looked like "abc$match"), so took only the part after "$" (and it looked like "match")and it work well. Thank you very much.
By the way, are there any "good" Sketchup Ruby Tutorials/Books for Beginners? I would really like to learn it.
Look for Automatic Sketchup - as a pdf or a to-buy hard-copy.
There are also several other links in the "developers' forum"...
If you place a $ at the very end it says the pattern ends there.
If you want to search for a '$' inside the text escape it '\$'; same with the '^' which marks the very beginning.
Here's a short guide to pattern matching... http://www.tutorialspoint.com/ruby/ruby ... ssions.htm
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Select component instances on right click

Postby John_C » Tue Jan 22, 2013 12:47 am

That's great, thanks ... :)
0

John_C 
 

Re: [Plugin] Select component instances on right click

Postby fullyfledgeded » Sun Mar 24, 2013 6:27 pm

Hi, Is there any way of selecting component families even if they are in groups or nested within other components? The only way i can get it to work with this plugin is if i explode until all desired components are no longer grouped or component nested.
0

fullyfledgeded 
 

Re: [Plugin] Select component instances on right click

Postby fullyfledgeded » Tue Mar 26, 2013 1:16 pm

Thanks TIG and Abdullah for sorting out a that code :bounce: I was frantically, searching the forum for a solution that i missed this code.

Alot of my component instances, have annoyingly renamed, with #1, #2 etc added to them, ultimately creating new component definitions, increasing file size :x

now that i can select multiple instances at once, I can replace them with one component definition.

However I still don't why this is happening, other people have this problem too:

viewtopic.php?f=15&t=22523

might start a new post to see if there is any more info

cheers
0

fullyfledgeded 
 

Re: [Plugin] Select component instances on right click

Postby smicha » Sat Apr 27, 2013 7:46 am

Great plugin. Thanks
0

smicha 
 

Re: [Plugin] Select component instances on right click

Postby Sir » Fri Jun 19, 2015 11:04 am

fantastic plugin. extremely useful.

thanks
0

Sir 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Plugins

Who is online

Users browsing this forum: dtrarch, mikehathaway, pablocarol and 9 guests

Visit our sponsors: