0
votes

I have a SketchUp model which I have created by importing three other model files. I want to update one of the three underlying model files. If I edit the model and physically import again, I have to spend the time to physically positioning the model again. Is there way to change the underlying model and the higher level model gets updated automatically?

3
SketchUp does not "link" models. If you import, that model is brought fully into the scene and there is no connection to its original source.avariant

3 Answers

1
votes

You don't need to do this programmatically - you can do it within Sketchup itself.

  1. Save a component in file aComponent.skp
  2. Import the component into your working file, perhaps workingFile.skp

To UPDATE the component (similar to an XREF in Autocad)

Whenever you make changes to the aComponent.skp file, all you need to do is go into your workingFile.skp and find the component you loaded (I made one called weirdThing here) in the OUTLINER, not the Component window.

  1. Right click on the component's name in the OUTLINER.
  2. Choose "Reload..."
  3. Sketchup asks you for the file to update it with. Choose aComponent.skp -- or any other file with a component definition of the same name inside it!

NOTE: This doesn't work if you right click on the name in the Component List (see image below).

enter image description here

1
votes

Not sure if this is a programming question or user question, but if it's programming question then you can use DefinitionList#load to load the new SKP file, then use ComponentInstance#definition= to replace the instances for the definition you want to replace.

http://ruby.sketchup.com/Sketchup/DefinitionList.html#load-instance_method http://ruby.sketchup.com/Sketchup/ComponentInstance.html#definition=-instance_method

If this is a user question, then I'd recommend you ask in the Superuser site (https://superuser.com/) or the SketchUp forums: https://forums.sketchup.com/

0
votes

While SketchUp doesn't link models and you can't automate changes from one model to another (without a plugin anyway), there is a way to replace a component with a different one. Are you comfortable using the Ruby console? If so, do the following (note that this assumes your objects are components!):

  1. Select the old component instance, the one you want to replace.

  2. Open the Ruby console (Window -> Ruby Console).

  3. Type the following (you must have the old instance selected):

    old = Sketchup.active_model.selection.first

and hit enter.

  1. Import your new object (unless you already have) and place it somewhere in the scene (somewhere it's not in the way and you can find it easily).

  2. Select the new component instance, your new object that you just imported

  3. Type the following in the Ruby console (you must have the new instance selected):

    new = Sketchup.active_model.selection.first

and hit enter.

  1. Now, to replace the old component with the new component, type the following in the Ruby console:

    old.definition = new.definition

and hit enter.

That should replace the old component with your new one. You can now delete the object you imported earlier. It would probably be a good idea to purge your model too. Note the replacement uses the old instance's coordinate axis location. As long as these are the same model, just with some edits, you shouldn't have any trouble.