Notifications
Clear all
[Closed] Modifier gizmo size
Jul 13, 2010 10:28 am
I’m making a script that creates curtains of variable sizes out of a plane through various modifiers.
One of them is a wave modifier for which I need the wave gizmo to always be of a certain size.
Is there any way that I can set the size of a modifier gizmo to be [100,100,100] for instance?
2 Replies
Jul 13, 2010 10:28 am
Hmm, I think I figured it out actually.
When I apply the modifier it auto wraps around the object it’s applied to, so I can get the size of the gizmo and divide the desired size by the size of the gizmo.
o = $
objgizmo = o.modifiers[#Wave].gizmo
gizmosize = o.max - o.min
desiredsize = [100,100,100]
objgizmo.scale = desiredsize / gizmosize
Jul 13, 2010 10:28 am
Just replying to my previous post in case this might help someone.
Made some adjustments to my previous solution, now it can be used for 2 dimensional gizmos too and it doesn’t matter in what orientation the gizmo or object is.
-- Return num if num is a valid float, otherwise return 1.0 (incase it's just a 2 dimensional gizmo)
fn returnScale num = if (bit.isFinite num and num > 0) then return num else return 1.0
-- Set the gizmo size of a modifier
fn setGizmoSize obj objmod gizmosize =
(
local modsize = (getModContextBBoxMax obj objmod) - (getModContextBBoxMin obj objmod)
objmod.gizmo.scale.x = returnScale (gizmosize.x / modsize.x)
objmod.gizmo.scale.y = returnScale (gizmosize.y / modsize.y)
objmod.gizmo.scale.z = returnScale (gizmosize.z / modsize.z)
)
setGizmoSize $ $.modifiers[#Wave] [100,100,100]