Tricky Dynamic Component question


Hi there,

I’m dealing with a rather difficult challenge: I’d like to make a dynamic component that contains cabinets. I’d like to make the component scalable in one direction, in this way, that the more I stretch it, the more cabinets doors will appear.
Now I can make a ‘fence-like’ component that adds copies of the cabinet doors and positions them according to the total length of the component. However, I’d like to add something extra:

I want my doors always equally divided over the total length. So let’s say, at a total length of 1,5 meter, I’d like to see 3 doors, equally divided. When I stretch my component until 2 meter, I’d like to see 4 doors. When I make my component 1,75 meter, I like to see either 3 or 4 door, depending on the following: When my door width exceeds a certain number (let’s say 55cm), I’d like my component to add a 4th door automatically.

I figured I have to use the ‘IF’ functionally somehow, but I can’t get my head around it. Hopefully there’s someone out there with lots of experience and a well working brain!

Thanks in advance.


Hey, so you don’t need an IF Statement, just math.
So the logic I used was the total length divided by the door width to get the amount of doors you need. To get the remainder, I did total length minus the total sum of the copies. With the reminder space, I divided it by the amount of copies minus 1.
So 3 doors of 30" is 90"
Total length of 100
Reminder space is 10"
10 divided by (3 doors-1), and thats the gap between doors.

This was trickier than I imagined, so I’m pretty sure my method can be cleaned up to a cleaner formula. but this seems to work.
Good Luck.

Dynamic_Door_Copy.skp (87.7 KB)


Thanks for you quick response Quantj, this is getting really close to what I’m looking for!
(I’d like to increase the number of doors only when the door width would exceed a certain value, instead of a preset width, plus I don’t need the gaps).
I’m gonna try to get my head around it and see if I can understand the way you made your block. It’s already very interesting since I just started building dynamics since a few days


I realized I misread your first post.

Try this one:
So it’ll change the door width up to a Max of 50" before adding another copy and re-adjusting all sizes.

I feel like this was mentioned before in this forum somewhere, maybe there’s more info about this somewhere. I couldn’t find it when i searched, but I swear I’ve made something like this before for another post.

Dynamic_Door_Copy-2.skp (95.9 KB)


Quantj you have no idea how grateful I am! Thank you so much :slight_smile: 'm gonna spend some time figuring out how you made this component. This is exáctly what I was looking for.


So, I’m slowly understanding how the component works, and I’m ready for the next challenge. Since the cabinets doors are gonna have handles to open them, I’d like to position every other door mirrored (so the opening handles will be adjacent to one another.
I figured I don’t necessarily need coding for that, since I can manually flip every other door.
However since the axes of the door are not positioned in the middle, I thought I should change the axes to the middle, and then change the code at Door, Position X (=IF(Copy=0,0,((CopyLenX)-LenX))), to =IF(Copy=0,(0.5LenX,((Copy*(0.5LenX))-)(0.5LenX)))

However, I unfortunately found out that doesn’t work. Probably because of the order in which the attributes are followed. How would I build a cabinets component with flipping doors?


you could wrap the component within another with opposite axis


Hey Pcmoor, that doesn’t work unfortunately, since it’s always the mother component (of the door itself) that needs to be mirrored.


Haven’t tried to see is this would work, but what about having the knob in the component and have a formula to make it flip if the COPY is an even number or not?

Also, you might want to clean up what i did previously if you’re reusing my old model, i was sloppy with how I treated COPY0, sorry :stuck_out_tongue:


Hmm… That doesn’t work since I have to change the door’s axes to the middle in order to flip it around it’s middle. Doing that destroys the model, and I’m not sure why


What about creating 2 knobs? 1 is hidden on EVEN copy and other it hidden on ODD copy?

and you don’t necessarily have to flip the knob once, you can have it rotate and move position on Copy number, it’s more complicated, but I think it could work, definitely not a clean solution though.
KNOB!LENX=IF(FLIP=1, x-350,x)
…something like that


That’s definitely an option! Thank you for that. I’m still very curious though, if it would be possible to actually flip a subcomponent. With the position, length and rotation values, I can’t (as far as I know), flip a subcomponent. Entering negative values for position or length don’t seem to work (which I understand).

So If somebody knows how to actually flip anything?


What about the following approach:

Door axis in the middle
Width custom variable created as described above, based on length of component/remainder, etc
LenX of door equal to = IF(ISEVEN(COPY),Width,Width*(-1))

Does that work?