by Matt666 » Mon Mar 16, 2009 3:37 pm
Hi all! Here is a set of tools to play with components and groups. It can : - Make a group of just one entity (right click or menu plugins/Make group)
- Make a component instance of just one entity (right click or menu plugins/Make component)
- Convert each entity in the selection in a single group (right click or menu plugins/Convert on single groups)
- Convert each entity in the selection in a single component (right click or menu plugins/Convert on single components)
- Convert the selected component into a group (right click or menu plugins/Make group)
SU has a native tool to convert a group into a component. That's all! 
-
Matt666
-
- Posts: 830
- Joined: Wed Dec 05, 2007 8:38 am
- Location: 48.1184, -1.675
- Name: Matt
-
by pilou » Mon Mar 16, 2009 3:49 pm
For study in deepth components groups 
-

pilou
- Top SketchUcator
-
- Posts: 21116
- Joined: Wed Jan 23, 2008 10:33 pm
- Name: Pilou
- Operating system: Windows
- SketchUp version: 2017
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Advanced
-
by MALAISE » Mon Mar 16, 2009 3:58 pm
Useful, but carefully select entities
Thanks Matt
MALAISE
La Connaissance n'a de valeur que partagée
-

MALAISE
-
- Posts: 653
- Joined: Sun Apr 20, 2008 1:23 pm
- Location: Carrières/Seine FRANCE
- Name: MALAISE
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Advanced
by leixing » Tue Mar 17, 2009 4:32 pm
it does not work if i use the first and second item. the sketchup is dead!! please tell me why or make a example. thanks!
-
leixing
-
- Posts: 27
- Joined: Fri Apr 11, 2008 9:24 am
by Matt666 » Wed Mar 18, 2009 9:16 pm
Sorry for the delay! Aille... I tested it more deeper, and yes, SU crashes... Sorry. I don't know why.I will investigate. Thank you for the feedback!
-
Matt666
-
- Posts: 830
- Joined: Wed Dec 05, 2007 8:38 am
- Location: 48.1184, -1.675
- Name: Matt
-
by su30 » Thu Mar 26, 2009 4:21 am
Hi Matt,
Your script make sense! and it reminds me an idea, I wish there will be a plugin: First we draw single lines, then we select a component, I hope the plugin can make each single straight line into a component, the length of the line will define the scale of the component.
I don't know if it is possible, but I know it will also make big sense!
Su30
su30
-
su30
-
- Posts: 26
- Joined: Fri Sep 19, 2008 3:08 am
by CadFather » Tue Mar 31, 2009 12:07 am
Hi Matt - i think this script is great - hope you can find the crash fix sometime Cheers..
-

CadFather
- PluginStore Author

-
- Posts: 1032
- Joined: Fri Nov 16, 2007 11:03 am
- Location: London, Milano, Sicily
- Name: CadFather
- Operating system: Windows
- SketchUp version: 2014
- License type: Pro
- SketchUp use: landscape architecture
- Level of SketchUp: Advanced
-
by TIG » Tue Mar 31, 2009 1:43 pm
Try this viewtopic.php?p=145009#p145009- Code: Select all
componentInstance.add_entities(entities,copy,unique)
it might help you avoid the BugSplatting... .
TIG
-

TIG
- Global Moderator
-
- Posts: 20275
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 2021
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by CadFather » Tue May 19, 2009 8:45 am
Hi Matt, hope you are so bored one of these days that you will pick this script up again! cheers
-

CadFather
- PluginStore Author

-
- Posts: 1032
- Joined: Fri Nov 16, 2007 11:03 am
- Location: London, Milano, Sicily
- Name: CadFather
- Operating system: Windows
- SketchUp version: 2014
- License type: Pro
- SketchUp use: landscape architecture
- Level of SketchUp: Advanced
-
by Matt666 » Tue May 19, 2009 11:00 am
Hi CadFather! The problem is that working on components generates lots of problems... It's very hard for me. I try sometimes, but slowly!
-
Matt666
-
- Posts: 830
- Joined: Wed Dec 05, 2007 8:38 am
- Location: 48.1184, -1.675
- Name: Matt
-
by CadFather » Tue May 19, 2009 11:13 am
..take all the time you see fit Matt, i might post a request as well..cheers!
-

CadFather
- PluginStore Author

-
- Posts: 1032
- Joined: Fri Nov 16, 2007 11:03 am
- Location: London, Milano, Sicily
- Name: CadFather
- Operating system: Windows
- SketchUp version: 2014
- License type: Pro
- SketchUp use: landscape architecture
- Level of SketchUp: Advanced
-
by Matt666 » Tue May 19, 2009 11:18 am
-
Matt666
-
- Posts: 830
- Joined: Wed Dec 05, 2007 8:38 am
- Location: 48.1184, -1.675
- Name: Matt
-
by mac1 » Tue May 18, 2010 6:46 pm
Matt666 wrote:Hi all! Here is a set of tools to play with components and groups. It can : - Make a group of just one entity (right click or menu plugins/Make group)
- Make a component instance of just one entity (right click or menu plugins/Make component)
- Convert each entity in the selection in a single group (right click or menu plugins/Convert on single groups)
- Convert each entity in the selection in a single component (right click or menu plugins/Convert on single components)
- Convert the selected component into a group (right click or menu plugins/Make group)
SU has a native tool to convert a group into a component. That's all! 
* Edit post * Report this post * Reply with quote Make_Comonents.rb Version 1.1 Does Not Run All the Time Postby mac1 on Tue May 18, 2010 10:30 am System Windows xp sp3 SU as noted below P4 3.2GHz Intel 865 PERL Mother Board, 4 GB Memory I have been attempting to convert the file ref in this link http://www.google.com/support/forum/p/s ... 94ef&hl=en ( file: http://sketchup.google.com/3dwarehouse/ ... 2514717f00 )to components but the script usually converts the first group and quits but, some times it will convert correctly. Ii have not been able to find the initial conditions to repeat the success case. When the failure occurs the ruby console reports this: Error: #<NoMethodError: undefined method `definition' for #<Deleted Entity:0x60ad9f0>> F:/PROGRA~1/Google/GOOGLE~1/Plugins/Make_Components.rb:140:in `make_components' F:/PROGRA~1/Google/GOOGLE~1/Plugins/Make_Components.rb:135:in `each' F:/PROGRA~1/Google/GOOGLE~1/Plugins/Make_Components.rb:135:in `make_components' F:/PROGRA~1/Google/GOOGLE~1/Plugins/Make_Components.rb:48 F:/PROGRA~1/Google/GOOGLE~1/Plugins/Make_Components.rb:48:in `call' I have uninstalled all ruby scripts except the ones loaded with the basic SU installation also removed SU 6. the failure repeats with both SU 7.0+ and SU 7.1 both with clean installs. I have tried a repair install with both SU 7's but cannot because of a missing msi file Any Suggestions??
-
mac1
- Top SketchUcator
-
- Posts: 881
- Joined: Wed Apr 16, 2008 4:05 pm
- Location: Colorado
- Name: mac1
- Operating system: Windows
- SketchUp version: 2015
- License type: Free/Make
- SketchUp use: woodworking
- Level of SketchUp: Intermediate
by mac1 » Tue May 18, 2010 7:07 pm
Update Noted during my post the ruby console error report is different ( in the ref. help forum) that what was obtained in the last attempt to covert the groups. Line number ref are different by one and the entity octal number is different. Removed script, download from Matt's link above and reloaded with same result. 
-
mac1
- Top SketchUcator
-
- Posts: 881
- Joined: Wed Apr 16, 2008 4:05 pm
- Location: Colorado
- Name: mac1
- Operating system: Windows
- SketchUp version: 2015
- License type: Free/Make
- SketchUp use: woodworking
- Level of SketchUp: Intermediate
by Chris Fullmer » Tue May 18, 2010 7:35 pm
I looked over his code and there seems to be an error that pops up when you only have groups selected. Try running the script with always a non-group in the selection - like just draw a line and then select it along with the groups, then run the script. I think that will by pass the problems.
Chris
-

Chris Fullmer
- SketchUp Team

-
- Posts: 6929
- Joined: Wed Nov 21, 2007 3:21 am
- Location: Boulder, CO
- Name: Chris Fullmer
- Operating system: Windows
- SketchUp version: 2013
- License type: Pro
- SketchUp use: landscape architecture
- Level of SketchUp: Advanced
-
by mac1 » Tue May 18, 2010 11:31 pm
Chris Fullmer wrote:I looked over his code and there seems to be an error that pops up whn you only have groups selected. Try running the script wil always a non-group in the selection - like just draw a line and then select it along with the groups, then run the script. I think that will by pass the problems.
Chris
Thanks, nothing to it when you know what you are doing  BTW the line gets converted to component also 
-
mac1
- Top SketchUcator
-
- Posts: 881
- Joined: Wed Apr 16, 2008 4:05 pm
- Location: Colorado
- Name: mac1
- Operating system: Windows
- SketchUp version: 2015
- License type: Free/Make
- SketchUp use: woodworking
- Level of SketchUp: Intermediate
by brookefox » Wed May 19, 2010 1:40 am
The utility of this script is beyond me. I will keep my head down in hopes that someone will post some uses.
~ Brooke
-

brookefox
-
- Posts: 826
- Joined: Thu Jun 26, 2008 4:17 pm
- Location: Pacific northwest, USA
- Name: Brooke
- Operating system: Windows
- SketchUp version: 8
- License type: Free/Make
- SketchUp use: architecture
- Level of SketchUp: Intermediate
by mac1 » Thu May 20, 2010 5:24 pm
brookefox wrote:The utility of this script is beyond me. I will keep my head down in hopes that someone will post some uses.
Very simple at least for me. A post in the Sketchup help forum having problems with file size had numerous groups with the same geo.( An example is shown in the ref test file I included with my post.) has a file size of ~930KB. If one converts to components, then uses the browser "replace selected" capability that goes down to around ~70KB. A significant reduction in my mind. If one looks at the model info stats report the edges and faces don't change that much. It was my feeble attempt to understand the imapct of max use of components which is often stated but not quantified.  BTW I will on occasion place a very simple component in my model(s), have even used a line ( not a good idea), then recognizing a components definition is invariant under move, scale and rotation one can latter replace with a complex model which gets added to the model at the scale, location and rotation of the simple model( need to pay attention to your component axis)
-
mac1
- Top SketchUcator
-
- Posts: 881
- Joined: Wed Apr 16, 2008 4:05 pm
- Location: Colorado
- Name: mac1
- Operating system: Windows
- SketchUp version: 2015
- License type: Free/Make
- SketchUp use: woodworking
- Level of SketchUp: Intermediate
by brookefox » Sat May 22, 2010 7:02 pm
Thanks for yor response. This use I get but for it I don't need this plugin: problems with file size had numerous groups with the same geo.
One can make components out of groups and instances of groups this with native SU. It's the making of components out of lines that I don't get much of. So for your 'simple' best use you would have a lot of lines in your models which are not parts of components, and making them components with this would reduce your file size. OK. I do have a lot of groups which are not components, but next to no lines which are not parts of groups or components. For me the crux is when and what groups to componetize, just because it take time, even if it saves file space. Certainly if I have many of said group or I want component behavior from a group it would be best componentized, I don't need a plugin to do that. Rereading the thread I see the use implied of maybe wanting to populate a model with lines, componetize them and then subsequently edit the component which would then be in place wherever the lines were. If I can do this now with two lines instead of one, that is sufficient for me.
~ Brooke
-

brookefox
-
- Posts: 826
- Joined: Thu Jun 26, 2008 4:17 pm
- Location: Pacific northwest, USA
- Name: Brooke
- Operating system: Windows
- SketchUp version: 8
- License type: Free/Make
- SketchUp use: architecture
- Level of SketchUp: Intermediate
by mac1 » Sun May 23, 2010 5:03 am
brookefox wrote:Thanks for yor response. This use I get but for it I don't need this plugin: problems with file size had numerous groups with the same geo.
One can make components out of groups and instances of groups this with native SU. It's the making of components out of lines that I don't get much of. So for your 'simple' best use you would have a lot of lines in your models which are not parts of components, and making them components with this would reduce your file size. OK. I do have a lot of groups which are not components, but next to no lines which are not parts of groups or components. For me the crux is when and what groups to componetize, just because it take time, even if it saves file space. Certainly if I have many of said group or I want component behavior from a group it would be best componentized, I don't need a plugin to do that. Rereading the thread I see the use implied of maybe wanting to populate a model with lines, componetize them and then subsequently edit the component which would then be in place wherever the lines were. If I can do this now with two lines instead of one, that is sufficient for me.
Glad you are happy with what you have that is what is important. The plugin is just another wrench in the tool box. You are correct SU has that native capability but what are you going to do if you have say a 100 groups and identical. The native tool will make a component out of all of them but the reduction of file size doing that will be nil. My test case was not suppose to be a global analysis of a model having a mix of various entities and was meant to show what poor modeling practice can cost one. The model has 33 groups and nested in each of those is three groups( all identical) and some other simple entities a really a simple model. If you examine one of those and expolde the component the change in file size is nil so the the message is use components but having a bunch of nested groups in the components does not help much Gday
-
mac1
- Top SketchUcator
-
- Posts: 881
- Joined: Wed Apr 16, 2008 4:05 pm
- Location: Colorado
- Name: mac1
- Operating system: Windows
- SketchUp version: 2015
- License type: Free/Make
- SketchUp use: woodworking
- Level of SketchUp: Intermediate
by artmusicstudio » Wed Nov 06, 2013 5:17 pm
hello, i went thru all topics dealing with component naming, but i cannot find a solution.
i would like to give a name to a created component by this code:
######## start code
model = Sketchup.active_model entities = model.active_entities rl1 = [0, y1, 0] rl2 = [0, y2, z] group = entities.add_group entities2 = group.entities new_line = entities2.add_line rl1, rl2 length = new_line.length centerpoint = rl1 # Create a circle perpendicular to the normal or Z axis vector = rl2 vector2 = vector.normalize! edges = entities2.add_circle centerpoint, vector2, $thradius kreis = entities2.add_face edges kreis.pushpull -(5/$faktor)/100 $masterrailingtms = group.to_component # HERE I WOULD LIKE TO DEFINE A NAME FOR THIS NEW COMPONENT, WHICH I CAN SEE IN IN SKP ENTITY-INORMATION-WINDOW. this name also hopefully appears in the copied instances of this component, but most important is the name for component [0]
######## end code
can somebody help me? thanx stan
-

artmusicstudio
- PluginStore Author

-
- Posts: 207
- Joined: Fri Jul 23, 2010 2:35 pm
- Name: artmusicstudio
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Intermediate
-
by TIG » Wed Nov 06, 2013 6:41 pm
Your xxxx = group.to_component refers to an component-instance NOT a component-definition: so to find the instance's definition use: defn = xxx.definition then rename it thus: defn.name = "foo_fighter" Be aware if there is already a 'foo_fighter' definition it'll become 'foo_fighter#1' etc
PS: don't use global $var variables which will potentially clash with others tools - wrap your code in your own module and use @var instead.
TIG
-

TIG
- Global Moderator
-
- Posts: 20275
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 2021
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by artmusicstudio » Thu Nov 07, 2013 10:48 am
hi tig, thanx, this work well, one step further for me, now i can identify the "children" of the masters exactly. that's perfect. just to understand exactly: a name of component instance defined by this method appears in the field "description"
a group named by group.name = "xxx" appears in the filed "name"
is there also a way to NAME a component or its instance besides a description?
thanx stan
-

artmusicstudio
- PluginStore Author

-
- Posts: 207
- Joined: Fri Jul 23, 2010 2:35 pm
- Name: artmusicstudio
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Intermediate
-
by TIG » Thu Nov 07, 2013 11:27 am
Both components and groups [and also images for that matter] that you see placed inside a model are instances of their 'definition'.
Every 'definition' has a unique definition.name - this can be reset provided it is unique - if 'xxx' is already used SketchUp auto-increments the name as 'xxx#1' etc. For a component that is the 'Definition Name' displayed in Entity Info, the Component-Browser's top-most field, and in the Outliner as <defname>. A component-instance can also have a instance.name this the 'Name' displayed in Entity Info, and in the Outliner as name<defname>. This need not be assigned and it does not need to be unique. You can find defn = instance.definition etc.
A group also has a unique definition.name that is usually hidden from the user - something like 'Group#99'. You can change this through the API to another unique definition.name - but for what purpose? There is also group.name - akin to the instance.name. This need not be assigned and it does not need to be unique. This is the 'Name' displayed in Entity Info and in the Outliner [if the Name=='' then the Outliner says 'Group'] You cannot directly find a group.definition in the API, BUT defn = group.entities.parent should return its definition.
The definition.description can be assigned and for a component appears this in the second-from-top field in the Component-Browser. Although you can assign a definition.description to a group it is not seen anywhere by a user - it is only accessible through the API.
When you convert a group to a component the name of the component definition is taken as the group's definition.name [e.g. 'Group#666'] NOT the group.name. What is returned by the group's conversion to a component is an instance NOT a definition, so to find the definition itself use the code given in the earlier reply. Then you can use defn.name='xxxx' as desired...
TIG
-

TIG
- Global Moderator
-
- Posts: 20275
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 2021
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by plot-paris » Wed Jul 27, 2016 1:30 pm
is there a Version that works with SketchUp 2016?
Bulk conversion of components to groups doesn't seem to be working (and is sorely needed when importing a 3ds-model, where every object is a component)
-

plot-paris
-
- Posts: 1573
- Joined: Tue Apr 01, 2008 10:15 am
- Location: Konstanz, Germany
- Name: plot-paris
- Operating system: Windows
- SketchUp version: 2016
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by Mooeee » Sat Jul 15, 2017 10:30 pm
Is there any news as to whether this plugin will be updated to SketchUp 2017 as it looks a really useful plugin, or is there a similar plugin out there to use.
-
Mooeee
-
- Posts: 2
- Joined: Mon Aug 18, 2008 7:35 pm
by sdmitch » Sun Jul 16, 2017 3:27 pm
plot-paris wrote:Bulk conversion of components to groups doesn't seem to be working (and is sorely needed when importing a 3ds-model, where every object is a component)
Here is a code snippet you can try. Paste it into the Ruby Console and press Enter. It will convert all Component instances in the selection to a group. - Code: Select all
@mod = Sketchup.active_model @ent = @mod.active_entities @sel = @mod.selection @vue = @mod.active_view cmps = @sel.grep(Sketchup::ComponentInstance) cmps.each{|ci| grp = @ent.add_group(ci) grp.name = ci.definition.name ci.explode } @mod.definitions.purge_unused
-

sdmitch
- PluginStore Author

-
- Posts: 1496
- Joined: Wed Mar 02, 2011 9:21 pm
- Name: sdmitch
- Operating system: Windows
- SketchUp version: 2014
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Beginner
by Box » Sun Jul 16, 2017 3:58 pm
Hopefully Plot will enjoy your post even though it is 1 year later.
-

Box
-
- Posts: 5017
- Joined: Mon Jun 07, 2010 1:55 pm
- Location: Sydney
- Name: Box
- Operating system: Windows
- SketchUp version: 2020
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Intermediate
-
by sdmitch » Sun Jul 16, 2017 4:38 pm
Box wrote:Hopefully Plot will enjoy your post even though it is 1 year later.
DOH!!!
-

sdmitch
- PluginStore Author

-
- Posts: 1496
- Joined: Wed Mar 02, 2011 9:21 pm
- Name: sdmitch
- Operating system: Windows
- SketchUp version: 2014
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Beginner
by faust07 » Wed Mar 06, 2019 1:09 am
Thanks sdmitch, used your code snippet to convert components to groups for MSPhysics. The reason is that MSP does not accept components for coupling with joints. The conversion of about 200 components with subcomponents into groups would have taken a long time...
-
faust07
-
- Posts: 510
- Joined: Tue Aug 25, 2009 3:26 pm
- Location: Germany
- Name: Faust07
- Operating system: Windows
- SketchUp version: 2017
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Intermediate
by Ad Machine » 5 minutes ago
-
Ad Machine
- Robot
-
- Posts: 2012
-
Return to Plugins
|