Is there a plugin that will copy a component separately?
-
I've had reason to do something that might work for you. No plugins required. Let's say you have a bunch of copies of 'Component #1' in your model and they are on a layer, 'Comp1'. Elsewhere in your model you've taken a copy of 'Component #1', made it unique edited it and renamed it 'Component #2' You also have a layer called 'Comp2'
In the In Model Components library, right click on the thumbnail or list entry for 'Component #1' and choose "Select instances". Hit Ctrl+C (Edit>Copy). Leave the instances selected. Next, in Entity Info, change the layer association to 'Comp2'. The instances should still be selected. Back in the In Model library, right click on the thumbnail for Component #2 and choose "Replace Selected." Finally, hit Edit>Paste in Place. You'll now have 'Component #1' on 'Comp 1' and 'Component #2' on 'Comp2'
It sounds really difficult but it really goes very rapidly. The key thing to remember if the location of the components is important is that their insertion points (origins) must be in the same relative location.
-
Is this the same?: Select a component#1. Right click-"instances / select instances", copy, paste in-place, right click-"make unique". Move to layer #2.
It is best to use the "Add hidden layer" plugin if you do not already have that Layer #2, so you don't have to reset your existing scenes.
-
@unknownuser said:
I wonder if there's a plugin out there that would do this for me so that when I clone Option 1 it makes all of the components in Option 2 unique so they reference eachother, but not the components from option 1.
The following code creates a unique copy of component#1 and names it component#2. It then places a copy of component#2 at each location of component#1.
mod = Sketchup.active_model ent = mod.active_entities sel = mod.selection defs=mod.definitions comp1=defs["Component#1"] copy1=ent.add_instance(comp1,Geom;;Transformation.new()) copy1.make_unique copy1.definition.name="Component#2" comp2=copy1.definition copy1.erase! for i in comp1.instances ent.add_instance(comp2,i.transformation) end
-
You know, you don't have to use add_instance to change the definition. ComponentInstance.definiton= is a setter you can use to replace the definition used for an instance.
-
I think the issue with each of the solutions is nested components. My example may have been a bit too simplistic. The reality is that I have an overall building (Option 1) that has some nested components within (some walls, tables, windows, etc.), and within those are other components (doors, accessories, etc.).
So if I were to do this manually, I'd copy the overall building component, paste-in-place, make unique. Then I'd go into that component and make the nested components unique so that when I change what's inside it doesn't affect Option #1. Then I have to go into each of those components and select the nested components within for the same reason. And if I accidentally don't make something unique (which happens), then I end up not finding out until I happen to go back and turn on the Option 1 layer (thank goodness for archives and autosaves).
From what I gather, none of the solutions suggested really goes into the nested components at all.
-Brodie
-
Good golly, Brodie. It sounds to me as if you might find it useful to look seriously at your nesting practices. I'm thinking you could get by with much less of it and make your work a whole lot easier.
-
I could perhaps do with a bit less nesting but in general it's a pretty good workflow for what I'm working with. It helps me to group things and make fewer changes. I work with a lot of symmetry so, for example, I can use components to build one side of the building's walls and then mirror it to the other side. Then if I nest some tables in there, those will mirror over as well. And if I have a group of 4 similar tables that's scattered around each option I can make a component of those nested within the mirrored component. It makes future changes much quicker.
The only real downside, other than the current topic, is having to click down to the bottom of the nest. Luckily I've got a programmable gaming mouse so I was able to set up a button that basically performs about 10 left-mouse clicks
-Brodie
-
If (once you establish your primary Unique component) you edit the component in a separate source file (always use a separate file for editing), the nested components that are modified will be given a new definition when the component is reloaded. This way nested components that are still identical in the two cases, will remain so in the (what would you call it?) Main File.
Test this. I haven't had that particular need regarding nested components, but it seems to work. IDK if this is a direction you'd take, but I find working on a complex part (component) outside of a Main file, actually relieves complication and speeds the program up.
After all I think you are describing having two scenarios in one file. These components would not be visible at once?
You might try outline to get quickly down to nested components.
-
That's not a bad workaround Peter. I do, in fact, do this on occasion and it works pretty well. Where it sometimes breaks is when in the cases where there's a component that doesn't change and I bring it back in and it's not disassociated with the other similar components in the main file. It's not an issue at that moment, but sometimes, down the road there is a change to one of those components and I have no good way of knowing/remembering that it's linked with another option's components.
Of course, I guess the workaround to that would be to ALWAYS edit the options in another file but at some point the copy/pasting can be pretty time consuming. Plus you sometimes need references that are in the main file so it's nice to just be able to work in there.
I'm not a big fan of outliner. Not of any fault of outliner, I just work with so many components that I don't bother naming them so my outliner dialogue is nonsensical.
-Brodie
-
So you're saying there's a bug or error wherein the component that should be the same has obtained a new definition. But in your original request all the components are unique already so you've lost that connection anyway.
Also you shouldn't copy paste, but Reload. IDK-- a lot of time is saved not dealing with the rest of the model while working on a part such as a single building.
Your point about getting to nested components. Shouldn't there be a context menu (plugin?) that opens the bottom nested component under the mouse? That would be cool.
-
The language is a bit complicated here but I think there's a small miscommunication based on your first point. I'll post a little video illustrating my manual solution. I've copied the Option 2 into another location for illustration purposes but normally it would be overlapping with Option 1 and I would toggle between the 2 options.
https://dl.dropbox.com/u/384281/nested.swf
-Brodie
-
I see. I didn't mean "already", I guess, I meant that what you're suggesting is to make all nested components unique.
The source file technique gives you the option to keep some components the same. But, yes, if you work on the nested components in the main file you run a risk of changing components you don't want changed.
It seems "Make this component unique, including all nested components. Keep all instances the same" is a possible ruby.
-
@pbacot said:
It seems "Make this component unique, including all nested components. Keep all instances the same" is a possible ruby.
Better one-liner than I was able to come up with. Sounds exactly like what I'm talking about. I'd hoped it was already out there and something I'd missed but it sounds like I'll be doing it manually for awhile longer
-Brodie
-
I've been working on house models lately and when I have a window made I often just want to make a new size or modified window of the same style. I usually have nested components. While at times it may serve to leave these components as is, usually I want them all unique to make the new window or door.
"Make this component and all it's nested components unique" would be very helpful for this. If for exambple, you wanted to change a bank of windows (while keeping the old component for use elsewhere), the plugin should work on multiple instances.
-
FredoScale has a function just like this.
-
Oh, I see. I didn't realize. Only problem I have there is it crashes Sketchup half the time, but I think it's the same idea. Thanks. Peter
-
Probably better off highlighting this to Fredo and see if he can address it instead of somebody starting to develop something new from scratch.
(And maybe it's a plugin you have that conflicts...)
Advertisement