Referenced file in Outliner

We have multiple people working on different parts of a model at any given time. In order to do this, we all work on certain parts of the model in separate sketchup files and then x-ref all of those files into a final combined sketchup file. It sure would be nice when in the “final” sketchup model that contains all of the x-refed files that you could click on that referenced model in the outliner and open up that referenced model directly from there. Am I missing something or does this just need to be added to the wish list?

Seems like HonoluluDesktop wrote an old extension to do this before he died.
Might still be a very old edition over at SketchUcation.

Basically it’d be a right-click context menu handler since the instance is selected when you right-click it (whether in Outliner, the modeling area or the “In Model” Components collection panel.)

Wacked this out. It seems to work okay. Try it …

(Keep in mind that after making changes to the Xref files, you’ll need to reload them manually in the “final model” unless the Xref Manager extension detects that changes have been made.)

# Windows ONLY
module Example
  module RightClickOpenComponentFile

    @@loaded = false unless defined?(@@loaded)

    unless @loaded

      UI.add_context_menu_handler do |menu|
        selset = Sketchup.active_model.selection
        if selset.single_object?
          cinst = selset.first
          if cinst.is_a?(Sketchup::ComponentInstance) 
            cpath = cinst.definition.path
            if cpath && File.exist?(cpath)
              menu.add_item('Open File in new window',5) {
              menu.add_item('Open File in this window',6) {

      @@loaded = true


That worked!! We just counted that as a HUGE WIN!! Our department has been bitching about this for years! THANK YOU!

1 Like

Glad to hear it!

@eneroth3 Perhaps your Cross Ref Manager could add context commands like this ?

So far I haven’t added direct access to opening a file as I wanted to keep my UI as clean as possible, but my reference manager has a button for opening the containing folder (with the file selected). Personally I have more use for this as I want to have the folders I work in open for direct access to other files in that project, but I can also see the point in directly accessing the file without having to open up a window for the folder.

Sure, that sounds useful.

A bit faster workflow. (The OP’s opening this FR is evidence that it is desirable.)

The above code will also open distro’d component library definitions (which may not be so desirable.)
Perhaps limiting to Xref definitions that have the manager’s attribute assigned would keep the UI a bit cleaner?

You can always have manager option(s) to toggle various context commands on / off. (Let the user use it their way.)

Oh, and I said “Windows Only” in the example above because the API docs mention encoding issues on Mac platform pre-2019.3 for UI.openURL(). Have no Mac to test with and decided to let someone else “weigh in” on this.

My extension has no custom attributes but relies on SketchUp’s native path property of the definition. This is how this manager functions on models created without it being installed.

I’m thinking it could have an entry in the context menu for Open Model, to allow for this option without cluttering the toolbar on manager window (both native context menu and inside the manager window).


Regarding, no attribute … interesting idea. That would also then work with Xref models created with other extensions that did write attributes but without messing them up. (They’d just need to resync any modtime info next time that extension was used. Not that users are likely to use more than one xref extension.)

I see your’s keeps track of when a xref model needs to be reloaded by reading the GUID of external skp files.)

Oh, and I just noticed a booboo in the API docs. It says definition#path returns false if the path is unsaved (ie, created in the model proper.) But testing shows it actually returns an empty string.
So, I was using a boolean test that doesn’t really matter …

if cpath && File.exist?(cpath)

… as "" resolves to true and File.exist? will return false for empty pathnames.

Could be just …

if File.exist?(cpath)

But is better practice as …

if !cpath.empty? && File.exist?(cpath)

… so Ruby doesn’t try to create a File::Stat object.

I’m checking definition.internal? to see if the component has an associated path. Only after I know a component is supposed to be linked to a file I check the path and whether a file exists.

To get back to the original topic, Eneroth Reference Manager could be changed to have an Open Model entry in the context menu, accessible in the context menu. It will however need some error handling and pedagogically phrased messages for internal components as well as missing files. I have other projects with higher priority but this is absolutely something I’ll take note of.

1 Like

In the absence of attributes, the another way would be an option to only add the context command if the clicked instance’s definition path matches the model proper’s path. (Ie, they are in the same folder.)

I can see scenarios where users accidentally modify library components for a specific project not realizing they’re editing a library file.

I think such increased complexity would be more in the way than helpful. Editing assets shared between projects, or shared between different parts withing the same projects, is a valid use case. Hiding the command for certain components could lead to the user thinking the plugin isn’t properly installed or malfunctioning.

Version 2.1.0 of Eneroth Reference Manager is submitted for review and will likely be live in a few days (may take a little longer now right after decamp though). This version lets you open any component from the context menu, and if the component is internal you are asked for a location to save it to.

Hi, i am very late to the party, i ask for a feature to handle xref in the same way 3dsmax / autocad handles xref as external files that dont add to the file size of the master file, does the Eneroth extension was able to do this?

example: xref_doors.skp(25mb), xref_main_buildings.skp(125mb), master_file.skp(2mb) is this posible?

SketchUp doesn’t support this kind of references, only embedded files. The reference manager can however help reload and organize, e.g. when cooperating.

Does anyone in the community asked or better get an answer from SketchUp team directly why they refrain from introducing this basic feature?

Does your reference (Xref) manager:

  • lock the Xref when inserted in the main model from being edited? as per AutoCAD (ignoring Refedit)
  • allow unlocking then editing of the Xref (via some form of Refedit) and which then saves the changes made back to the reference file?

Nope, no locking. The extension is intended to be useful both for loading in components from files and saving them out again. Some models are compositions with assets loaded in while others are collections with items being saved out. I have thought of ways to optionally impose rules here to avoid mistakes, but for the time being the extension is as simple as possible to allow for as many use cases as possible.

Thanks for the reply.

If a change is made to a reference file (Xref) within the main Model (as per Refedit) is that change then saved back and overwrites the original reference file (Xref)? i.e. as would happen within AutoCAD. I’m looking for this behaviour as AutoCAD’s Xref system always worked well.

Eneroth reference Manager only saves out to file or reload from file when you explicitly tells it to do so. When either the component or file changes it can ask you if you want to reload/save out, but it doesn’t do anything by itself.

But it can do it from within the app, even if you have to instigate it manually? If that’s the case that’s cool. Changing an Xref within the model and it then being out of sync with the original is a huge PITA.

Also, what’s the reason your app doesn’t automatically save the changes made to the Xref within the main model back to the original file? A technical programming thing?

If the extension silently wrote over external files it would be a huge risk for accidental data loss. The extension can just as well be used for models that drive the external files as models that passively consume the external files, and currently doesn’t know what way you are using it.