1
$\begingroup$

I have a modal operator that adds and adjusts an array of elements along a curve, but I have a problem with scaling. I'm using the 'Fit to Curve' setting for the array modifier so it automatically adds the necessary duplicates of the object until it fits the curve.

If I scale normally this happens (it just scales in 2 dimensions and ignores the curve as an axis):

GIF - What happens if I scale the object...

This can be solved by applying transformations after with a KeyPress (similar to pressing Ctrl+A) but you won't see the correct effect until that moment, so it's not exactly ideal for a modal operator you're constantly adjusting and where seeing the correct result live is kind of the point.

I figured the solution was to apply transforms constantly but then I'm just scaling the already scaled object and the modal scale grows exponentially and has other unintended side effects as well.

This is the effect I would like to achieve (right now I get it by going into edit mode and scaling the mesh directly):

GIF - The effect I am looking for...

The obvious problem is that I have to leave the modal operator, select the faces, press S to scale the object, then go back in to the modal.

I would very much like to be able to replicate the effect of Scaling in Edit Mode without going into edit mode or at least enter and exiting fast enough that the user doesn't realize it. The desired effect being: the object transforms stay at (1, 1, 1) but moving the mouse to the right increases the scale and to the left decreases it with no exponential growth.

I tried doing something like this:

val =  self.start_scale + (start_mouse_x - current_mouse_x) * multiplier
scale_matrix = Matrix.Diagonal((val, val, val, val))
mesh.data.transform(scale_matrix)

The advantage is that I avoid switching into edit mode entirely, the disadvantage is I have the same problem as if we were constantly applying transformations (I'm just scaling the current scale again and I get the same exponential growth instead of setting an absolute scale value).

So...

What's the best way of mimicking the Edit Mode Scale where mouse to the right makes the scale bigger, to the left makes the scale smaller and the object transform stays at (1, 1, 1)? The other important aspect being that the scale is not multiplying itself, but rather increasing/decreasing with a constant effect and NOT exponentially.

$\endgroup$
4
  • 1
    $\begingroup$ Hi. In future, please use the built-in uploader when adding images. See: meta.stackexchange.com/questions/75491/… . Thanks. $\endgroup$ Jun 8, 2020 at 17:03
  • $\begingroup$ Hi, thanks for helping me. I tried but it wouldn't work for me. I kept getting an error, I think it said the size was too big. Do you have special privileges that allow you to bypass that? $\endgroup$ Jun 8, 2020 at 19:30
  • 1
    $\begingroup$ No, I don't have special privileges. If you click the 'edited 2 hours ago' link below the question you can see I just changed the formatting a bit to display the images. $\endgroup$ Jun 8, 2020 at 19:46
  • $\begingroup$ I remember now, it said Imgur wasn't responding whenever I tried uploading the image with the link I had. Who knows what that was about. Thanks! $\endgroup$ Jun 8, 2020 at 23:30

1 Answer 1

2
$\begingroup$

Use shape keys

enter image description here

Demo, set up with array (fit curve) and curve modifier. The cone is given a shape key which is 1 / 10 the scale of original. Because the array modifier is using the mesh dimension this "emulates applying scale" in the modifier.

For set up above, when the shapekey value is dragged to 1, the "scale" is 1/10 making 10 x more cones fit the path.

$\endgroup$
1
  • $\begingroup$ Oh cool, I know how shape keys work but it’s something I never would of thought about using if you hadn’t mentioned it. I think this is an acceptable solution and should be fairly simple to implement as well. Thanks for the idea. $\endgroup$ Jun 9, 2020 at 14:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .