10

I'm new to Blender, and coming from an Acad background; so apologies if my terminology is a little off...

I'm trying to construct a 'stretchable array' comprising a module that can stretch and deform within defined limits and repeat itself such that it exactly fits a given length.

I'm attaching an image which hopefully illustrates what I'm talking about:

enter image description here

I'm happy to explore solutions which incorprate Sverchok, Tissue, etc.

Thanks

Robin Betts
  • 76,260
  • 8
  • 77
  • 190
Strawberry
  • 329
  • 2
  • 15
  • "I'm happy to explore solutions which incorprate Sverchok, Tissue, etc." This, in principle, is a Blender community. – Lukasz-40sth Jan 13 '20 at 12:48
  • @Lukasz-40sth Are Add-ons not allowed then?; I rather thought that was the point of Blender – Strawberry Jan 13 '20 at 13:01
  • They aren't but people here mainly use Blender and it may be hard to make you happy. And what do you mean? Do you want to do it with addons? – Lukasz-40sth Jan 13 '20 at 14:10
  • No. I'm just happy to explore a variety of solutions (and would be content with one) – Strawberry Jan 13 '20 at 14:39
  • 2
    Nice question. It's not clear in my mind what you are actually building: from a given a radius, how many elements do you expect to generate? a custom amount? or something correlated with the radius? Could you give us some examples of implementation? – Carlo Jan 13 '20 at 19:47
  • @carlo I'm trying to construct a grille of indeterminate length. This design is a bit simplified from what I really have in mind, but the principle is similar. – Strawberry Jan 13 '20 at 21:42
  • Would an example be like a target store logo that which, when scaled outwards, would add more rings to the symbol? – Nate_Sycro27 Jan 16 '20 at 22:02
  • @Nate_sycro if it allowed that all rings were the same width and the diameter could be any increment. – Strawberry Jan 16 '20 at 22:04
  • Yes like that. When it is scaled up the new rings would have the same band thickness, but a greater size. – Nate_Sycro27 Jan 16 '20 at 22:05
  • @nate_sycro27 Robin's solution below is technically perfect; I'm just curious to see what other ideas might be out there. Also, in reality the shape is more complicated- but that's for another day. – Strawberry Jan 16 '20 at 22:25
  • His seems like the correct answer. I was considering adding another answer just for the sake of demonstrating this kind of effect on any object. – Nate_Sycro27 Jan 16 '20 at 22:26

2 Answers2

9

Here's a first shot using drivers, with a set-up to keep the expressions as simple as possible to begin with.

The X location of an Empty('End'), marks the length of the array. Moving 'End' in X changes a collection of driven values, and stretches the array. Everything is parented to another Empty at the origin, ('Start') so the rig works in Start's space, and can be moved about.

The arrayed object is a rectangle with 2 shape keys. The Basis key is set to width 0. The 'Width' key is set to width 1 at relative value 1, so the Value directly encodes the width.

The Count of the array is driven as follows:

enter image description here

The shape key of the rectangle is driven by the 'End' Empty, too:

enter image description here

... and the rectangle is rounded top and bottom by a driven Bevel modifier:

enter image description here

..with this result, so far:

enter image description here

I don't know whether this satisfies your requirements directly, but I'm sure it could be adjusted?

Robin Betts
  • 76,260
  • 8
  • 77
  • 190
  • Hi, this looks very promising indeed. – Strawberry Jan 14 '20 at 08:33
  • 2
    i have to confess, not only can I not figure out how this works, I can't even figure out what object/parameter you're manipulating in the gif - I think I need a book... Ah, you're dragging the 'end' object; well, that's a start... – Strawberry Jan 14 '20 at 17:41
  • 2
    @Strawberry Hmmm .. how can I help? You could mute the modifiers, so you can see what they're doing... , or .. right-click the purple driven fields, and ' Open Driver Editor', adjust the expressions to see the effect? Get stuck, ask for a clarification, and I'll do my best. PS, you can delete the guide line, it's irrelevant, I was just using it to measure up. – Robin Betts Jan 14 '20 at 18:44
  • 2
    The main manual section to read up is Drivers – Robin Betts Jan 14 '20 at 18:48
5

Use self with drivers

Good example to show usage of use self with drivers. This way can put a property on an object (aka self) and drive other properties of that object with the property.

enter image description here

For example sake I'm using the width 2 as my basis width.

On the to be arrayed object added a custom property "length". Note: The minimum is set to the size of the minimum units length in this case 2 to avoid zero division errors in driver expression. this could be handled for the single unit case

The origin of the object has been moved x-wards to zero such that object scales left to right.

Now it becomes a matter of driving the array count and x scale to fit our length following the rules outlined

The property we created, the array modifier count and scale all belong to the arrayed object so can take advantage of "use self" in drivers. This isn't default, so have to check the use self checkbox in driver editor to use

The variable self is the driven object. For the case of the array modifier the modifier is the object being driven ie self is the array modifier object, BUT the ID object it belongs to is self.id_data. So in the expression this will be the arrayed object. Bit confusing at first. If say we wanted to bring the x offset of the modifier into our calculation it would be self.relative_offset_displace.x

Default array mod setup, with x relative offset 1.

enter image description here

Driving the array count.

How many 2 width base units fit our length. The integer div operator // gives us this.

enter image description here

self.id_data["length"]  // 2

Driving the scale

Knowing the length and count above, how much bigger must a unit be than 2 to fit the length. Notice how for scale use self["length"] // 2 as the scale property belongs to the object..

enter image description here

(self["length"] / (self["length"] // 2)) / 2
batFINGER
  • 84,216
  • 10
  • 108
  • 233