Update Reference to Sibling aka Global Attribute

Hi Folks,

this is my first post. I’ve been reading along for some time now, but didn’t find a solution
to my current problem. So I hope you can help me.

I’ve been searching for a way to make some kind of global attributes which can be referenced by multiple
DCs. For example, I want to change the Material or thickness of furniture parts in one place.

One solution I found is to make a component on the sibling level and reference its values via
SiblingComponent!attribute. This works fine for the first time, but when I change the value, the components using this reference don’t update by themselves. How can I achieve that?

I don’t want to put all components in one big component to reference it as parent!. This seems rather messy.

Or is there a better solution for my problem?

EDIT: I just found out that if I have a setup like above, change some value on the furniture component via Component Options and click apply, the reference to the sibling attribute updates. However, I want this to happen automatically.

Thanks in advance
Christoph

The Model level itselfs act as the highest Parent level.
Consider a component as a mini-SketchUp file…
When you have a model, you are actually in a component.
The thing is, DC won’t display the model attributes through the panels, allthough they can have them (but it is a bit cumbersome to set them, since you have to import the model in a new file, set the attributes in the DC panel, save it and open again)

Instead:
Make dummy components (I sometimes just draw a recrangle and make it a component). Set the attributes for the glob al settings, do not nest them in the existing, but put them somewhere in the model. Name it GlobalComponent or simular.
Refer to them in the existing components.
You need to redraw when you make a change in the global component, however.

Refer in the existing components to GlobalComponent!MaterialSetting etc.

Also see this thread:

Thanks for your reply Mike.
That`s basically how I do it. I realised now that I just need a way to quickly redraw all DCs.
I’m looking into it.

1 Like

OK I have a working solution. I used this code

 Sketchup.active_model.selection.grep(Sketchup::ComponentInstance).each do |s|
    $dc_observers.get_latest_class.redraw_with_undo(s)

end

and bound it to a custom toolbar button via toolbar editor.

2 Likes

You mean the one created by @Aerilius ?

Here is a link for the ones who might be interested:

https://extensions.sketchup.com/en/content/toolbar-editor

Yes, that’s the one. Works really well.

1 Like

Hi, I just came across this post as I want to create a toolbar where I can adjust global settings.
My question is where and how do I add this code into my Sketchup model?
Thanks

I use DCs extensively every day. I did not know you could do this.
Awesome!

Hi, have a look at this Customize Toolbars in SketchUp - YouTube video. It’s explained around the the 3:20 mark.

I can’t get this to work. I am trying to make a custom button in Toolbar Editor but when I try to save it, it won’t let me (I get a red Border around the code text box, can anyone advise (see screenshot attached)…

Sketchup.active_model.selection.grep(Sketchup::ComponentInstance).each do |s|
  $dc_observers.get_latest_class.redraw_with_undo(s)
end

You need to end the block…

Thanks, that worked in so far as being able to create the button for the redrawing, however how can I create and access the global attributes?
I would like to set the attribute values by creating another custom button which brings up the Global Attributes box. I know how to do it with the ‘swatch’ method but I am creating a plugin and prefer not to have to right click on the swatch as it sems a messy workaround.
Can anyone advise what code to use to access a global attributes box?
Thanks

Hello, is anyone able to answer this? I would appreciate it I can get any help on it, thanks

Hey, there is no ‘global attributes panel’, you need to create a DC with those attributes and nest the rest of your DCs inside it. @MikeWayzovski describes and links a thread above.

Thanks for the replies / responses much appreciated. However what I’m trying to achieve is being able to set the Global Component Attributes with the model itself as being the parent, as described above. I understand that there is no easy way to do it as sketchup doesn’t show any attribute box for the model as standard, however I’m trying to make a plug in whereby this would be one of the features, so I assume it would be possible with custom code and could be accessed by a custom toolbar button to show the pop up attributes box. So does anyone know if such a code example exists and where I might be able to find it? Or is this a job for a developer?