Making a group out of everything in a component definition
-
We wanted to take all the exiting geometry in a component definition, and put it in a group within the same component definition, so that we could put the new group in a layer, which made it easy to turn off a layer to hide all of the existing geometry. (This was part of our project to convert hi-poly components so that they could be displayed as lo-poly proxies just by turning layers on and off)
We came up this this logic:
(I thought I would share this here in case anyone ever need to perform a similar task)-
Make a new dummy component instance with the same definition as the original component
-
Make the dummy component instance unique. (It now has a cloned copy of the geometry in the original component definition)
-
Erase the geometry from the definition of the original component.
-
Add a group to the original component definition and give it the layer desired.
-
Place an instance of the dummy component into the group in the original component.
-
Explode the instance, in the group in the original component definition.
- (You can also add additional information to the original component - such as the low-poly geometry.)
- Erase the dummy component instance and the dummy component definition.
(I was not able to figure out how to remove a component instance - I used purge_unused instead)
Here is a sample ruby script which does this:
This seems to work well, but is rather complicated.
Is there some easy way to do this that I am missing?
-
-
- Edit the component.
- Select all of the geometry of the component and "copy" which will copy it all to the clipboard.
- Create one simple segment, still within the component, and Make a group out of it. ( I don't believe that the "right click" works to get the "make group" option when you only have a single segment so you will need to use the "make group" option under the edit menu or, if you have one, a keyboard shortcut".
- Edit the group.
- Erase the segment that you didn't need anyway, and choose "paste in place" from the edit menu. This will place the geomtry in the clipboard inside the group.
- Close the group and associate the group with whatever layer you want.
- Do whatever you need to do with the component geometry outside the group and inside the component.
-
@sorgesu said:
- Edit the component.
- Select all of the geometry of the component and "copy" which will copy it all to the clipboard.
I;m not sure how to emulate "Edit Component" from a ruby script.
Ditto, for copy and paste.
-
can't help there. I have no clue how to do a ruby.
I know for a fact that edit component is possible since I own a ruby that does that.
I have posted it once before. It is called cleanimage.rb and it edits a component and hides all the lines.I have uploaded it here
Perhaps you can deconstruct the ruby to see the way to "edit component". I have nothing that does a "paste in place" that I am know of, but I'm sure one of the guys here who do ruby scripts can be of help.
-
Sorry Al. I didn't even notice that it was in the Ruby forum since I always view "active topices".
I also thought you wanted both the "group" as well as the component. Sorry about that. I'll leave the ruby queries to the ruby experts and I'll make sure to check which forum the question comes from. -
I appreciate your trying to help, Susan, but I put this query in the ruby forum because I was soliciting help from other ruby programmers on how best to do this task.
It is easy in SketchUp itself, as you point out, although probably even easier than you suggest because you can probably:
- Open the component for edit
- Select all the geometry in the component
- Right click and select Make group
and you have the group.
My problem is that this is much more difficult in Ruby, unless there is a ruby command for #1 and #3 (there is a one line command for #2)
Again, though, thanks for offering your help.
Advertisement