Select by Length

Hi I have a request, I'm sure it's quite simple. I have search but can't find the right thing. Although I would love to learn some scripting I have never found the time and for this one I really have such a tight deadline I am really hoping someone will assist.

I have about 1500 randomly sized boxes in a scene and I need to alter there lengths and hieghts but try and keep them random(ish). I would like to be able to globaly select them and do a change max/min size to them so only reducing or increasing and sizes outwith parameters set.

or/and

Select objects with width or length that exceed certain parameters then i can use the "Adjust Length, Width, Height"
script but that won't keep them random

I know this is a big ask but any help would be really appreciated

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

If I understand...

You work with parametric Length, Width, Height, not with scale and just need to reduce this params. Also search how to select them by property size. If so, maybe this examples can help.

-- get all boxes to array
boxes = for o in objects where classOf o == Box collect o
 
-- get bigger than 50 (in L or H)
selBig = for b in boxes where
	b.length > 50 or b.hieght > 50 collect b
 
-- get smaller than 50 (in L or H)
selSmall = for b in boxes where
	b.length < 50 or b.hieght < 50 collect b
 
-- decrease their length with 2%
for each in selBig do each.length *= 0.98
 
-- increase their length with 2%
for each in selSmall do each.length *= 1.02

my recent MAXScripts RSS (archive here)

titane357's picture

thanks Anubis for these well

thanks Anubis for these well commented line of script ! :-)

Swordslayer's picture

You can try this. Set min/max

You can try this. Set min/max values for the axis you want to use and hit button with the name of that axis:

try destroyDialog scaleInRange catch()
rollout scaleInRange "Scale in Range"
(
	button btnScaleX " Scale in X" 
	button btnScaleY " Scale in Y "
	button btnScaleZ " Scale in Z "
	spinner spnMinDimensionX "min X" across:2
	spinner spnMaxDimensionX "max X"
	spinner spnMinDimensionY "min Y" across:2
	spinner spnMaxDimensionY "max Y"
	spinner spnMinDimensionZ "min Z" across:2
	spinner spnMaxDimensionZ "max Z"
 
	fn scaleToVal obj val axis =
	(
		local point_3 = [1,1,1]
		local scale_ratio = val/(obj.max - obj.min)[axis]
		point_3[axis] = scale_ratio
		scale obj point_3
	)
 
	on btnScaleX pressed do
		if selection.count > 0 do
			for each in selection
				where NOT isDeleted each do
					scaleToVal each (random spnMinDimensionX.value spnMaxDimensionX.value) 1
 
	on btnScaleY pressed do
		if selection.count > 0 do
			for each in selection
				where NOT isDeleted each do
					scaleToVal each (random spnMinDimensionY.value spnMaxDimensionY.value) 2
 
	on btnScaleZ pressed do
		if selection.count > 0 do
			for each in selection
				where NOT isDeleted each do
					scaleToVal each (random spnMinDimensionZ.value spnMaxDimensionZ.value) 3
)
createDialog scaleInRange
grasshopper's picture

thanks for the tip, I'll go

thanks for the tip, I'll go and try that

titane357's picture

hello. as i'm bad scripter I

hello. as i'm bad scripter I just point you a solution.
You should duplicate as copy a box with a Xform modifier on top.
Then use ModmodZorb script to randomize boxes height for example, and then you can mofify result by changing Xform scale for eg.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.