[Plugin] Select component instances on right click
-
That is really handy!
Thank you very much.
-
Hi,
Very handy. May I suggest to change last line of the script
file_loaded "fr_cleanup.rb"
to
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:
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:
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,
-
The new version (v2) has been posted!
See above. -
Thank you very much.
-
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 -
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.
-
-
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 -
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.
-
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 -
@jorgensen said:
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
-
@sepo said:
I have installed the version 2 from the top of this tread.
ThanksHi 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? -
very impressed.
-
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.
-
This is a copy of part of the script's code. See the reference to the .rb in the 1st and last line:
@unknownuser said:
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
endfile_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?
-
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 ? -
Hi John,
@unknownuser said:
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)
-
Thank you.
-
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. -
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 workn="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'...
Advertisement