Referencing component instances/copies

Here i have a wall made of 3 panels, which are the same component definition “panel” and hence have the same formula. The windowLocation attribute hides the panel if the window component has the same position as the panel. ( i plan to replace it with a panel that has a structural opening cut out on it later ). The good news is that it works; the bad news is that it only works for the first window definition. If i try to hide another panel by dragging another window out from the component browser it doesn’t work

I can only assume that sketchup is unable to reference component instances/copies? Is there a way round my problem? all i can think is that each new window should be a new component definition that is included in the windowLocation attribute, but that would cumbersome

attached is the sketchup modelhide panel.skp (241.3 KB)

Thanks in advance

The “windowLocation” name is not something that is standard to Dynamic Components. It is just a custom attribute name, and asking us what it should contain, is like asking us to guess what your having for supper tonite. :stuck_out_tongue_winking_eye:

Look in the Component Manager, then in the “Dynamic Components Training” collection (folder) and at the “Fence” component. Examine how it deals with copies.

Look at other example components, also in the “Components sampler” collection.

If you’re going to ask about a certain component, either give a link to it on the 3DW, or post a copy in the thread, preferably the first post, which you can edit (with the pencil icon.)

And install an attribute inspector if you’re going to work with DCs.
I myself, like Aerilius’ Attribute Inspector, but there are a few others on the Extension Warehouse.

Hi DanRathbun, thanks for your response. I’ve attached the Sketchup model to my original post.

I played around with the fence example. It illustrates nicely how to repeat a component x number of times which i’m ok with. What i’m struggling with is how to control individual component copies, and in particular how to control them from other components

for example in my model within any particular panel copy i’m able to control it’s visibility using the “windowLocation” attribute(which references the win definition). Then (from within the panel still), if im trying to reference a copy of the “win” component it doesn’t work. It can only reference the original win definition.

Thanks

It is actually the original instance, (ie definition.instances[0] in Ruby.)

I just played a bit. DCs are accessed by Name attribute (which is really keyed as “_name” in the attribute dictionary.) When sub-components are copied, everything is copied including the name. So they all dumbly are named “Window” or “Picket”, etc. If you were to manually number them, then it plays havoc on the DC engine, and you get each copy making copies of itself.

This would need to be filed as a Feature Request, ie: Being able to refer to each copy instance by Name, ie as each copy is created they are numbered. This means there must also be some check that Names are unique within each nesting context.

1 Like

I modified your formulas and included a window x position on your parent “wall”
hide panel.skp (144.3 KB)

One can address each copy via the copy value, for example in say lenZ, could put:
=if(copy=1,40,30)
I created a door that uses one copied panel that changes configuration and size

However this is rather complicated, and works only within the component instance. Although one can copy or move sub components into other components, (this can be done by mouse select and drop via outliner) but this breaks the original formulas/relationship. Which maybe okay ? like for creating openings through multi groups of wall leafs and exploding the result.

I do believe that you should consider the more conventional approach, use the internal copy only for panels that are the same in a wall, with special panels for openings. The panels should be made to swap and retain certain hierarchy data when changes are required. If you decide on the this approach, I will help you build them to suit your needs,and encourage you to create some scripts for easy placement.

It was worth perusing your ideas, hence the slow response. but still believe the swap-able panel system would be more function-able and simpler

1 Like

I do not really understand what you are doing.
you can not just drag another copy of a component into a dynamic component and have it work as part of the dc

all copies need to be created and controlled by the dc.

If you want a window to be a part of each panel then the window needs to be nested inside the panel.

If your ultimate intention is to make a window that cuts two faces -I believe I tried when I started learning DC’s and could not make it work and I do not think that any major improvements have been made to DC’s in the mean time.

Instead you would construct a DC wall that has an opening something like this:

1 Like

Hi Chris, thanks for your response

Every time the user wishes to add another window to the wall, they can do so by inputting the number of copies desired in the copies field (ill add a dropdown menu later). This creates copies of the window. Then when they drag one of these copies into the correct position, on one of the panels, it hides the panel (this is so i can replace it with a panel with an opening for a window(i will develop this later) ). Unfortunately this only works for the original component definition, not any of it’s copies.

I’m not dragging any components into any dynamic components, im trying to reference component copies from other components of a different definition.

“If you want a window to be a part of each panel then the window needs to be nested inside the panel.”

I hear what your saying, but I only want the window to show in panel where the user chooses it to be and it a makes sense for it to be dragged into position. I could include a window in the panel definition(and hence all it’s copies) but then a user wouldn’t be able to control it’s visibility by dragging it into position. They’d have to use the on click attribute on the panel concerned(or something similar) which isn’t the functionality I want

“Instead you would construct a DC wall that has an opening something like…”

This could possibly be a better alternative to hiding the panel and replacing it with a new one that has opening cut into to it. However, if this change propagates through all copies of the definition, then this is undesired behaviour; i need it to only effect the copy concerned

Thanks again

Except you did not create the new window by modifying the copies attribute.

" I’m not dragging any components into any dynamic components,"

Yes you did - you dragged a copy of win from the component browser into your DC

Well I am still not clear what you are trying to accomplish.
Currently the window does not have a hide attribute at all.

All Components are identical unless you make them unique.

You need to describe exactly what you want the behavior of your DC to be.
A copy within a DC is not the same as a copy of the DC or any component outside the DC.

You can not reference components outside of the DC -so you can not make a DC that can control some other DC or automatically changes based on the status of some other component which is not part of the DC

so i tried the approach of creating a copy and giving it a different name (or as you put it “manually number them”):


With this different name, i’m able to reference it using the “windowcopynumber” attribute in the parent wall component. However like you said it does causes problems of unwanted copies:

I could i suppose delete the unwanted copies, but it’s not the ideal approach. This issue should definitely be filed under the Feature Requests, as it has been explored before ( which pcmooor has contributed to)

thanks

1 Like

If I make a component A

then make a component B

I can not make A know anything about B

or B know anything about A

Unless they are combined into a master component and then those specific instances are referenced. Which means that you would need to modify the DC attributes anyway.

Think of a DC as being a little program in itself - it can only act on itself and it can only do what it is programmed to do.

I do think that it might be handy to be able to grab sub components out of a library instead of having to have every possibility contained within the DC but I have not seen any indication that DC capabilities are going to be enhanced.

ok so i’ve re-recorded my example this time creating the copy of the window from it’s copies attribute. But it makes no difference.

you can see that once the copy is made it is moved, but not dragged into a dynamic component, because it remains at the same level of hierarchy; it doesn’t become nested within the panel

im not trying to hide the window; im trying to hide the panel when a window copy is placed on top of it. Then once i have this functionality working i will replace this hidden panel with a panel like this:


so that the window can sit within the structural opening:

You can not nest components within other components on the fly

If you want win to be a possibility of a panel it needs to be in every panel.

I looks to me like you want to create a hole in a panel and then add a window to it

The way that you are trying to do this is not possible currently.

you need to rethink how you are trying to accomplish this.

The panel and all it’s properties needs to be self contained.

You cannot make a component automatically modify another component by dragging it into it.

It is not possible to make a hole in two solid faces that can move.

The only way to accomplish this is like the wall DC example I linked to.

im not trying to do this [quote=“eskimo, post:11, topic:38126”]
you can see that once the copy is made it is moved, but not dragged into a dynamic component, because it remains at the same level of hierarchy; it doesn’t become nested within the panel
[/quote]

my first objective is to hide the panel when the window is positioned above it:

I have achieved this but only using the original win definition; not its copies. I would like to use the copies to do this aswell

thanks

I am still not sure what you are trying to do -your picture shows a panel with a hole in it but you dc properties hides the whole panel.

panel hole.skp (329.3 KB)

Hi pcmoor thanks for your response,

so i had a play with your modification:


thats great - I can move the window and it hides a panel - however, i’d like to take things one step further and hide a panel with a window copy:

What do you think? I would happy to accept a work around solution. I am new to dynamic components but i was thinking instead of moving the copy we could move the original definition and the copy would take it’s place:


however the problem is when I run redraw, the middle panel doesn’t remain hidden( because its looking for the original win definition which is no longer there). Could we perhaps add a counter or something to the panel component so that once it’s been hidden once it remains hidden? I’ve had a look at your door example which has shown me the great possibilities so a simple workaround shouldn’t be too hard?

thanks

Hi Chris

Thanks

You are lacking a fundamental understanding of how SketchUp and components and copies work.

You can not manually drag a copy into another component.

All you are doing above is using the copy attribute to make a copy of win and then manually changing the position of the copy of win

dragging it into the same space as the panel does not make it become part of the panel any more than any two components would interact with each other if they occupy the same space

PCMoors example hides panels based on the position of win

In the second gif when you made the copy you actually moved the original and it behaved as pcmoore programmed it to.

In the first gif you made a copy (which is not referenced to in the dc) and then moved that copy.

1 Like

im not trying to do this[quote=“eskimo, post:7, topic:38126”]
I’m not dragging any components into any dynamic components, im trying to reference component copies from other components of a different definition.
[/quote]

im not trying to make it part of the panel. I realise that they do not interact with each other if they simply occupy the same space, which is why i’m referencing the window position from the panel instead of trying to make it part of the panel

which is exactly what i’m trying to do. Now i’m just trying to extend this functionality by hiding panels based on the position of a window copy

yes moving the original is part of the workaround around i’m proposing. The user knows no difference bewtween the original and it’s copies.

yes i know but it makes no differnce[quote=“ChrisStewart, post:17, topic:38126”]
You are lacking a fundamental understanding of how SketchUp and components and copies work.
[/quote]

I have been using sketchup components for years. With regards to copies, if what i’m trying to do is unachievable then thats why we can look at a work around and file a feature request

Perhaps you mean the original instance, ie, the copy number 0 ?

You cannot “move” definitions, as they do not appear in the model. Ie, they cannot be placed (or moved) as they do not have a transformation property.

1 Like

Still not clear of what your intent is but you can not access a copies attributes dynamically

So for example:
I can make a formula like this: =win!(attribute)

but not something like: =wincopy001!(attribute)

What is the use of hiding an unknown number of panels based on the position of an unknown number of blocks?

1 Like